Skip to content

Issue/736 add more warnings as errors#11

Merged
MartinHock merged 23 commits into
mainfrom
issue/736-add-more-warnings-as-errors
Jun 9, 2026
Merged

Issue/736 add more warnings as errors#11
MartinHock merged 23 commits into
mainfrom
issue/736-add-more-warnings-as-errors

Conversation

@MartinHock

@MartinHock MartinHock commented Jun 8, 2026

Copy link
Copy Markdown
Owner

reduced warnings

Summary by CodeRabbit

  • Chores

    • Standardized editor and build settings, added test run configuration, and updated git ignores.
    • Adjusted analysis and logging configuration for consistent formatting and diagnostics.
    • Added solution entries for repo config files.
  • Refactor

    • Renamed and modernized several constants, types, and parameter names for consistency.
    • Improved logging templates and made some types more restrictive.
  • Tests

    • Improved test infrastructure, parallel execution settings, and resource disposal/cleanup.

MartinHock added 22 commits June 8, 2026 16:30
- Set latest analysis level and adjust warning settings in Directory.Build.props
- Add Scalar API reference and improve exception handling in MiddlewareConfig
- Standardize cancellation token usage in endpoints
- Pass cancellation token to Task.Delay in NoOpMediator
Changed DisposeAsync in CustomWebApplicationFactory from new to override, added call to base.DisposeAsync, and suppressed finalization to ensure proper resource disposal and .NET best practices.
Ensure all int-to-string conversions for routes and logging use CultureInfo.InvariantCulture for consistent, culture-agnostic output across LoggerConfigs and contributor request files. This improves reliability in globalized scenarios.
Changed Constants to static and renamed fields to PascalCase.
Updated all usages to match new names across queries, endpoints,
DTOs, and validation to align with .NET standards.
Changed structured logging placeholders from lowercase to PascalCase across multiple files to improve consistency and align with .NET logging conventions.
Renamed constants to PascalCase for .NET convention compliance, updated all references, and removed an unused FastEndpoints using directive.
Changed entity filtering to use DomainEvents.Count != 0 instead of DomainEvents.Any() when dispatching events. This is a minor refactor with no functional impact.
- Use PascalCase {ContributorId} in logging for consistency
- Refactor BaseEfRepoTestFixture: private readonly _dbContext, add protected DbContext property
- Implement IDisposable and IAsyncDisposable for proper DbContext disposal
- Update EfRepositoryUpdate to use new DbContext property
CA1014 (CLS compliance) is now disabled by setting its severity to none, clarifying that CLS compliance is not required for this application or template repository.
Expanded and reorganized .editorconfig for C#/VB conventions and .NET rules. Updated .gitignore for SonarQube and VS artifacts. Modified Clean.Architecture.slnx to include .gitignore and adjust test config references. Added .runsettings for parallel xUnit test execution.
.editorconfig updated to suppress CA1014 and CA1707, and set CA1848 as a suggestion. Refactored DeleteContributorService to use a static LoggerMessage.Define delegate for contributor deletion logs, replacing direct LogInformation calls. No functional changes made.
The PhoneNumber property in CreateContributorRequest is now a nullable string without an explicit default value assignment. This simplifies the property declaration.
Updated DeleteContributorService summary and remarks to explain logging approach. Method now returns Result.Success() after deletion and event publication.
Update GetContributorQuery and related files to use the new Clean.Architecture.UseCases.Contributors.GetContributor namespace. Adjust using directives and references in handler and endpoint files for consistency.
Renamed ct to cancellationToken in UpdateContributorHandler for clarity and consistency. Changed NoOpMediator.CreateStream to a static method.
.editorconfig updated to disable CA1848 and CA1873 rules and clarify LoggerMessage usage is not enforced. Solution file now includes .editorconfig in /src/ to apply coding conventions and analyzer settings to all source projects.
Seal VogenEfCoreConverters class for stricter encapsulation

Changed VogenEfCoreConverters from internal partial to internal sealed partial, preventing inheritance and enforcing stricter encapsulation.
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9502f7b1-431f-4169-aaee-dd6ec4d23579

📥 Commits

Reviewing files that changed from the base of the PR and between 037a81d and 9857a3f.

📒 Files selected for processing (1)
  • tests/Clean.Architecture.AspireTests/Clean.Architecture.AspireTests.csproj
✅ Files skipped from review due to trivial changes (1)
  • tests/Clean.Architecture.AspireTests/Clean.Architecture.AspireTests.csproj

📝 Walkthrough

Walkthrough

Coordinated repository-wide updates: editor and analysis settings, renamed constants and parameters to PascalCase, logging-placeholder casing, culture-invariant route/formatting, constructor/handler parameter normalization, disposal/cancellation fixes in tests and endpoints.

Changes

Naming Convention & Code Quality Improvements

Layer / File(s) Summary
Constants & Logging Placeholder Standardization
src/Clean.Architecture.UseCases/Constants.cs, src/Clean.Architecture.Infrastructure/Data/Config/DataSchemaConstants.cs, src/Clean.Architecture.Infrastructure/Data/SeedData.cs, src/Clean.Architecture.Core/ContributorAggregate/Handlers/ContributorDeletedHandler.cs, src/Clean.Architecture.Core/ContributorAggregate/Handlers/ContributorNameUpdatedEmailNotificationHandler.cs, src/Clean.Architecture.Web/Configurations/MiddlewareConfig.cs, tests/Clean.Architecture.FunctionalTests/CustomWebApplicationFactory.cs
Constants renamed to PascalCase and structured logging placeholders updated from {contributorId}/{exceptionMessage} to {ContributorId}/{ExceptionMessage}.
Email Sender Parameter Standardization
src/Clean.Architecture.Core/Interfaces/IEmailSender.cs, src/Clean.Architecture.Infrastructure/Email/FakeEmailSender.cs, src/Clean.Architecture.Infrastructure/Email/MimeKitEmailSender.cs
Interface and implementations updated to use recipientEmail/senderEmail parameter names; logging and message construction adjusted accordingly.
Handler & Service Parameter Normalization
src/Clean.Architecture.Core/Services/DeleteContributorService.cs, src/Clean.Architecture.UseCases/Contributors/Get/GetContributorHandler.cs
Constructor parameter names normalized (repository, mediator, logger); DeleteContributorService introduced a precompiled LoggerMessage delegate.

Culture-Aware Route Building & Logging

Layer / File(s) Summary
Route builders & Serilog formatting
src/Clean.Architecture.Web/Configurations/LoggerConfigs.cs, src/Clean.Architecture.Web/Contributors/Delete.DeleteContributorRequest.cs, src/Clean.Architecture.Web/Contributors/GetById.GetContributorByIdRequest.cs, src/Clean.Architecture.Web/Contributors/Update.UpdateContributorRequest.cs
Route builders use CultureInfo.InvariantCulture and Serilog console sink configured with CultureInfo.InvariantCulture for consistent formatting.

Code Quality & Sealing

Layer / File(s) Summary
Sealing and event-dispatch tweak
src/Clean.Architecture.Infrastructure/Data/Config/VogenEfCoreConverters.cs, src/Clean.Architecture.Infrastructure/Data/EventDispatcherInterceptor.cs
VogenEfCoreConverters made sealed partial; event-dispatch check changed from Any() to Count != 0.

Namespace, Import, and Minor Cleanups

Layer / File(s) Summary
Imports and namespace updates
src/Clean.Architecture.UseCases/Contributors/GetContributor/GetContributorQuery.cs, src/Clean.Architecture.Web/Contributors/GetById.cs, src/Clean.Architecture.ServiceDefaults/Extensions.cs, src/Clean.Architecture.Web/Contributors/Update.UpdateContributorValidator.cs, src/Clean.Architecture.Web/Contributors/Update.cs
Moved GetContributorQuery to GetContributor namespace; removed unused ServiceDiscovery and FastEndpoints imports; updated OpenTelemetry path checks to be case-insensitive.

Consumer-Side Updates for Renamed Constants

Layer / File(s) Summary
Handler & Validator Constant References
src/Clean.Architecture.UseCases/Contributors/List/ListContributorsHandler.cs, src/Clean.Architecture.UseCases/Contributors/List/ListContributorsQuery.cs, src/Clean.Architecture.Web/Contributors/List.cs, tests/Clean.Architecture.FunctionalTests/ApiEndpoints/ContributorList.cs
All usages updated to reference PascalCase identifiers (DefaultPageSize, MaxPageSize, DefaultNameLength, NumberOfContributors).

Cancellation & Disposal Pattern Updates

Layer / File(s) Summary
Cancellation Token Handling
src/Clean.Architecture.Web/Contributors/Create.cs, src/Clean.Architecture.UseCases/Contributors/Update/UpdateContributorHandler.cs, tests/Clean.Architecture.UnitTests/NoOpMediator.cs
Create endpoint forwards CancellationToken to mediator; Update handler parameter renamed to cancellationToken; NoOpMediator stream delay now honors cancellation.
Disposal & Test Fixture Updates
tests/Clean.Architecture.FunctionalTests/CustomWebApplicationFactory.cs, tests/Clean.Architecture.IntegrationTests/Data/BaseEfRepoTestFixture.cs, tests/Clean.Architecture.IntegrationTests/Data/EfRepositoryUpdate.cs
CustomWebApplicationFactory uses override DisposeAsync; BaseEfRepoTestFixture implements IDisposable/IAsyncDisposable with explicit disposal; tests adjusted to use protected DbContext accessor.

Build Configuration & Project Structure

Layer / File(s) Summary
Code Analysis & Diagnostic Settings
Directory.Build.props, .editorconfig, tests/.editorconfig
AnalysisLevel set to latest, AnalysisMode Recommended, CodeAnalysisTreatWarningsAsErrors disabled; added analyzer severity overrides and test editorconfig.
Test Configuration & Execution Settings
tests/.runsettings
New test run settings enable parallel execution and CPU/thread settings.
Solution & Repository Structure
Clean.Architecture.slnx, .gitignore
Solution includes editorconfig files; .gitignore now excludes .sonarqube/ working directory.

🎯 4 (Complex) | ⏱️ ~45 minutes

🐰 A rabbit nudged constants into PascalCase bright,

hopped through routes with invariant light,
logged names tidy and tests neatly spun,
the template hops forward — tidy and fun. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.71% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Issue/736 add more warnings as errors' directly reflects the main objective of the PR to reduce warnings by treating them as errors, though it is somewhat vague about whether warnings are being added as errors or fixed.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue/736-add-more-warnings-as-errors

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/Clean.Architecture.UnitTests/NoOpMediator.cs (1)

56-59: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

IStreamQuery interface path bypasses the new cancellation-aware logic.

On Lines 56-59, ISender.CreateStream<TResponse>(IStreamQuery<TResponse> ...) still returns immediately and never uses the new method on Lines 5-8. Any caller going through IMediator/ISender won’t observe the intended cancellation-aware behavior.

Suggested fix
  IAsyncEnumerable<TResponse> ISender.CreateStream<TResponse>(IStreamQuery<TResponse> query, CancellationToken cancellationToken)
  {
-    return AsyncEnumerable.Empty<TResponse>();
+    return CreateStream(query, cancellationToken).GetAwaiter().GetResult();
  }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/Clean.Architecture.UnitTests/NoOpMediator.cs` around lines 56 - 59, The
ISender.CreateStream<TResponse>(IStreamQuery<TResponse> query, CancellationToken
cancellationToken) implementation currently ignores cancellation and returns
AsyncEnumerable.Empty, bypassing the new cancellation-aware logic; update this
method to delegate to the cancellation-aware CreateStream overload instead of
returning empty: call the class's cancellation-aware
CreateStream<TResponse>(IStreamQuery<TResponse> query, CancellationToken
cancellationToken) (or the internal method introduced on lines 5-8) and pass
through the provided CancellationToken, or if the IStreamQuery<TResponse>
exposes its own CancellationToken property use that, otherwise forward
CancellationToken.None — this ensures callers via IMediator/ISender observe the
intended cancellation behavior.
🧹 Nitpick comments (3)
tests/Clean.Architecture.UnitTests/NoOpMediator.cs (1)

5-5: ⚡ Quick win

Async method name should end with Async.

On Line 5, CreateStream is async but missing the Async suffix (CreateStreamAsync), which breaks the repository’s C# naming rule.

As per coding guidelines, "Use 'Async' suffix for async methods (e.g., GetByIdAsync)".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/Clean.Architecture.UnitTests/NoOpMediator.cs` at line 5, The async
method CreateStream should be renamed to CreateStreamAsync to follow the
Async-suffix convention; update the method declaration in NoOpMediator (public
static async Task<IAsyncEnumerable<TResponse>> CreateStream<TResponse>(...)) to
CreateStreamAsync<TResponse>(...) and then update all callers, tests, and any
interface references (e.g., usages of IStreamQuery or test helpers) to call
CreateStreamAsync; ensure the method signature, generic type parameter,
CancellationToken parameter, and async behavior remain unchanged so
functionality is preserved.

Source: Coding guidelines

src/Clean.Architecture.Infrastructure/Email/FakeEmailSender.cs (1)

8-10: ⚡ Quick win

Log placeholder names should match parameter names for structured logging clarity.

The log template uses {To}, {From}, and {Subject}, but the actual parameter names are recipientEmail, senderEmail, and subject. In structured logging, placeholder names become property names in the output, so they should match the source variable names for consistency and clarity.

📝 Suggested fix to align placeholders with parameter names
-  public Task SendEmailAsync(string recipientEmail, string senderEmail, string subject, string body)
-  {
-    _logger.LogInformation("Not actually sending an email to {To} from {From} with subject {Subject}", recipientEmail, senderEmail, subject);
+  public Task SendEmailAsync(string recipientEmail, string senderEmail, string subject, string body)
+  {
+    _logger.LogInformation("Not actually sending an email to {RecipientEmail} from {SenderEmail} with subject {Subject}", recipientEmail, senderEmail, subject);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Clean.Architecture.Infrastructure/Email/FakeEmailSender.cs` around lines
8 - 10, Update the structured log in FakeEmailSender.SendEmailAsync to use
placeholder names that match the method parameters: replace "{To}", "{From}",
and "{Subject}" in the _logger.LogInformation call with "{recipientEmail}",
"{senderEmail}", and "{subject}" respectively so the emitted log property names
align with the actual variables.
src/Clean.Architecture.Infrastructure/Email/MimeKitEmailSender.cs (1)

11-13: ⚡ Quick win

Log placeholder names should match parameter names for structured logging clarity.

The log template uses {To}, {From}, and {Subject}, but the actual parameter names are recipientEmail, senderEmail, and subject. For consistency with structured logging best practices and the patterns used elsewhere in this PR (e.g., DeleteContributorService, ContributorDeletedHandler), placeholder names should match the source variable names.

📝 Suggested fix to align placeholders with parameter names
-  public async Task SendEmailAsync(string recipientEmail, string senderEmail, string subject, string body)
-  {
-    _logger.LogWarning("Sending email to {To} from {From} with subject {Subject} using {Type}.", recipientEmail, senderEmail, subject, this.ToString());
+  public async Task SendEmailAsync(string recipientEmail, string senderEmail, string subject, string body)
+  {
+    _logger.LogWarning("Sending email to {RecipientEmail} from {SenderEmail} with subject {Subject} using {Type}.", recipientEmail, senderEmail, subject, this.ToString());
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Clean.Architecture.Infrastructure/Email/MimeKitEmailSender.cs` around
lines 11 - 13, In SendEmailAsync, update the structured log template so its
placeholders match the actual parameter names: use {recipientEmail},
{senderEmail} and {subject} (and keep {Type} or this.ToString() if desired)
instead of {To}, {From}, {Subject}; modify the _logger.LogWarning call in
MimeKitEmailSender.SendEmailAsync to use those parameter-aligned placeholders so
the logged properties bind correctly to recipientEmail, senderEmail and subject.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Clean.Architecture.slnx`:
- Line 16: The solution contains a solution item entry with File
Path=".editorconfig" that incorrectly references the repository root config;
update that solution item so its File Path points to the src-specific file
(change the value to "src/.editorconfig") so the solution references the src
folder's editorconfig instead of the root one, ensuring the solution wiring and
IDE view show the per-source configuration correctly.

In `@Directory.Build.props`:
- Line 8: The project currently sets the MSBuild property
CodeAnalysisTreatWarningsAsErrors to false which disables treating analyzer
diagnostics as build-breaking; change the value of the
CodeAnalysisTreatWarningsAsErrors property in Directory.Build.props to true so
analyzer warnings are treated as errors (or make it conditionally true for CI
builds if you need local leniency), ensuring analyzer findings fail the build
and restore the intended quality gate.

In `@src/Clean.Architecture.UseCases/Contributors/Get/GetContributorHandler.cs`:
- Line 10: GetContributorHandler currently takes IReadRepository<Contributor>
repository as a primary constructor parameter but uses it directly; create a
private readonly field named _repository and assign the constructor parameter to
it in the constructor (e.g., _repository = repository) and then replace direct
uses of repository (e.g., in the Handle method) with _repository to follow the
guideline of assigning primary constructor parameters to private fields for
clarity and testability.

---

Outside diff comments:
In `@tests/Clean.Architecture.UnitTests/NoOpMediator.cs`:
- Around line 56-59: The ISender.CreateStream<TResponse>(IStreamQuery<TResponse>
query, CancellationToken cancellationToken) implementation currently ignores
cancellation and returns AsyncEnumerable.Empty, bypassing the new
cancellation-aware logic; update this method to delegate to the
cancellation-aware CreateStream overload instead of returning empty: call the
class's cancellation-aware CreateStream<TResponse>(IStreamQuery<TResponse>
query, CancellationToken cancellationToken) (or the internal method introduced
on lines 5-8) and pass through the provided CancellationToken, or if the
IStreamQuery<TResponse> exposes its own CancellationToken property use that,
otherwise forward CancellationToken.None — this ensures callers via
IMediator/ISender observe the intended cancellation behavior.

---

Nitpick comments:
In `@src/Clean.Architecture.Infrastructure/Email/FakeEmailSender.cs`:
- Around line 8-10: Update the structured log in FakeEmailSender.SendEmailAsync
to use placeholder names that match the method parameters: replace "{To}",
"{From}", and "{Subject}" in the _logger.LogInformation call with
"{recipientEmail}", "{senderEmail}", and "{subject}" respectively so the emitted
log property names align with the actual variables.

In `@src/Clean.Architecture.Infrastructure/Email/MimeKitEmailSender.cs`:
- Around line 11-13: In SendEmailAsync, update the structured log template so
its placeholders match the actual parameter names: use {recipientEmail},
{senderEmail} and {subject} (and keep {Type} or this.ToString() if desired)
instead of {To}, {From}, {Subject}; modify the _logger.LogWarning call in
MimeKitEmailSender.SendEmailAsync to use those parameter-aligned placeholders so
the logged properties bind correctly to recipientEmail, senderEmail and subject.

In `@tests/Clean.Architecture.UnitTests/NoOpMediator.cs`:
- Line 5: The async method CreateStream should be renamed to CreateStreamAsync
to follow the Async-suffix convention; update the method declaration in
NoOpMediator (public static async Task<IAsyncEnumerable<TResponse>>
CreateStream<TResponse>(...)) to CreateStreamAsync<TResponse>(...) and then
update all callers, tests, and any interface references (e.g., usages of
IStreamQuery or test helpers) to call CreateStreamAsync; ensure the method
signature, generic type parameter, CancellationToken parameter, and async
behavior remain unchanged so functionality is preserved.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3780c851-e071-4ba9-9695-5930c16c4d01

📥 Commits

Reviewing files that changed from the base of the PR and between 74624fb and 037a81d.

📒 Files selected for processing (38)
  • .editorconfig
  • .gitignore
  • Clean.Architecture.slnx
  • Directory.Build.props
  • src/Clean.Architecture.Core/ContributorAggregate/Handlers/ContributorDeletedHandler.cs
  • src/Clean.Architecture.Core/ContributorAggregate/Handlers/ContributorNameUpdatedEmailNotificationHandler.cs
  • src/Clean.Architecture.Core/Interfaces/IEmailSender.cs
  • src/Clean.Architecture.Core/Services/DeleteContributorService.cs
  • src/Clean.Architecture.Infrastructure/Data/Config/DataSchemaConstants.cs
  • src/Clean.Architecture.Infrastructure/Data/Config/VogenEfCoreConverters.cs
  • src/Clean.Architecture.Infrastructure/Data/EventDispatcherInterceptor.cs
  • src/Clean.Architecture.Infrastructure/Data/SeedData.cs
  • src/Clean.Architecture.Infrastructure/Email/FakeEmailSender.cs
  • src/Clean.Architecture.Infrastructure/Email/MimeKitEmailSender.cs
  • src/Clean.Architecture.ServiceDefaults/Extensions.cs
  • src/Clean.Architecture.UseCases/Constants.cs
  • src/Clean.Architecture.UseCases/Contributors/Get/GetContributorHandler.cs
  • src/Clean.Architecture.UseCases/Contributors/GetContributor/GetContributorQuery.cs
  • src/Clean.Architecture.UseCases/Contributors/List/ListContributorsHandler.cs
  • src/Clean.Architecture.UseCases/Contributors/List/ListContributorsQuery.cs
  • src/Clean.Architecture.UseCases/Contributors/Update/UpdateContributorHandler.cs
  • src/Clean.Architecture.Web/Configurations/LoggerConfigs.cs
  • src/Clean.Architecture.Web/Configurations/MiddlewareConfig.cs
  • src/Clean.Architecture.Web/Contributors/Create.cs
  • src/Clean.Architecture.Web/Contributors/Delete.DeleteContributorRequest.cs
  • src/Clean.Architecture.Web/Contributors/GetById.GetContributorByIdRequest.cs
  • src/Clean.Architecture.Web/Contributors/GetById.cs
  • src/Clean.Architecture.Web/Contributors/List.cs
  • src/Clean.Architecture.Web/Contributors/Update.UpdateContributorRequest.cs
  • src/Clean.Architecture.Web/Contributors/Update.UpdateContributorValidator.cs
  • src/Clean.Architecture.Web/Contributors/Update.cs
  • tests/.editorconfig
  • tests/.runsettings
  • tests/Clean.Architecture.FunctionalTests/ApiEndpoints/ContributorList.cs
  • tests/Clean.Architecture.FunctionalTests/CustomWebApplicationFactory.cs
  • tests/Clean.Architecture.IntegrationTests/Data/BaseEfRepoTestFixture.cs
  • tests/Clean.Architecture.IntegrationTests/Data/EfRepositoryUpdate.cs
  • tests/Clean.Architecture.UnitTests/NoOpMediator.cs
💤 Files with no reviewable changes (1)
  • src/Clean.Architecture.Web/Contributors/Update.cs

Comment thread Clean.Architecture.slnx
<File Path="Directory.Packages.props" />
</Folder>
<Folder Name="/src/">
<File Path=".editorconfig" />

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Wrong solution item path under /src/ folder.

On Line 16, File Path=".editorconfig" points to the repository root file again, not src/.editorconfig. This breaks the intended solution wiring for src-specific config and can mislead contributors in IDE solution view.

Suggested fix
-    <File Path=".editorconfig" />
+    <File Path="src/.editorconfig" />
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<File Path=".editorconfig" />
<File Path="src/.editorconfig" />
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Clean.Architecture.slnx` at line 16, The solution contains a solution item
entry with File Path=".editorconfig" that incorrectly references the repository
root config; update that solution item so its File Path points to the
src-specific file (change the value to "src/.editorconfig") so the solution
references the src folder's editorconfig instead of the root one, ensuring the
solution wiring and IDE view show the per-source configuration correctly.

Comment thread Directory.Build.props
<AnalysisLevel>latest</AnalysisLevel>
<AnalysisMode>Recommended</AnalysisMode>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Analyzer warnings are no longer enforced as errors.

On Line 8, setting CodeAnalysisTreatWarningsAsErrors to false creates a policy gap: compiler warnings fail builds, but analyzer findings won’t. That undercuts this PR’s quality gate objective and can let new analyzer regressions merge unnoticed.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Directory.Build.props` at line 8, The project currently sets the MSBuild
property CodeAnalysisTreatWarningsAsErrors to false which disables treating
analyzer diagnostics as build-breaking; change the value of the
CodeAnalysisTreatWarningsAsErrors property in Directory.Build.props to true so
analyzer warnings are treated as errors (or make it conditionally true for CI
builds if you need local leniency), ensuring analyzer findings fail the build
and restore the intended quality gate.

/// Queries don't necessarily need to use repository methods, but they can if it's convenient
/// </summary>
public class GetContributorHandler(IReadRepository<Contributor> _repository)
public class GetContributorHandler(IReadRepository<Contributor> repository)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Assign the primary constructor parameter to a private field.

The guideline explicitly states: "Never use primary constructor parameters directly - always assign to private fields for clarity and testability." The parameter repository is used directly in line 16 without being assigned to a private field.

As per coding guidelines, use a private field with underscore prefix.

🔧 Proposed fix to add private field assignment
-public class GetContributorHandler(IReadRepository<Contributor> repository)
+public class GetContributorHandler(IReadRepository<Contributor> repository)
   : IQueryHandler<GetContributorQuery, Result<ContributorDto>>
 {
+  private readonly IReadRepository<Contributor> _repository = repository;
+
   public async ValueTask<Result<ContributorDto>> Handle(GetContributorQuery request, CancellationToken cancellationToken)
   {
     var spec = new ContributorByIdSpec(request.ContributorId);
-    var entity = await repository.FirstOrDefaultAsync(spec, cancellationToken);
+    var entity = await _repository.FirstOrDefaultAsync(spec, cancellationToken);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public class GetContributorHandler(IReadRepository<Contributor> repository)
public class GetContributorHandler(IReadRepository<Contributor> repository)
: IQueryHandler<GetContributorQuery, Result<ContributorDto>>
{
private readonly IReadRepository<Contributor> _repository = repository;
public async ValueTask<Result<ContributorDto>> Handle(GetContributorQuery request, CancellationToken cancellationToken)
{
var spec = new ContributorByIdSpec(request.ContributorId);
var entity = await _repository.FirstOrDefaultAsync(spec, cancellationToken);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Clean.Architecture.UseCases/Contributors/Get/GetContributorHandler.cs` at
line 10, GetContributorHandler currently takes IReadRepository<Contributor>
repository as a primary constructor parameter but uses it directly; create a
private readonly field named _repository and assign the constructor parameter to
it in the constructor (e.g., _repository = repository) and then replace direct
uses of repository (e.g., in the Handle method) with _repository to follow the
guideline of assigning primary constructor parameters to private fields for
clarity and testability.

Source: Coding guidelines

@MartinHock MartinHock merged commit f074048 into main Jun 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants