Skip to content

Clear the SonarCloud issues open on master - #404

Merged
blehnen merged 1 commit into
masterfrom
sonar-cleanup-ns20
Sep 23, 2026
Merged

blehnen merged 1 commit into
masterfrom
sonar-cleanup-ns20

Conversation

@blehnen

@blehnen blehnen commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

Clears all 11 unresolved SonarCloud issues on master. The netstandard2.0 build (#252, #401) caused every one of them.

Fixed in code (9)

  • CA1510 ×4 in DashboardApiClient / DashboardConsumerClient: if (x == null) throw … becomes _ = x ?? throw …. ArgumentNullException.ThrowIfNull is what the rule suggests, but it doesn't exist on netstandard2.0, which Dashboard.Client targets. A throw expression compiles on every target. Checks run in the same order and throw the same exceptions as before.
  • S2925 ×5 in IntervalTimerTests / MonotonicTimeTests: Thread.Sleep becomes await Task.Delay. The wait still stands in for a busy caller or for real time passing, so the drift bound (1200ms vs ~1400ms for a drifting timer) still separates a correct timer from a broken one.

Suppressed with a justification (2)

  • S6588 on Epoch.Unix (Redis): netstandard2.0 has no DateTime.UnixEpoch. The remark on Epoch.Unix also said the field arrived in .NET 5. It has been in the framework since netstandard2.1, and the remark now says so.
  • S2094 on IsExternalInit: the compiler looks the type up by name and needs it to be empty.

These are [SuppressMessage] attributes in the source, not Won't Fix marks in SonarCloud, so a reviewer can see the reason in the code.

Verification

  • Dashboard.Client and Transport.Redis build in Release with -p:CI=true on net10.0, net8.0 and netstandard2.0, with 0 warnings.
  • Dashboard.Client.Tests: 92/92 pass.
  • The compatibility timer tests pass 14/14, repeated 6 times.

No changelog entry: nothing here changes behaviour a consumer can see.

🤖 Generated with Claude Code

Summary by Sourcery

Resolve all outstanding SonarCloud issues across the dashboard, compatibility, and Redis components.

Enhancements:

  • Clear SonarCloud findings while preserving existing runtime behavior and netstandard2.0 compatibility.

Documentation:

  • Correct the documentation describing the availability of DateTime.UnixEpoch.

Tests:

  • Replace blocking compatibility-test delays with asynchronous waits while retaining timer and monotonic-time coverage.

Chores:

  • Document justified suppressions for compatibility-required empty and Unix epoch helper types.

Summary by CodeRabbit

  • Chores

    • Updated compatibility annotations and documentation without changing existing behavior.
  • Tests

    • Replaced blocking waits with asynchronous delays in timing tests.

Null checks in Dashboard.Client use throw expressions, which work on every target including netstandard2.0, where ArgumentNullException.ThrowIfNull does not exist. The compatibility timer tests wait with Task.Delay instead of Thread.Sleep. Epoch and IsExternalInit carry justified suppressions, since netstandard2.0 has no DateTime.UnixEpoch and the compiler needs IsExternalInit to be empty.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@sourcery-ai sourcery-ai 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.

Sorry @blehnen, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 day and 9 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: blehnen/DotNetWorkQueue/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: cab20ccb-f0aa-44f6-822d-ac2000bd951c

📥 Commits

Reviewing files that changed from the base of the PR and between fcbca32 and 7f091e6.

📒 Files selected for processing (6)
  • Source/Compatibility/IsExternalInit.cs
  • Source/DotNetWorkQueue.Dashboard.Client/DashboardApiClient.cs
  • Source/DotNetWorkQueue.Dashboard.Client/DashboardConsumerClient.cs
  • Source/DotNetWorkQueue.Tests/Compatibility/IntervalTimerTests.cs
  • Source/DotNetWorkQueue.Tests/Compatibility/MonotonicTimeTests.cs
  • Source/DotNetWorkQueue.Transport.Redis/Basic/Time/Epoch.cs

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The diff adds analyzer suppressions for compatibility types, rewrites client constructor null checks, and replaces blocking sleeps with asynchronous delays in compatibility tests.

Changes

Analyzer suppressions

Layer / File(s) Summary
Compatibility type annotations
Source/Compatibility/IsExternalInit.cs, Source/DotNetWorkQueue.Transport.Redis/Basic/Time/Epoch.cs
The types receive analyzer suppressions. The epoch comment identifies netstandard2.1 as the version that introduced DateTime.UnixEpoch.

Client constructor validation

Layer / File(s) Summary
Constructor null checks
Source/DotNetWorkQueue.Dashboard.Client/DashboardApiClient.cs, Source/DotNetWorkQueue.Dashboard.Client/DashboardConsumerClient.cs
Constructors use throw expressions or null-coalescing throws for null arguments. The exception types and parameter names remain unchanged.

Asynchronous compatibility test delays

Layer / File(s) Summary
Asynchronous test delays
Source/DotNetWorkQueue.Tests/Compatibility/IntervalTimerTests.cs, Source/DotNetWorkQueue.Tests/Compatibility/MonotonicTimeTests.cs
Tests replace Thread.Sleep with await Task.Delay. Two monotonic time tests change to return Task asynchronously.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 7f091

The PR contains equivalent validation rewrites, compatibility annotations, and asynchronous test delays without an identified merge-blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 6 files. 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 accurately summarizes the pull request, which resolves or suppresses SonarCloud issues in the affected source files and tests.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

@sourcery-ai

sourcery-ai Bot commented Sep 23, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Clears all 11 unresolved SonarCloud issues by modernizing null validation and asynchronous timing tests, while adding source-level justifications for the two findings that cannot be fixed without breaking netstandard2.0 or compiler compatibility.

Flow diagram for netstandard2.0-compatible SonarCloud cleanup

flowchart LR
    A[SonarCloud findings] --> B{Can the issue be fixed without target compatibility changes?}
    B -->|Yes| C[Modernize null validation]
    B -->|Yes| D[Use await Task.Delay in timing tests]
    B -->|No| E[Add source-level SuppressMessage justification]
    C --> F[Build and tests remain compatible]
    D --> F
    E --> F
Loading

File-Level Changes

Change Details Files
Reworked null-argument validation to satisfy SonarCloud while preserving target-framework compatibility and exception behavior.
  • Replaced explicit null-check statements with null-coalescing throw expressions.
  • Kept validation order and existing exception types/messages unchanged.
Source/DotNetWorkQueue.Dashboard.Client/DashboardApiClient.cs
Source/DotNetWorkQueue.Dashboard.Client/DashboardConsumerClient.cs
Converted compatibility timing tests to asynchronous delays so they no longer trigger blocking-wait findings.
  • Replaced Thread.Sleep calls with awaited Task.Delay calls.
  • Updated affected test methods to return Task while preserving timing scenarios and assertions.
Source/DotNetWorkQueue.Tests/Compatibility/IntervalTimerTests.cs
Source/DotNetWorkQueue.Tests/Compatibility/MonotonicTimeTests.cs
Documented intentional SonarCloud suppressions for framework- and compiler-required compatibility constructs.
  • Suppressed S6588 on the Unix epoch constant because DateTime.UnixEpoch is unavailable on netstandard2.0.
  • Suppressed S2094 on IsExternalInit because the compiler requires an empty type discoverable by name.
  • Corrected documentation to state DateTime.UnixEpoch was introduced in netstandard2.1.
Source/Compatibility/IsExternalInit.cs
Source/DotNetWorkQueue.Transport.Redis/Basic/Time/Epoch.cs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@codacy-production codacy-production 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.

Pull Request Overview

The PR successfully addresses 11 SonarCloud issues, focusing on modernizing null-check patterns and improving test reliability by replacing blocking sleeps with asynchronous delays. The changes are up to standards according to Codacy analysis. The primary gap identified is the lack of unit tests to verify the newly implemented ArgumentNullException.ThrowIfNull logic in the dashboard client classes.

About this PR

  • The implementation of CA1510 (throw expressions) in DashboardApiClient and DashboardConsumerClient lacks corresponding unit tests to verify that ArgumentNullException is thrown as expected when null arguments are provided to the constructors.

Test suggestions

  • Verify that IntervalTimer accuracy and drift detection logic remains correct after switching from Thread.Sleep to Task.Delay.
  • Verify that MonotonicTime correctly measures elapsed time using asynchronous delays in tests.
  • Verify that DashboardApiClient constructor throws ArgumentNullException when options or httpClientFactory are null.
  • Verify that DashboardConsumerClient constructor throws ArgumentNullException when httpClientFactory is null.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify that DashboardApiClient constructor throws ArgumentNullException when options or httpClientFactory are null.
2. Verify that DashboardConsumerClient constructor throws ArgumentNullException when httpClientFactory is null.

TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback

@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.60%. Comparing base (7a9cb0e) to head (7f091e6).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
...etWorkQueue.Dashboard.Client/DashboardApiClient.cs 33.33% 1 Missing and 1 partial ⚠️

❌ Your patch status has failed because the patch coverage (50.00%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #404      +/-   ##
==========================================
- Coverage   90.63%   90.60%   -0.03%     
==========================================
  Files        1088     1088              
  Lines       37528    37528              
  Branches     3286     3286              
==========================================
- Hits        34014    34003      -11     
- Misses       2478     2487       +9     
- Partials     1036     1038       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@blehnen
blehnen merged commit ce8529f into master Sep 23, 2026
12 of 13 checks passed
@blehnen
blehnen deleted the sonar-cleanup-ns20 branch September 23, 2026 14:38
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.

1 participant