Code Smell RSPEC-1186 should have exception for empty private constructor

41 views
Skip to first unread message

jko...@csas.cz

unread,
May 17, 2018, 4:18:10 AM5/17/18
to SonarLint
Hi all.
While using Sonarlint and default rules, people in my team started a discussion about RSPEC-1186 and detection of empty private constructors. 1186 marks empty constructors as bug, but for specific cases, like util class with only static methods, it's valid pattern and probably doesn't need more explanations.
Of course you can also add a comment in constructor, but seems that in this pattern it's just adding a useless content and useless content should always be omitted.

/**
 * Util class with only static methods, no instances allowed.
 */
public
final class FooBar {

   
private FooBar {
   
}

   
public static void foo() {
   
    // any code here
    }


    public static void bar() {
   
    // any code here
    }

}


pierre-yves.nicolas

unread,
May 18, 2018, 7:21:20 AM5/18/18
to SonarLint
Hi,

As you say that you're using "Sonarlint and default rules", I suppose that you use the "standalone mode" i.e. with no connection to a SonarQube server.
In that case, SonarLint uses the embedded SonarJava.
Which version of SonarLint are you using? Do you use it in Eclipse or IntelliJ?
Did you try to upgrade to the latest version of SonarLint?

Pierre-Yves

jko...@csas.cz

unread,
May 23, 2018, 6:12:51 AM5/23/18
to SonarLint
I'm sorry. The problem was using Sonarlint connected to Sonarqube server and seems that Sonar software was a bit outdated. Or there was some other problem, but after update the problem with marking empty constructors disappear.
Reply all
Reply to author
Forward
0 new messages