Skip to content

Commit

Permalink
fixed code analysis warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
wickedmachinator committed Jan 17, 2024
1 parent 3771b59 commit e9c1a0b
Show file tree
Hide file tree
Showing 20 changed files with 39 additions and 77 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ dotnet_diagnostic.RCS1097.severity = silent
dotnet_diagnostic.RCS1239.severity = silent
csharp_style_prefer_primary_constructors = true:suggestion

# RCS1158: Static member in generic type should use a type parameter
dotnet_diagnostic.RCS1158.severity = silent

# RCS1202: Avoid NullReferenceException
dotnet_diagnostic.RCS1202.severity = silent

# RCS1075: Avoid empty catch clause that catches System.Exception
dotnet_diagnostic.RCS1075.severity = silent

Expand Down
5 changes: 1 addition & 4 deletions EtLast.AdoNet/EtlConnectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,7 @@ public static void ReleaseConnection(IProcess process, ref DatabaseConnection co
});
},
onClosed: connection => ioCommand.End(),
onError: (connection, ex) =>
{
ioCommand.Failed(ex);
});
onError: (connection, ex) => ioCommand.Failed(ex));

if (connection == null)
return;
Expand Down
2 changes: 2 additions & 0 deletions EtLast.ConsoleHost/ConsoleHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public ConsoleHost(string name)
HostArgumentsFolder = @".\HostArguments";
ReferenceAssemblyFolders.Add(@"C:\Program Files\dotnet\shared\Microsoft.NETCore.App\");
ReferenceAssemblyFolders.Add(@"C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\");

AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
}

protected override ILogger CreateHostLogger()
Expand Down
2 changes: 1 addition & 1 deletion EtLast.ConsoleHost/ConsoleHostSessionBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[EditorBrowsable(EditorBrowsableState.Never)]
public static class ConsoleHostSessionBuilderExtensions
{
public static ISessionBuilder UseRollingDevLogManifestFiles<T>(this ISessionBuilder session, int? maxFileCount, int? maxSizeOnDisk = 16 * 1024 * 1024)
public static ISessionBuilder UseRollingDevLogManifestFiles(this ISessionBuilder session, int? maxFileCount, int? maxSizeOnDisk = 16 * 1024 * 1024)
{
var folder = Path.Combine(session.DevLogFolder, "manifest");
CleanupManifestFolder(maxFileCount, maxSizeOnDisk, folder);
Expand Down
1 change: 0 additions & 1 deletion EtLast.Diagnostics.HttpSender/DiagnosticsHttpSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class DiagnosticsHttpSender : IDisposable, IEtlContextListener
private readonly IEtlContext _context;
private ExtendedBinaryWriter _currentWriter;
private readonly ExtendedBinaryWriter _eventWriter = new(new MemoryStream(), Encoding.UTF8);
private readonly ExtendedBinaryWriter _dictWriter = new(new MemoryStream(), Encoding.UTF8);
private readonly object _currentWriterLock = new();
private bool _finished;
private int _communicationErrorCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,8 @@ private void ListView_MouseDoubleClick(object sender, MouseEventArgs e)
};

var control = new ProcessRowListControl(form, process, rows.Values.ToList());
control.Updater.RefreshStarted += (sender, args) =>
{
form.Text = "LOADING...";
};
control.Updater.RefreshFinished += (sender, args) =>
{
form.Text = "Process output: " + process.Name;
};
control.Updater.RefreshStarted += (sender, args) => form.Text = "LOADING...";
control.Updater.RefreshFinished += (sender, args) => form.Text = "Process output: " + process.Name;

ToolTipSingleton.Remove(ListView);
form.ShowDialog();
Expand Down
2 changes: 2 additions & 0 deletions EtLast.Hosting/Host/AbstractHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ private void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArg
var formattedMessage = ex.FormatExceptionWithDetails();

if (Logger != null)
{
Logger.Write(LogEventLevel.Fatal, "unexpected error during execution: {ErrorMessage}", formattedMessage);
}
else
{
Console.WriteLine("unexpected error during execution: " + formattedMessage);
Expand Down
20 changes: 10 additions & 10 deletions EtLast.Hosting/Logging/EtlContextDevToFileLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,39 @@ public EtlContextDevToFileLogger(string folder, LogSeverity minimumLogLevel, int
var config = new LoggerConfiguration()
.WriteTo.File(new Serilog.Formatting.Compact.CompactJsonFormatter(), Path.Combine(folder, "events-.json"),
restrictedToMinimumLevel: (LogEventLevel)minimumLogLevel,
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: infoFileCount,
buffered: true,
flushToDiskInterval: TimeSpan.FromSeconds(1),
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: infoFileCount,
encoding: Encoding.UTF8)

.WriteTo.File(Path.Combine(folder, "2-info-.txt"),
outputTemplate: "{Timestamp:HH:mm:ss.fff zzz} [{Level:u3}] {Message:l} {NewLine}{Exception}",
restrictedToMinimumLevel: LogEventLevel.Information,
outputTemplate: "{Timestamp:HH:mm:ss.fff zzz} [{Level:u3}] {Message:l} {NewLine}{Exception}",
formatProvider: CultureInfo.InvariantCulture,
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: infoFileCount,
encoding: Encoding.UTF8)

.WriteTo.File(Path.Combine(folder, "3-warning-.txt"),
outputTemplate: "{Timestamp:HH:mm:ss.fff zzz} [{Level:u3}] {Message:l} {NewLine}{Exception}",
restrictedToMinimumLevel: LogEventLevel.Warning,
outputTemplate: "{Timestamp:HH:mm:ss.fff zzz} [{Level:u3}] {Message:l} {NewLine}{Exception}",
formatProvider: CultureInfo.InvariantCulture,
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: importantFileCount,
encoding: Encoding.UTF8)

.WriteTo.File(Path.Combine(folder, "4-error-.txt"),
outputTemplate: "{Timestamp:HH:mm:ss.fff zzz} [{Level:u3}] {Message:l} {NewLine}{Exception}",
restrictedToMinimumLevel: LogEventLevel.Error,
outputTemplate: "{Timestamp:HH:mm:ss.fff zzz} [{Level:u3}] {Message:l} {NewLine}{Exception}",
formatProvider: CultureInfo.InvariantCulture,
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: importantFileCount,
encoding: Encoding.UTF8)

.WriteTo.File(Path.Combine(folder, "5-fatal-.txt"),
outputTemplate: "{Timestamp:HH:mm:ss.fff zzz} [{Level:u3}] {Message:l} {NewLine}{Exception}",
restrictedToMinimumLevel: LogEventLevel.Fatal,
outputTemplate: "{Timestamp:HH:mm:ss.fff zzz} [{Level:u3}] {Message:l} {NewLine}{Exception}",
formatProvider: CultureInfo.InvariantCulture,
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: importantFileCount,
Expand All @@ -57,10 +57,10 @@ public EtlContextDevToFileLogger(string folder, LogSeverity minimumLogLevel, int
restrictedToMinimumLevel: LogEventLevel.Debug,
outputTemplate: "{Timestamp:HH:mm:ss.fff zzz} [{Level:u3}] {Message:l} {NewLine}{Exception}",
formatProvider: CultureInfo.InvariantCulture,
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: lowFileCount,
buffered: true,
flushToDiskInterval: TimeSpan.FromSeconds(1),
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: lowFileCount,
encoding: Encoding.UTF8);
}

Expand All @@ -71,10 +71,10 @@ public EtlContextDevToFileLogger(string folder, LogSeverity minimumLogLevel, int
restrictedToMinimumLevel: LogEventLevel.Verbose,
outputTemplate: "{Timestamp:HH:mm:ss.fff zzz} [{Level:u3}] {Message:l} {NewLine}{Exception}",
formatProvider: CultureInfo.InvariantCulture,
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: lowFileCount,
buffered: true,
flushToDiskInterval: TimeSpan.FromSeconds(1),
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: lowFileCount,
encoding: Encoding.UTF8);
}

Expand Down
8 changes: 4 additions & 4 deletions EtLast.Hosting/Logging/EtlContextIoToFileLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ public EtlContextIoToFileLogger(string folder, int lowFileCount = 4)
.WriteTo.File(Path.Combine(folder, "io-.tsv"),
outputTemplate: "{Timestamp:HH:mm:ss.fff zzz}\t{Message:l}{NewLine}",
formatProvider: CultureInfo.InvariantCulture,
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: lowFileCount,
buffered: true,
flushToDiskInterval: TimeSpan.FromSeconds(1),
hooks: new IoFileLifecycleHooks(),
encoding: Encoding.UTF8);
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: lowFileCount,
encoding: Encoding.UTF8,
hooks: new IoFileLifecycleHooks());

_logger = config.CreateLogger();
}
Expand Down
5 changes: 0 additions & 5 deletions EtLast/Mutators/ThrowExceptionOnRowErrorMutator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

public sealed class ThrowExceptionOnRowErrorMutator : AbstractMutator
{
protected override void StartMutator()
{
base.StartMutator();
}

protected override IEnumerable<IRow> MutateRow(IRow row, long rowInputIndex)
{
if (row.HasError())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ public override void Execute(IFlow flow)
AND CONSTRAINT_CATALOG = '{DatabaseName}'
AND CONSTRAINT_TYPE = 'PRIMARY KEY'",
})
.CustomJob("Test", job =>
{
Assert.AreEqual(0, countOfPrimaryKeys1);
})
.CustomJob("Test", job => Assert.AreEqual(0, countOfPrimaryKeys1))
.CreatePrimaryKeyConstraint(() => new CreatePrimaryKeyConstraint()
{
Name = "CreatePrimaryKey",
Expand All @@ -52,9 +49,6 @@ public override void Execute(IFlow flow)
AND CONSTRAINT_CATALOG = '{DatabaseName}'
AND CONSTRAINT_TYPE = 'PRIMARY KEY'",
})
.CustomJob("Test", job =>
{
Assert.AreEqual(1, countOfPrimaryKeys2);
});
.CustomJob("Test", job => Assert.AreEqual(1, countOfPrimaryKeys2));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ public override void Execute(IFlow flow)
ColumnName = "DateTimeValue",
WhereClause = null,
})
.CustomJob("Test", job =>
{
Assert.AreEqual(new DateTime(2022, 7, 9), result.MaxValue);
});
.CustomJob("Test", job => Assert.AreEqual(new DateTime(2022, 7, 9), result.MaxValue));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ public override void Execute(IFlow flow)
TableName = ConnectionString.Escape(nameof(GetTableRecordCountTests)),
WhereClause = null,
})
.CustomJob("Test", job =>
{
Assert.AreEqual(2, result);
});
.CustomJob("Test", job => Assert.AreEqual(2, result));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ public class AssertFail : AbstractEtlTask
{
public override void Execute(IFlow flow)
{
flow.CustomJob("StoredProcedureAdoNetDbReader", job =>
{
Assert.Fail("Expected fail from Assert TestAssertAndException");
});
flow.CustomJob("StoredProcedureAdoNetDbReader", job => Assert.Fail("Expected fail from Assert TestAssertAndException"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ public class Exception : AbstractEtlTask
public override void Execute(IFlow flow)
{
flow
.CustomJob(nameof(Exception), job =>
{
throw new System.Exception("Test Exception.");
});
.CustomJob(nameof(Exception), job => throw new System.Exception("Test Exception."));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ public static CustomJob CreateReadSqlTableAndAssertExactMatch(NamedConnectionStr
return new CustomJob()
{
Name = "ReadAndCheck" + table + "Table",
Action = job =>
{
ReadSqlTableAndAssertExactMacth(job, connectionString, table, expectedRowsList);
}
Action = job => ReadSqlTableAndAssertExactMacth(job, connectionString, table, expectedRowsList)
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ public class GetFiles : AbstractEtlTask
public override void Execute(IFlow flow)
{
flow
.CustomJob(nameof(GetFiles), job =>
{
FileNames = ["a.txt", "b.txt", "c.txt"];
});
.CustomJob(nameof(GetFiles), job => FileNames = ["a.txt", "b.txt", "c.txt"]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ public class ShowMessage : AbstractEtlTask
public override void Execute(IFlow flow)
{
flow
.CustomJob("ShowMessageJob", job =>
{
Context.Log(LogSeverity.Warning, job, Message);
});
.CustomJob("ShowMessageJob", job => Context.Log(LogSeverity.Warning, job, Message));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ public void Complex()
Process = TestData.Country(),
KeyGenerator = row => row.GenerateKey("id"),
},
MatchSelector = (row, lookup) =>
{
return lookup.GetSingleRowByKey(row.GenerateKey("countryId"));
},
MatchSelector = (row, lookup) => lookup.GetSingleRowByKey(row.GenerateKey("countryId")),
NoMatchAction = new NoMatchAction(MatchMode.Custom)
{
CustomAction = row =>
Expand Down
5 changes: 1 addition & 4 deletions Tests/EtLast.Tests.Unit/Tests/Mutators/CustomMutatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ public void RemoveRowsWithDelegate()
.ReadFrom(TestData.Person())
.CustomCode(new CustomMutator()
{
Action = row =>
{
return row.GetAs<int>("id") < 4;
}
Action = row => row.GetAs<int>("id") < 4
});

var result = TestExecuter.Execute(context, builder);
Expand Down

0 comments on commit e9c1a0b

Please sign in to comment.