Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlm committed Oct 31, 2024
1 parent 894317d commit c5d315c
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/Consolonia.Core/Drawing/ConsoleBrush.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.ComponentModel;
using System.Globalization;
using Avalonia;
using Avalonia.Media;
using Consolonia.Core.Drawing.PixelBufferImplementation;
Expand Down Expand Up @@ -183,6 +181,8 @@ private static Color InterpolateColor(IGradientBrush brush, double relativePosit
break;
}
}
if (before == null && after == null)
throw new ArgumentException("no gradientstops defined");

if (before == null)
{
Expand Down
4 changes: 1 addition & 3 deletions src/Consolonia.Core/Drawing/DrawingContextImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ public void DrawGeometry(IBrush brush, IPen pen, IGeometryImpl geometry)
}
return;
}
default:
break;
}

Rect r2 = r.TransformToAABB(Transform);
Expand Down Expand Up @@ -270,7 +268,7 @@ public Matrix Transform
lineStyle = null;
if (pen is not
{
Brush: ConsoleBrush or LineBrush or ImmutablePen or ImmutableSolidColorBrush,
Brush: ConsoleBrush or LineBrush or ImmutableSolidColorBrush,
Thickness: 1,
DashStyle: null or { Dashes: { Count: 0 } },
LineCap: PenLineCap.Flat,
Expand Down
10 changes: 4 additions & 6 deletions src/Consolonia.Core/Drawing/PixelBufferImplementation/Pixel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Avalonia.Controls.Documents;
using Avalonia.Media;
using Consolonia.Core.Text;

// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Global
Expand All @@ -28,7 +25,7 @@ public Pixel(char character, Color foregroundColor, FontStyle style = FontStyle.
}

public Pixel(byte drawingBoxSymbol, Color foregroundColor) : this(
new DrawingBoxSymbol(drawingBoxSymbol), foregroundColor, FontStyle.Normal, FontWeight.Normal)
new DrawingBoxSymbol(drawingBoxSymbol), foregroundColor)
{
}

Check warning on line 31 in src/Consolonia.Core/Drawing/PixelBufferImplementation/Pixel.cs

View workflow job for this annotation

GitHub Actions / build

"[RedundantArgumentDefaultValue] The parameter 'style' has the same default value" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Drawing/PixelBufferImplementation/Pixel.cs(31,70)

Check warning on line 31 in src/Consolonia.Core/Drawing/PixelBufferImplementation/Pixel.cs

View workflow job for this annotation

GitHub Actions / build

"[RedundantArgumentDefaultValue] The parameter 'weight' has the same default value" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Drawing/PixelBufferImplementation/Pixel.cs(31,88)
Expand Down Expand Up @@ -71,12 +68,13 @@ public Pixel Blend(Pixel pixelAbove)
case PixelBackgroundMode.Transparent:
// when a textdecoration of underline happens a DrawLine() is called over the top of the a pixel with non-zero symbol.
// this detects this situation and eats the draw line, turning it into a textdecoration
if (pixelAbove.Foreground.Symbol is DrawingBoxSymbol box &&
if (pixelAbove.Foreground.Symbol is DrawingBoxSymbol &&
this.Foreground.Symbol is SimpleSymbol simpleSymbol &&
((ISymbol)simpleSymbol).GetCharacter() != (Char)0)

{

Check notice on line 75 in src/Consolonia.Core/Drawing/PixelBufferImplementation/Pixel.cs

View workflow job for this annotation

GitHub Actions / build

"[ArrangeThisQualifier] Qualifier 'this.' is redundant" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Drawing/PixelBufferImplementation/Pixel.cs(75,25)
// this is a line being draw through text. add TextDecoration for underline.
newForeground = new PixelForeground(this.Foreground.Symbol, this.Foreground.Weight, this.Foreground.Style, TextDecorations.Underline, this.Foreground.Color);
newForeground = new PixelForeground(Foreground.Symbol, Foreground.Weight, Foreground.Style, TextDecorations.Underline, Foreground.Color);
}
else

Check notice on line 79 in src/Consolonia.Core/Drawing/PixelBufferImplementation/Pixel.cs

View workflow job for this annotation

GitHub Actions / build

"[ArrangeThisQualifier] Qualifier 'this.' is redundant" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Drawing/PixelBufferImplementation/Pixel.cs(79,61)

Check notice on line 79 in src/Consolonia.Core/Drawing/PixelBufferImplementation/Pixel.cs

View workflow job for this annotation

GitHub Actions / build

"[ArrangeThisQualifier] Qualifier 'this.' is redundant" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Drawing/PixelBufferImplementation/Pixel.cs(79,85)

Check notice on line 79 in src/Consolonia.Core/Drawing/PixelBufferImplementation/Pixel.cs

View workflow job for this annotation

GitHub Actions / build

"[ArrangeThisQualifier] Qualifier 'this.' is redundant" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Drawing/PixelBufferImplementation/Pixel.cs(79,109)

Check notice on line 79 in src/Consolonia.Core/Drawing/PixelBufferImplementation/Pixel.cs

View workflow job for this annotation

GitHub Actions / build

"[ArrangeThisQualifier] Qualifier 'this.' is redundant" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Drawing/PixelBufferImplementation/Pixel.cs(79,160)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Avalonia.Media;

namespace Consolonia.Core.Drawing.PixelBufferImplementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public readonly struct PixelForeground
public PixelForeground(ISymbol symbol, FontWeight weight = FontWeight.Normal, FontStyle style = FontStyle.Normal, TextDecorationCollection textDecorations = null, Color? color = null)
{
ArgumentNullException.ThrowIfNull(symbol);
Symbol = symbol ?? new SimpleSymbol('░');
Symbol = symbol;

Check warning on line 12 in src/Consolonia.Core/Drawing/PixelBufferImplementation/PixelForeground.cs

View workflow job for this annotation

GitHub Actions / build

"[ConstantNullCoalescingCondition] '??' left operand is never null" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Drawing/PixelBufferImplementation/PixelForeground.cs(12,32)
Color = color ?? Colors.White;
Weight = weight;
Style = style;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace Consolonia.Core.Drawing.PixelBufferImplementation
{
public readonly struct SimpleSymbol : ISymbol
Expand Down
4 changes: 1 addition & 3 deletions src/Consolonia.Core/Drawing/RenderTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Media;
using Avalonia.Media.TextFormatting.Unicode;
using Avalonia.Platform;
using Consolonia.Core.Drawing.PixelBufferImplementation;
using Consolonia.Core.Infrastructure;
Expand Down Expand Up @@ -117,8 +116,7 @@ private void RenderToDevice()
if (!_consoleWindow.InvalidatedRects.Any(rect =>
rect.ContainsExclusive(new Point(x, y)))) continue;*/
if (pixel.Background.Mode != PixelBackgroundMode.Colored)
throw new InvalidOperationException(
"All pixels in the buffer must have exact console color before rendering");
throw new InvalidOperationException("All pixels in the buffer must have exact console color before rendering");

if (x == pixelBuffer.Width - 1 && y == pixelBuffer.Height - 1)
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand Down
1 change: 0 additions & 1 deletion src/Consolonia.Core/Text/GlyphRunImpl.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Avalonia;
Expand Down
2 changes: 1 addition & 1 deletion src/Consolonia.Core/Text/TextShaper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public ShapedBuffer ShapeText(ReadOnlyMemory<char> text, TextShaperOptions optio
var glyphInfos = Convert(text.Span.ToString());

var shapedBuffer = new ShapedBuffer(text, glyphInfos.Length,
options.Typeface ?? new GlyphTypeface(), 1, 0 /*todo: must be 1 for right to left?*/);
options.Typeface, 1, 0 /*todo: must be 1 for right to left?*/);

Check warning on line 17 in src/Consolonia.Core/Text/TextShaper.cs

View workflow job for this annotation

GitHub Actions / build

"[ConstantNullCoalescingCondition] '??' left operand is never null" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Text/TextShaper.cs(17,37)

for (int i = 0; i < shapedBuffer.Length; i++) shapedBuffer[i] = glyphInfos[i];
return shapedBuffer;
Expand Down

0 comments on commit c5d315c

Please sign in to comment.