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

New Rule S2094: Classes should not be empty #6754

Merged
merged 39 commits into from Feb 21, 2023

Conversation

zsolt-kolbay-sonarsource
Copy link
Contributor

@antonioaversa
Copy link
Contributor

@zsolt-kolbay-sonarsource : you may want to have a look at the failing GitHub actions checks.

I think I can start the review anyway.

@zsolt-kolbay-sonarsource zsolt-kolbay-sonarsource marked this pull request as draft February 14, 2023 10:34
Copy link
Contributor

@antonioaversa antonioaversa left a comment

Choose a reason for hiding this comment

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

Mostly tests to add and code conventions remarks.

Source generation and abstract classes without abstract methods may require further analysis.

Another general remarks is whether this rule should also consider struct and record struct. While the rule explicitly mention classes, other languages such as Java don't have the struct construct, while others, such as C++, are excluded from the rule for reasons explained in the comments.

@zsolt-kolbay-sonarsource zsolt-kolbay-sonarsource marked this pull request as ready for review February 14, 2023 18:02
Copy link
Contributor

@antonioaversa antonioaversa left a comment

Choose a reason for hiding this comment

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

LGTM, just a couple of minor remarks + the "source generators" topic, on which I let @andrei-epure-sonarsource answer.

Copy link
Contributor

@andrei-epure-sonarsource andrei-epure-sonarsource left a comment

Choose a reason for hiding this comment

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

interim comments on java IT

Copy link
Contributor

@andrei-epure-sonarsource andrei-epure-sonarsource left a comment

Choose a reason for hiding this comment

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

interim comments

Copy link
Contributor

@andrei-epure-sonarsource andrei-epure-sonarsource left a comment

Choose a reason for hiding this comment

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

interim

Copy link
Contributor

@andrei-epure-sonarsource andrei-epure-sonarsource left a comment

Choose a reason for hiding this comment

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

The build is failing, you probably need to update an UT.

All good, only one small comment left #6754 (comment)

Request changes as the PR cannot be merged as is.

Copy link
Contributor

@andrei-epure-sonarsource andrei-epure-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, but please remove the redundant safety check - I've looked into the types and it's not necessary (see #6754 (comment) )

@sonarcloud
Copy link

sonarcloud bot commented Feb 21, 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

@sonarcloud
Copy link

sonarcloud bot commented Feb 21, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

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

92.5% 92.5% Coverage
0.0% 0.0% Duplication

@andrei-epure-sonarsource andrei-epure-sonarsource merged commit be60a31 into master Feb 21, 2023
@andrei-epure-sonarsource andrei-epure-sonarsource deleted the Zsolt/S2094-empty-class branch February 21, 2023 16:21

protected override bool IsClassWithDeclaredBaseClass(SyntaxNode node) => node is ClassDeclarationSyntax { BaseList: not null };

protected override string DeclarationTypeKeyword(SyntaxNode node) => ((TypeDeclarationSyntax)node).Keyword.ValueText;
Copy link
Contributor

Choose a reason for hiding this comment

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

@zsolt-kolbay-sonarsource I was looking at coverage and noticed this new line.

According to coding style, the expression body should have been on a new line. Please fix it in any next random PR. Same above and on VB.

protected override string DeclarationTypeKeyword(SyntaxNode node) => 
    ((TypeDeclarationSyntax)node).Keyword.ValueText;

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.

New Rule S2094: Classes should not be empty
4 participants