Skip to content
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

Fix S1643 FP: should not apply when strings are not aggregated #7711

Merged
merged 22 commits into from
Aug 2, 2023

Conversation

cristian-ambrosini-sonarsource
Copy link
Contributor

@cristian-ambrosini-sonarsource cristian-ambrosini-sonarsource commented Jul 31, 2023

Fixex #5521 + structure refactoring.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like a nice change. Some more improvements are possible

Copy link
Contributor

@martin-strecker-sonarsource martin-strecker-sonarsource left a comment

Choose a reason for hiding this comment

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

Consider changing the parameter names.
Also: There seem to be FPs in the ITs.

analyzers/src/SonarAnalyzer.Common/Facade/SyntaxFacade.cs Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

There seem to be FPs in the ITs

@cristian-ambrosini-sonarsource
Copy link
Contributor Author

There seem to be FPs in the ITs

Emh, while fixing those FPs I "had" to fix #5521 within the same PR.

@cristian-ambrosini-sonarsource cristian-ambrosini-sonarsource changed the title Improve S1643: rule structure refactoring Fix S1643 FP: should not apply when strings are not aggregated Aug 2, 2023
Copy link
Contributor

Choose a reason for hiding this comment

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

Wating for the equivalence comment to be resolved.

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM. You can improve coverage with something like

var i = 1 - 1 + 1;

or so.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Aug 2, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarqubecloud
Copy link

sonarqubecloud bot commented Aug 2, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@cristian-ambrosini-sonarsource cristian-ambrosini-sonarsource deleted the cristian/refactor-S1643 branch August 2, 2023 14:33
@cristian-ambrosini-sonarsource
Copy link
Contributor Author

Peach validation:

  • 81 lost issues: most of them are not related to this specific issue but to the addition of context.SemanticModel.GetSymbolInfo(assigned).Symbol is ILocalSymbol check.
    That removed issues where the string was just a field or property inside another class , of key/value of a dictionary.
    While I'm fine with those, as already discussed, I found one TN that needs to be investigated/addressed. Moreover, we lost also some string fields/properties declared outside the method. I think those are TNs as well.
    Some of them were just referencing a method parameter and those should be skipped because it may be part of some interface.

We need to take another look at this rule before the release.

@martin-strecker-sonarsource
Copy link
Contributor

I created issue #7722 with the FNs for IParameterSymbols, IFieldSymbol and IPropertySymbols.

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.

Fix S1643 FP: should not apply when strings are not aggregated
3 participants