Skip to content

Code quality refresh #1609

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

Merged
merged 56 commits into from
Sep 21, 2024
Merged

Code quality refresh #1609

merged 56 commits into from
Sep 21, 2024

Conversation

bkoelman
Copy link
Member

@bkoelman bkoelman commented Sep 21, 2024

Refresh code analysis rulesets, to reduce noise in the IDE and enable various CA* rules.

  • Use source generators for structured logging and regular expressions.
  • Various performance improvements, though they could be micro-optimizations that are hardly noticeable.
  • Harden public members declared as a read-only collection by returning a read-only wrapper to prevent modifications from the outside.

Code coverage is slightly lower than before because:

  • The source-generated logger doesn't log when logging off. This happens in cibuild to reduce noise in the logs.
  • Optimizations were introduced that type-check to prevent copying a collection. Multiple implementations in the service container are typically registered and injected via IEnumerable<>, whereas the underlying type is an array. If that ever changes, there's fallback code that copies the collection anyway. But it doesn't make sense to write tests for such fallbacks.

QUALITY CHECKLIST

- CA2254: Template should be a static expression
- CA1848: use the LoggerMessage delegates
Copy link

codecov bot commented Sep 21, 2024

Codecov Report

Attention: Patch coverage is 90.06623% with 60 lines in your changes missing coverage. Please review.

Project coverage is 90.78%. Comparing base (4404e89) to head (7061e4c).
Report is 57 commits behind head on master.

Files with missing lines Patch % Lines
...les/DapperExample/Repositories/DapperRepository.cs 30.00% 13 Missing and 1 partial ⚠️
...etCore/QueryStrings/FieldChains/MatchTraceScope.cs 12.50% 14 Missing ⚠️
...sonApiDotNetCore/Diagnostics/CascadingCodeTimer.cs 0.00% 4 Missing ⚠️
.../JsonApiDotNetCore/Middleware/JsonApiMiddleware.cs 78.94% 3 Missing and 1 partial ⚠️
src/JsonApiDotNetCore.Annotations/ArgumentGuard.cs 57.14% 1 Missing and 2 partials ⚠️
...c/JsonApiDotNetCore/Middleware/ExceptionHandler.cs 62.50% 3 Missing ⚠️
...ameworkExample/Services/InMemoryResourceService.cs 66.66% 0 Missing and 2 partials ⚠️
...onApiDotNetCore.Annotations/CollectionConverter.cs 66.66% 2 Missing ⚠️
...TranslationToSql/DataModel/BaseDataModelService.cs 66.66% 0 Missing and 1 partial ⚠️
...NetCore/Configuration/InverseNavigationResolver.cs 66.66% 0 Missing and 1 partial ⚠️
... and 12 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1609      +/-   ##
==========================================
- Coverage   90.85%   90.78%   -0.08%     
==========================================
  Files         348      349       +1     
  Lines       11189    11316     +127     
  Branches     1838     1849      +11     
==========================================
+ Hits        10166    10273     +107     
- Misses        672      681       +9     
- Partials      351      362      +11     

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

@bkoelman bkoelman force-pushed the code-quality-refresh branch from 9556b44 to 7061e4c Compare September 21, 2024 13:57
@bkoelman bkoelman marked this pull request as ready for review September 21, 2024 14:23
@bkoelman bkoelman merged commit 4802639 into master Sep 21, 2024
16 checks passed
@bkoelman bkoelman deleted the code-quality-refresh branch September 21, 2024 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant