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 S6964 FP: Properties with default values #9348

Merged

Conversation

zsolt-kolbay-sonarsource
Copy link
Contributor

Fixes #9331

private static bool HasDefaultValue(SyntaxNode node) => node switch
{
ParameterSyntax { Default: not null } => true,
PropertyDeclarationSyntax { Initializer: not null } property => property.Parent.ParameterList() is null,

Choose a reason for hiding this comment

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

Why property.Parent.ParameterList() is null? How are property initializers not relevant if there is a primary constructor?

@@ -144,4 +146,11 @@ type switch

private static bool HasValidateNeverAttribute(ISymbol symbol) =>
symbol.HasAttribute(KnownType.Microsoft_AspNetCore_Mvc_ModelBinding_Validation_ValidateNeverAttribute);

private static bool HasDefaultValue(SyntaxNode node) => node switch

Choose a reason for hiding this comment

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

Slightly better name?

Suggested change
private static bool HasDefaultValue(SyntaxNode node) => node switch
private static bool IsInitialized(SyntaxNode node) => node switch

Copy link

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

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM

@mary-georgiou-sonarsource mary-georgiou-sonarsource removed their request for review May 29, 2024 11:28
@mary-georgiou-sonarsource
Copy link
Contributor

@zsolt-kolbay-sonarsource I removed my self since Martin already checked and approved!
I had couple of comments but Martin more or less covered them.

@mary-georgiou-sonarsource mary-georgiou-sonarsource merged commit afc06e3 into master May 29, 2024
29 checks passed
@mary-georgiou-sonarsource mary-georgiou-sonarsource deleted the Zsolt/fix-S6964-FP-default-property-value branch May 29, 2024 11:29
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 S6964 FP: Property with a default value
3 participants