Skip to content

SONARJAVA-5437 Hint in S1186 to add comment to explain why the method is empty #4989

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

Merged
merged 1 commit into from
May 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions rules/S1186/java/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ include::../description.adoc[]

This does not raise an issue in the following cases:

* Methods with a comment to explain why they are empty
* Non-public default (no-argument) constructors
* Public default (no-argument) constructors when there are other constructors in the class
* Empty methods in abstract classes
Expand All @@ -23,6 +24,8 @@ public abstract class Animal {

== How to fix it

To fix this issue, either make the method do something, throw an exception, or add a comment to explain why it is empty.

=== Code examples

==== Noncompliant code example
Expand Down
Loading