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 S2743 FP: Should not raise when base type is generic #9404

Merged
merged 5 commits into from
Jun 5, 2024

Conversation

pavel-mikula-sonarsource
Copy link
Contributor

Fixes #7521

Copy link

sonarcloud bot commented Jun 5, 2024

Quality Gate Passed Quality Gate passed for 'Sonar .NET Java Plugin'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

sonarcloud bot commented Jun 5, 2024

return;
}
var typeParameterNames = typeDeclaration.TypeParameterList.Parameters.Select(x => x.Identifier.ToString()).ToArray();
if (typeDeclaration.BaseList is not null && typeDeclaration.BaseList.Types.Any(x => x.Type is GenericNameSyntax genericType && HasGenericTypeArgument(genericType, typeParameterNames)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (typeDeclaration.BaseList is not null && typeDeclaration.BaseList.Types.Any(x => x.Type is GenericNameSyntax genericType && HasGenericTypeArgument(genericType, typeParameterNames)))
if (typeDeclaration.BaseList is {} baselist && baseList.Types.Any(x => x.Type is GenericNameSyntax genericType && HasGenericTypeArgument(genericType, typeParameterNames)))

I'd also move this condition into a local function and just add it as an extract condition to like 41.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll fix this in #9405 as it moves the line around anyway

Copy link
Contributor

@mary-georgiou-sonarsource mary-georgiou-sonarsource left a comment

Choose a reason for hiding this comment

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

LGTM - One comment to make the dode a bit less "bracy".

@pavel-mikula-sonarsource pavel-mikula-sonarsource merged commit 34692c1 into master Jun 5, 2024
33 checks passed
@pavel-mikula-sonarsource pavel-mikula-sonarsource deleted the Pavel/S2743-FP branch June 5, 2024 14:54
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 S2743 FP: Should not raise when base type is generic
2 participants