-
Notifications
You must be signed in to change notification settings - Fork 231
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
New Rule: ExcludeFromCodeCoverage attributes should include a justification #6593
New Rule: ExcludeFromCodeCoverage attributes should include a justification #6593
Conversation
Hi @Corniel, thank you for your contribution. I looked into the implementation, and the implementation is just exemplary. There is one problem, though. The ExcludeFromCodeCoverageAttribute.Justification property was introduced in .Net 5, while the attribute itself is available in a much more comprehensive range of frameworks:
While we could check for the presents of the As such, we will need to deactivate the rule by default (we will just don't put the rule in the default "Sonar way" profile). Do you want to create the related RSpec or do you want me to do this for you? |
I've created som RSPEC's in the past, and it turned out that the process was not designed to be used by external contributes. So, if you can create it, I'm more than happy to review and contribute on that PR. |
7e9889b
to
a31056a
Compare
@martin-strecker-sonarsource Just did a rebase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to check the presents of the Justification
property.
...ers/src/SonarAnalyzer.Common/Rules/ExcludeFromCodeCoverageAttributesNeedJustificationBase.cs
Outdated
Show resolved
Hide resolved
...tests/SonarAnalyzer.UnitTest/TestCases/ExcludeFromCodeCoverageAttributesNeedJustification.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make the "Justification" check language specific.
...ers/src/SonarAnalyzer.Common/Rules/ExcludeFromCodeCoverageAttributesNeedJustificationBase.cs
Outdated
Show resolved
Hide resolved
...ers/src/SonarAnalyzer.Common/Rules/ExcludeFromCodeCoverageAttributesNeedJustificationBase.cs
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.VisualBasic/Facade/VisualBasicSyntaxFacade.cs
Outdated
Show resolved
Hide resolved
...tests/SonarAnalyzer.UnitTest/Rules/ExcludeFromCodeCoverageAttributesNeedJustificationTest.cs
Outdated
Show resolved
Hide resolved
...SonarAnalyzer.UnitTest/TestCases/ExcludeFromCodeCoverageAttributesNeedJustification.net48.cs
Outdated
Show resolved
Hide resolved
…geAttributesNeedJustificationBase.cs Co-authored-by: Martin Strecker <103252490+martin-strecker-sonarsource@users.noreply.github.com>
…verageAttributesNeedJustificationTest.cs Co-authored-by: Martin Strecker <103252490+martin-strecker-sonarsource@users.noreply.github.com>
…deCoverageAttributesNeedJustification.net48.cs Co-authored-by: Martin Strecker <103252490+martin-strecker-sonarsource@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Some polishing and edge cases only.
...tests/SonarAnalyzer.UnitTest/TestCases/ExcludeFromCodeCoverageAttributesNeedJustification.cs
Show resolved
Hide resolved
...ers/src/SonarAnalyzer.Common/Rules/ExcludeFromCodeCoverageAttributesNeedJustificationBase.cs
Outdated
Show resolved
Hide resolved
...ers/src/SonarAnalyzer.Common/Rules/ExcludeFromCodeCoverageAttributesNeedJustificationBase.cs
Show resolved
Hide resolved
...ers/src/SonarAnalyzer.Common/Rules/ExcludeFromCodeCoverageAttributesNeedJustificationBase.cs
Outdated
Show resolved
Hide resolved
…geAttributesNeedJustificationBase.cs Co-authored-by: Martin Strecker <103252490+martin-strecker-sonarsource@users.noreply.github.com>
…github.com/Corniel/sonar-csharp into corniel/justify-exclude-from-code-coverage
…geAttributesNeedJustificationBase.cs Co-authored-by: Martin Strecker <103252490+martin-strecker-sonarsource@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment needs to be moved.
...ers/src/SonarAnalyzer.Common/Rules/ExcludeFromCodeCoverageAttributesNeedJustificationBase.cs
Outdated
Show resolved
Hide resolved
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
…github.com/Corniel/sonar-csharp into corniel/justify-exclude-from-code-coverage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment should be on HasJustificationProperty
...ers/src/SonarAnalyzer.Common/Rules/ExcludeFromCodeCoverageAttributesNeedJustificationBase.cs
Outdated
Show resolved
Hide resolved
...ers/src/SonarAnalyzer.Common/Rules/ExcludeFromCodeCoverageAttributesNeedJustificationBase.cs
Show resolved
Hide resolved
Hi @Corniel, to finish the PR, we will need to import the RSpec into this PR. Can you run the Rspec script like so: See also the readme in the spec directory for details. Please let me know if you have trouble running the script. I can do this for you too. |
I have no access to |
…geAttributesNeedJustificationBase.cs Co-authored-by: Martin Strecker <103252490+martin-strecker-sonarsource@users.noreply.github.com>
…geAttributesNeedJustificationBase.cs Co-authored-by: Martin Strecker <103252490+martin-strecker-sonarsource@users.noreply.github.com>
@Corniel thanks for trying. I've run the script and pushed the changes (don't forget to pull the changes). I will run the pipeline now. |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Kudos, SonarCloud Quality Gate passed! |
Kudos, SonarCloud Quality Gate passed! |
Fixes #6885