Skip to content

Commit 1891d9c

Browse files
SimonCroppJimBobSquarePants
authored andcommitted
remove unused variables and methods (SixLabors#963)
* remove unused variables and methods * remove some redundant variables * remove some redundant variables * redundant variables * Update DrawTextOnImageTests.cs * Minor optimizations * cleanup
1 parent b365014 commit 1891d9c

7 files changed

Lines changed: 30 additions & 42 deletions

File tree

tests/ImageSharp.Tests/Drawing/Paths/DrawPathCollection.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors and contributors.
1+
// Copyright (c) Six Labors and contributors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System.Numerics;
@@ -50,7 +50,7 @@ public void CorrectlySetsBrushAndPath()
5050
ShapePath region = Assert.IsType<ShapePath>(processor.Region);
5151

5252
// path is converted to a polygon before filling
53-
ComplexPolygon polygon = Assert.IsType<ComplexPolygon>(region.Shape);
53+
Assert.IsType<ComplexPolygon>(region.Shape);
5454

5555
Assert.Equal(this.pen.StrokeFill, processor.Brush);
5656
}
@@ -68,7 +68,7 @@ public void CorrectlySetsBrushPathOptions()
6868
Assert.Equal(this.noneDefault, processor.Options);
6969

7070
ShapePath region = Assert.IsType<ShapePath>(processor.Region);
71-
ComplexPolygon polygon = Assert.IsType<ComplexPolygon>(region.Shape);
71+
Assert.IsType<ComplexPolygon>(region.Shape);
7272

7373
Assert.Equal(this.pen.StrokeFill, processor.Brush);
7474
}
@@ -86,7 +86,7 @@ public void CorrectlySetsColorAndPath()
8686
Assert.Equal(GraphicsOptions.Default, processor.Options);
8787

8888
ShapePath region = Assert.IsType<ShapePath>(processor.Region);
89-
ComplexPolygon polygon = Assert.IsType<ComplexPolygon>(region.Shape);
89+
Assert.IsType<ComplexPolygon>(region.Shape);
9090

9191
SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
9292
Assert.Equal(this.color, brush.Color);
@@ -105,7 +105,7 @@ public void CorrectlySetsColorPathAndOptions()
105105
Assert.Equal(this.noneDefault, processor.Options);
106106

107107
ShapePath region = Assert.IsType<ShapePath>(processor.Region);
108-
ComplexPolygon polygon = Assert.IsType<ComplexPolygon>(region.Shape);
108+
Assert.IsType<ComplexPolygon>(region.Shape);
109109

110110
SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
111111
Assert.Equal(this.color, brush.Color);

tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors and contributors.
1+
// Copyright (c) Six Labors and contributors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System.Numerics;
@@ -35,7 +35,7 @@ public void CorrectlySetsBrushAndPath()
3535

3636
// path is converted to a polygon before filling
3737
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
38-
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
38+
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
3939

4040
Assert.Equal(this.brush, processor.Brush);
4141
}
@@ -50,7 +50,7 @@ public void CorrectlySetsBrushPathOptions()
5050

5151
ShapeRegion region = Assert.IsType<ShapeRegion>(processor.Region);
5252
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
53-
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
53+
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
5454

5555
Assert.Equal(this.brush, processor.Brush);
5656
}
@@ -65,7 +65,7 @@ public void CorrectlySetsColorAndPath()
6565

6666
ShapeRegion region = Assert.IsType<ShapeRegion>(processor.Region);
6767
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
68-
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
68+
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
6969

7070
SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
7171
Assert.Equal(this.color, brush.Color);
@@ -81,7 +81,7 @@ public void CorrectlySetsColorPathAndOptions()
8181

8282
ShapeRegion region = Assert.IsType<ShapeRegion>(processor.Region);
8383
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
84-
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
84+
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
8585

8686
SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
8787
Assert.Equal(this.color, brush.Color);

tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors and contributors.
1+
// Copyright (c) Six Labors and contributors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System.Numerics;
@@ -51,7 +51,7 @@ public void CorrectlySetsBrushAndPath()
5151

5252
// path is converted to a polygon before filling
5353
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
54-
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
54+
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
5555

5656
Assert.Equal(this.brush, processor.Brush);
5757
}
@@ -70,7 +70,7 @@ public void CorrectlySetsBrushPathOptions()
7070

7171
ShapeRegion region = Assert.IsType<ShapeRegion>(processor.Region);
7272
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
73-
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
73+
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
7474

7575
Assert.Equal(this.brush, processor.Brush);
7676
}
@@ -89,7 +89,7 @@ public void CorrectlySetsColorAndPath()
8989

9090
ShapeRegion region = Assert.IsType<ShapeRegion>(processor.Region);
9191
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
92-
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
92+
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
9393

9494
SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
9595
Assert.Equal(this.color, brush.Color);
@@ -109,7 +109,7 @@ public void CorrectlySetsColorPathAndOptions()
109109

110110
ShapeRegion region = Assert.IsType<ShapeRegion>(processor.Region);
111111
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
112-
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
112+
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
113113

114114
SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
115115
Assert.Equal(this.color, brush.Color);

tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors and contributors.
1+
// Copyright (c) Six Labors and contributors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System.Numerics;
@@ -35,7 +35,7 @@ public void CorrectlySetsBrushAndPath()
3535

3636
ShapeRegion region = Assert.IsType<ShapeRegion>(processor.Region);
3737
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
38-
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
38+
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
3939

4040
Assert.Equal(this.brush, processor.Brush);
4141
}
@@ -50,7 +50,7 @@ public void CorrectlySetsBrushPathAndOptions()
5050

5151
ShapeRegion region = Assert.IsType<ShapeRegion>(processor.Region);
5252
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
53-
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
53+
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
5454

5555
Assert.Equal(this.brush, processor.Brush);
5656
}
@@ -66,7 +66,7 @@ public void CorrectlySetsColorAndPath()
6666

6767
ShapeRegion region = Assert.IsType<ShapeRegion>(processor.Region);
6868
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
69-
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
69+
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
7070

7171
SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
7272
Assert.Equal(this.color, brush.Color);
@@ -82,7 +82,7 @@ public void CorrectlySetsColorPathAndOptions()
8282

8383
ShapeRegion region = Assert.IsType<ShapeRegion>(processor.Region);
8484
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
85-
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
85+
Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);
8686

8787
SolidBrush brush = Assert.IsType<SolidBrush>(processor.Brush);
8888
Assert.Equal(this.color, brush.Color);

tests/ImageSharp.Tests/Drawing/Text/DrawText.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors and contributors.
1+
// Copyright (c) Six Labors and contributors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System.Numerics;
@@ -14,14 +14,6 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
1414
{
1515
public class DrawText : BaseImageOperationsExtensionTest
1616
{
17-
Rgba32 color = Color.HotPink;
18-
19-
SolidBrush brush = Brushes.Solid(Color.HotPink);
20-
21-
IPath path = new SixLabors.Shapes.Path(
22-
new LinearLineSegment(
23-
new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(20, 10), new Vector2(20, 10), new Vector2(30, 10), }));
24-
2517
private readonly FontCollection FontCollection;
2618

2719
private readonly Font Font;
@@ -103,23 +95,23 @@ public void DrawForEachACharacterWhenPenSetAndNotBrush()
10395
Pens.Dash(Color.Red, 1),
10496
Vector2.Zero);
10597

106-
var processor = this.Verify<DrawTextProcessor>(0);
98+
this.Verify<DrawTextProcessor>(0);
10799
}
108100

109101
[Fact]
110102
public void DrawForEachACharacterWhenPenSetAndNotBrushDefaultOptions()
111103
{
112104
this.operations.DrawText("123", this.Font, null, Pens.Dash(Color.Red, 1), Vector2.Zero);
113105

114-
var processor = this.Verify<DrawTextProcessor>(0);
106+
this.Verify<DrawTextProcessor>(0);
115107
}
116108

117109
[Fact]
118110
public void DrawForEachACharacterWhenPenSet()
119111
{
120112
this.operations.DrawText(new TextGraphicsOptions(true), "123", this.Font, Pens.Dash(Color.Red, 1), Vector2.Zero);
121113

122-
var processor = this.Verify<DrawTextProcessor>(0);
114+
this.Verify<DrawTextProcessor>(0);
123115
}
124116

125117
[Fact]

tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors and contributors.
1+
// Copyright (c) Six Labors and contributors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System;
@@ -41,21 +41,17 @@ public void DoesntThrowExceptionWhenOverlappingRightEdge_Issue688<TPixel>(TestIm
4141
{
4242
Font font = CreateFont("OpenSans-Regular.ttf", 36);
4343
Color color = Color.Black;
44-
float padding = 5;
4544
var text = "A short piece of text";
4645

4746
using (var img = provider.GetImage())
4847
{
49-
float targetWidth = img.Width - (padding * 2);
50-
float targetHeight = img.Height - (padding * 2);
51-
5248
// measure the text size
5349
SizeF size = TextMeasurer.Measure(text, new RendererOptions(font));
5450

5551
//find out how much we need to scale the text to fill the space (up or down)
5652
float scalingFactor = Math.Min(img.Width / size.Width, img.Height / size.Height);
5753

58-
//create a new font
54+
//create a new font
5955
Font scaledFont = new Font(font, scalingFactor * font.Size);
6056

6157
var center = new PointF(img.Width / 2, img.Height / 2);
@@ -64,7 +60,7 @@ public void DoesntThrowExceptionWhenOverlappingRightEdge_Issue688<TPixel>(TestIm
6460
HorizontalAlignment = HorizontalAlignment.Center,
6561
VerticalAlignment = VerticalAlignment.Center
6662
};
67-
63+
6864
img.Mutate(i => i.DrawText(textGraphicOptions, text, scaledFont, color, center));
6965
}
7066
}
@@ -241,6 +237,6 @@ private static Font CreateFont(string fontName, int size)
241237
return font;
242238
}
243239

244-
240+
245241
}
246242
}

tests/ImageSharp.Tests/ImageOperationTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void CloneCallsImageOperationsProvider_ListOfProcessors_WithDuplicateImag
8383
[Fact]
8484
public void CloneCallsImageOperationsProvider_Func_NotOnOriginal()
8585
{
86-
Image<Rgba32> returned = this.image.Clone(x => x.ApplyProcessor(this.processorDefinition));
86+
this.image.Clone(x => x.ApplyProcessor(this.processorDefinition));
8787
Assert.False(this.provider.HasCreated(this.image));
8888
Assert.DoesNotContain(
8989
this.processorDefinition,
@@ -93,7 +93,7 @@ public void CloneCallsImageOperationsProvider_Func_NotOnOriginal()
9393
[Fact]
9494
public void CloneCallsImageOperationsProvider_ListOfProcessors_NotOnOriginal()
9595
{
96-
Image<Rgba32> returned = this.image.Clone(this.processorDefinition);
96+
this.image.Clone(this.processorDefinition);
9797
Assert.False(this.provider.HasCreated(this.image));
9898
Assert.DoesNotContain(
9999
this.processorDefinition,

0 commit comments

Comments
 (0)