Skip to content

Update code quality rules #1347

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 66 commits into from
Aug 28, 2024
Merged

Update code quality rules #1347

merged 66 commits into from
Aug 28, 2024

Conversation

bart-vmware
Copy link
Member

@bart-vmware bart-vmware commented Aug 27, 2024

Description

This PR revisits code quality analysis rules. See the individual commit messages for details.

Goals

  • Run code style validation on build (enforce IDE* rules)
  • Match up IDE* rule configuration with StyleCop/Resharper
  • During development, show only helpful info/warning messages in the Error window
  • Review/fix/suppress inspections from Resharper (they never fail the build)

Implementation

  • One-time fix for a tiny set of rules, without changing their default severity
    They address specific patterns that are highly unlikely to occur while writing code, so the increased build time by turning them on isn't justifiable.
  • Rule severity for CA* analyzers
    • Change helpful rules from info to warning
    • Activate a tiny set of helpful rules
  • Rule severity for IDE* analyzers
    • If Resharper code cleanup auto-fixes them: silent (no messages, while refactoring remains available)
    • Silence noisy analyzers that usually aren't helpful, or conflict with StyleCop/Resharper
    • Otherwise: as warning (suggestion in .editorconfig is not possible, because it won't fail the release build)

Links

Closes #913, closes #916, closes #930.

Quality checklist

  • Your code complies with our Coding Style.
  • You've updated unit and/or integration tests for your change, where applicable.
  • You've updated documentation for your change, where applicable.
    If your change affects other repositories, such as Documentation, Samples and/or MainSite, add linked PRs here.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.
  • You've added required license files and/or file headers (explaining where the code came from with proper attribution), where code is copied from StackOverflow, a blog, or OSS.

  S6610: "StartsWith" and "EndsWith" overloads that take a "char" should be used instead of the ones that take a "string"
with:
  CA1865/CA1866: Use 'string.Method(char)' instead of 'string.Method(string)' for string with single char

Rationale: The CA rules cover more methods. Their refactoring suggestion is only provided when the conversion is safe.
…tionToken parameter to methods that take one
… results

Change severity from Hidden to None for IDE0058: Remove unnecessary expression value

Rationale: IDE0058 triggers for everything (producing noise in the Error List), whereas CA1806 is constrained to specific cases.
…char) instead of String.Contains(string) with single characters
@bart-vmware bart-vmware changed the title Resharper inspections Update code quality rules Aug 27, 2024
@bart-vmware
Copy link
Member Author

bart-vmware commented Aug 27, 2024

/azp run Steeltoe.All

This comment was marked as outdated.

@bart-vmware bart-vmware force-pushed the resharper-inspections branch 2 times, most recently from b5fd1b3 to a3dc658 Compare August 28, 2024 11:57
@bart-vmware bart-vmware force-pushed the resharper-inspections branch from a3dc658 to cb7c51f Compare August 28, 2024 13:39

This comment was marked as outdated.

@bart-vmware bart-vmware marked this pull request as ready for review August 28, 2024 14:59
@bart-vmware bart-vmware requested a review from TimHess August 28, 2024 15:15
Copy link
Member

@TimHess TimHess left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link

@bart-vmware bart-vmware merged commit 2b90370 into main Aug 28, 2024
22 checks passed
@bart-vmware bart-vmware deleted the resharper-inspections branch August 28, 2024 20:35
@TimHess TimHess added the ReleaseLine/4.x Identified as a feature/fix for the 4.x release line label Sep 4, 2024
@TimHess TimHess added this to the 4.0.0-m1 milestone Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ReleaseLine/4.x Identified as a feature/fix for the 4.x release line
Projects
None yet
2 participants