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

UnnecessaryAbstractClass should report empty abstract classes #4357

Closed
severn-everett opened this issue Dec 5, 2021 · 9 comments
Closed

Comments

@severn-everett
Copy link
Contributor

The rule UnnecessaryAbstractClass will not mark an abstract class that has no member declarations (e.g. abstract class Foo) as violating the rule. However, adding brackets to the class declaration (e.g. abstract class Foo{}) will trigger the rule. Semantically, these appear to be the same declaration, so UnnecessaryAbstractClass should be refactored to trigger in both scenarios.

@BraisGabin
Copy link
Member

I checked the code of this rule and found that this exception was added on propouse. I found that it was added to fix #550. @schalkms, is there any reason for this?

@schalkms
Copy link
Member

schalkms commented Dec 9, 2021

That was a long time ago. As far as I remember, this was added due to a clash with the EmptyClass rule.

@severn-everett
Copy link
Contributor Author

Would you be able to elaborate about this? The NoEmptyClassBody rule doesn't have any specifications about whether it's an abstract class, which is what this rule would be specifically analyzing.

@schalkms
Copy link
Member

If both rules are enabled, this snippet triggers both rules resulting in 2 reports.

@severn-everett
Copy link
Contributor Author

How would this get reproduced? Running Detekt on abstract class Foo with both UnnecessaryAbstractClass and NoEmptyClassBody set to active on Detekt 1.19.0 doesn't trigger either issue.

@BraisGabin
Copy link
Member

So, green light. @severn-everett can you create a PR fixing this?

@severn-everett
Copy link
Contributor Author

Will do, after I work on another use case I discovered for PR #4353

@schalkms
Copy link
Member

This was the case back then before detekt v1.0 got released. Quite some time passed since then. ☺️

@schalkms
Copy link
Member

Closed by a9ce1e2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants