Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Fix false positive null reference #179

Merged
merged 1 commit into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Aktabook.Bus/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Omar Boukli-Hacene. All rights reserved.

Check warning on line 1 in src/Aktabook.Bus/Program.cs

View workflow job for this annotation

GitHub Actions / Quality gate

Add or update the header of this file.
// Distributed under an MIT-style license that can be
// found in the LICENSE file.

Expand Down Expand Up @@ -29,7 +29,7 @@
using Serilog.Exceptions.EntityFrameworkCore.Destructurers;
using Serilog.Formatting.Compact;

#pragma warning disable CA1812

Check warning on line 32 in src/Aktabook.Bus/Program.cs

View workflow job for this annotation

GitHub Actions / Quality gate

Do not suppress issues.

const string bootstrapLogFileName = "Logs/aktabook-bus-bootstrap.log";

Expand All @@ -45,7 +45,7 @@
rollOnFileSizeLimit: false)
.CreateBootstrapLogger();

Log.Information("Starting host");

Check warning on line 48 in src/Aktabook.Bus/Program.cs

View workflow job for this annotation

GitHub Actions / Quality gate

Replace this string literal with a string retrieved through an instance of the 'ResourceManager' class.

try
{
Expand Down Expand Up @@ -78,7 +78,7 @@
TelemetryOptions telemetryOptions = context
.Configuration
.GetRequiredSection(nameof(TelemetryOptions))
.Get<TelemetryOptions>();
.Get<TelemetryOptions>()!;

services.AddSingleton(new ActivitySource(telemetryOptions.ServiceName));
services.AddOpenTelemetry()
Expand All @@ -100,7 +100,7 @@
OpenLibraryClientOptions openLibraryClientOptions = context
.Configuration
.GetRequiredSection(nameof(OpenLibraryClientOptions))
.Get<OpenLibraryClientOptions>();
.Get<OpenLibraryClientOptions>()!;
services.AddOpenLibraryClient(openLibraryClientOptions);
services.AddScoped<IBookInfoRequester, BookInfoRequester>();

Expand All @@ -126,7 +126,7 @@

endpointConfiguration.DefineCriticalErrorAction(async (criticalErrorContext, cancellationToken) =>
{
Log.Fatal(criticalErrorContext.Exception, "Critical error: {Error}", criticalErrorContext.Error);

Check warning on line 129 in src/Aktabook.Bus/Program.cs

View workflow job for this annotation

GitHub Actions / Quality gate

Replace this string literal with a string retrieved through an instance of the 'ResourceManager' class.

await criticalErrorContext.Stop(cancellationToken).ConfigureAwait(false);

Expand All @@ -147,8 +147,8 @@

return 0;
}
#pragma warning disable CA1031

Check warning on line 150 in src/Aktabook.Bus/Program.cs

View workflow job for this annotation

GitHub Actions / Quality gate

Do not suppress issues.
catch (Exception ex)

Check warning on line 151 in src/Aktabook.Bus/Program.cs

View workflow job for this annotation

GitHub Actions / Quality gate

Catch a list of specific exception subtype or use exception filters instead.
#pragma warning restore CA1031
{
Log.Fatal(ex, "Host terminated unexpectedly");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Omar Boukli-Hacene. All rights reserved.

Check warning on line 1 in src/Aktabook.Infrastructure.Configuration/ConfigurationManagerExtensions.cs

View workflow job for this annotation

GitHub Actions / Quality gate

Add or update the header of this file.
// Distributed under an MIT-style license that can be
// found in the LICENSE file.

Expand All @@ -16,13 +16,13 @@
{
return configuration
.GetRequiredSection(section)
.Get<SqlConnectionStringBuilder>(options => options.ErrorOnUnknownConfiguration = true);
.Get<SqlConnectionStringBuilder>(options => options.ErrorOnUnknownConfiguration = true)!;
}

public static string GetRabbitMqBusConnectionString(this IConfiguration configuration, string section)
{
return configuration
.GetRequiredSection(section)
.Get<AmqpUriBuilder>().ConnectionUri.ToString();
.Get<AmqpUriBuilder>()!.ConnectionUri.ToString();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Omar Boukli-Hacene. All rights reserved.

Check warning on line 1 in test/Aktabook.Data.Testing/Fixtures/RequesterServiceDbContextSqlServerDestructiveFixture.cs

View workflow job for this annotation

GitHub Actions / Quality gate

Add or update the header of this file.
// Distributed under an MIT-style license that can be
// found in the LICENSE file.

Expand Down Expand Up @@ -30,7 +30,7 @@
dbContext.Database.EnsureCreated();
}

#pragma warning disable S3010

Check warning on line 33 in test/Aktabook.Data.Testing/Fixtures/RequesterServiceDbContextSqlServerDestructiveFixture.cs

View workflow job for this annotation

GitHub Actions / Quality gate

Do not suppress issues.
_dbInitialized = true;
#pragma warning restore S3010
}
Expand All @@ -39,12 +39,12 @@

public RequesterServiceDbContext CreateDbContext()
{
if (_connectionString is null)

Check warning on line 42 in test/Aktabook.Data.Testing/Fixtures/RequesterServiceDbContextSqlServerDestructiveFixture.cs

View workflow job for this annotation

GitHub Actions / Quality gate

Use the '??=' operator here.
{
_connectionString = new ConfigurationFactory()
.Configuration
.GetRequiredSection(DbContextConstants.RequesterServiceDbContextSqlServerSection)
.Get<SqlConnectionStringBuilder>(options => options.ErrorOnUnknownConfiguration = true)
.Get<SqlConnectionStringBuilder>(options => options.ErrorOnUnknownConfiguration = true)!
.ConnectionString;
}

Expand Down
Loading