Skip to content

Commit

Permalink
Fixed analysis errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Rory Primrose committed Nov 21, 2023
1 parent 6f673f5 commit 0ac789d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions Divergic.Logging.Xunit.UnitTests/CacheLoggerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,13 @@ public void LogCachesLogMessageTest(LogLevel logLevel)
[InlineData(null)]
[InlineData("")]
[InlineData(" ")]
public void LogDoesLogsRecordWhenFormatterReturnsEmptyMessageAndExceptionIsNotNullTest(string data)
public void LogDoesLogsRecordWhenFormatterReturnsEmptyMessageAndExceptionIsNotNullTest(string? data)
{
const LogLevel logLevel = LogLevel.Error;
var eventId = Model.Create<EventId>();
var state = Guid.NewGuid().ToString();
var exception = new ArgumentNullException(Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
string Formatter(string message, Exception? error) => data;
string Formatter(string message, Exception? error) => data!;

var source = Substitute.For<ILogger>();

Expand Down Expand Up @@ -282,12 +282,12 @@ public void LogDoesLogsRecordWhenFormatterReturnsMessageAndExceptionIsNull()
[InlineData(null)]
[InlineData("")]
[InlineData(" ")]
public void LogDoesNotLogRecordWhenFormatterReturnsEmptyMessageAndExceptionIsNullTest(string data)
public void LogDoesNotLogRecordWhenFormatterReturnsEmptyMessageAndExceptionIsNullTest(string? data)
{
const LogLevel logLevel = LogLevel.Error;
var eventId = Model.Create<EventId>();
var state = Guid.NewGuid().ToString();
string Formatter(string message, Exception? error) => data;
string Formatter(string message, Exception? error) => data!;

var source = Substitute.For<ILogger>();

Expand Down
8 changes: 4 additions & 4 deletions Divergic.Logging.Xunit.UnitTests/DefaultFormatterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void FormatHidesSensitiveDataInMessage(string? sensitiveValue, string mes
[InlineData("", true)]
[InlineData(" ", true)]
[InlineData("stuff", true)]
public void FormatIncludesNewLineBetweenMessageAndException(string message, bool exceptionExists)
public void FormatIncludesNewLineBetweenMessageAndException(string? message, bool exceptionExists)
{
var config = new LoggingConfig();
var scopeLevel = 1;
Expand All @@ -93,7 +93,7 @@ public void FormatIncludesNewLineBetweenMessageAndException(string message, bool

var sut = new DefaultFormatter(config);

var actual = sut.Format(scopeLevel, categoryName, logLevel, eventId, message, exception);
var actual = sut.Format(scopeLevel, categoryName, logLevel, eventId, message!, exception);

actual.Should().NotStartWith(Environment.NewLine);
actual.Should().NotEndWith(Environment.NewLine);
Expand Down Expand Up @@ -125,7 +125,7 @@ public void FormatIncludesNewLineBetweenMessageAndException(string message, bool
[InlineData(null)]
[InlineData("")]
[InlineData(" ")]
public void FormatReturnsEmptyWhenMessageIsNullEmptyOrWhiteSpace(string message)
public void FormatReturnsEmptyWhenMessageIsNullEmptyOrWhiteSpace(string? message)
{
var config = new LoggingConfig().Set(x => x.ScopePaddingSpaces = 2);
var scopeLevel = 1;
Expand All @@ -135,7 +135,7 @@ public void FormatReturnsEmptyWhenMessageIsNullEmptyOrWhiteSpace(string message)

var sut = new DefaultFormatter(config);

var actual = sut.Format(scopeLevel, categoryName, logLevel, eventId, message, null);
var actual = sut.Format(scopeLevel, categoryName, logLevel, eventId, message!, null);

actual.Should().BeEmpty();
}
Expand Down
8 changes: 4 additions & 4 deletions Divergic.Logging.Xunit.UnitTests/ScopeScenarioTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void TestOutputWritesMessagesInContextOfScopesWithSensitiveData()
[InlineData(null)]
[InlineData("")]
[InlineData(" ")]
public void TestOutputWritesMessagesUsingScopesWithoutState(string scopeState)
public void TestOutputWritesMessagesUsingScopesWithoutState(string? scopeState)
{
Logger.LogCritical("Writing critical message");
Logger.LogDebug("Writing debug message");
Expand All @@ -80,11 +80,11 @@ public void TestOutputWritesMessagesUsingScopesWithoutState(string scopeState)
Logger.LogTrace("Writing trace message");
Logger.LogWarning("Writing warning message");

using (Logger.BeginScope((object) scopeState))
using (Logger.BeginScope((object) scopeState!))
{
Logger.LogInformation("Inside first scope");

using (Logger.BeginScope((object) scopeState))
using (Logger.BeginScope((object) scopeState!))
{
Logger.LogInformation("Inside second scope");
}
Expand Down Expand Up @@ -195,7 +195,7 @@ public async Task UsingParallelTasks()
return Task.CompletedTask;
})).ToList();

await Task.WhenAll(tasks).ConfigureAwait(false);
await Task.WhenAll(tasks);

Task StartOnDefaultScheduler(Func<Task> asyncFunc)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ public void CanDisposeMultipleTimes()
[InlineData(null)]
[InlineData("")]
[InlineData(" ")]
public void CreateLoggerThrowsExceptionWithInvalidCategoryNameTest(string categoryName)
public void CreateLoggerThrowsExceptionWithInvalidCategoryNameTest(string? categoryName)
{
var output = Substitute.For<ITestOutputHelper>();

using var sut = new TestOutputLoggerProvider(output);

// ReSharper disable once AccessToDisposedClosure
Action action = () => sut.CreateLogger(categoryName);
Action action = () => sut.CreateLogger(categoryName!);

action.Should().Throw<ArgumentException>();
}
Expand Down
6 changes: 3 additions & 3 deletions Divergic.Logging.Xunit.UnitTests/TestOutputLoggerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void LogIgnoresTestBoundaryFailure()

var task = new Task(async () =>
{
await Task.Delay(0).ConfigureAwait(false);
await Task.Delay(0);

sut.LogCritical("message2");
});
Expand Down Expand Up @@ -198,12 +198,12 @@ public void LogWritesMessageUsingSpecifiedLineFormatter()
[InlineData(null)]
[InlineData("")]
[InlineData(" ")]
public void ThrowsExceptionWhenCreatedWithInvalidCategoryNameTest(string categoryName)
public void ThrowsExceptionWhenCreatedWithInvalidCategoryNameTest(string? categoryName)
{
var output = Substitute.For<ITestOutputHelper>();

// ReSharper disable once ObjectCreationAsStatement
Action action = () => new TestOutputLogger(categoryName, output);
Action action = () => new TestOutputLogger(categoryName!, output);

action.Should().Throw<ArgumentException>();
}
Expand Down

0 comments on commit 0ac789d

Please sign in to comment.