Skip to content

Conversation

@pavel-mikula-sonarsource
Copy link
Contributor

Fixes #4081

.Any(x => typeParameterNames.Contains(x.Identifier.Value) && context.SemanticModel.GetSymbolInfo(x).Symbol is { Kind: SymbolKind.TypeParameter });

private static bool BaseTypeHasGenericTypeArgument(TypeDeclarationSyntax typeDeclaration, string[] typeParameterNames) =>
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
typeDeclaration.BaseList is not null && typeDeclaration.BaseList.Types.Any(x => x.Type is GenericNameSyntax genericType && HasGenericTypeArgument(genericType, typeParameterNames));
typeDeclaration.BaseList is {} baselist && baseList.Types.Any(x => x.Type is GenericNameSyntax genericType && HasGenericTypeArgument(genericType, typeParameterNames));

I like this more - up to you.

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 - I'm not merging as there are 2 PRs on the same rule and might be conflicting.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 6, 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

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 6, 2024

@pavel-mikula-sonarsource pavel-mikula-sonarsource merged commit 9085bd1 into master Jun 6, 2024
@pavel-mikula-sonarsource pavel-mikula-sonarsource deleted the Pavel/S2743-FN branch June 6, 2024 09:09
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 FN: Static fields of nested class inside generic class

2 participants