typescript:S1186 should not apply to private constructors


export class KeyboardBehaviour {
  private constructor() {
  }           // <---- S1186 violation reported here

  static doStuff(): void {
    // some logic here

Private constructor has “it should not be possible to create instances of this class” meaning, which does not seem to warrant an extra comment.


  • SonarCloud
  • TypeScript

Hello @grimsa,

Welcome back, and thank you for your feedback.

I agree with you here; it doesn’t make sense to comment a private empty constructor, which is common when implementing design patterns like Singleton, among other things.

In that regard, I created this ticket to address this false positive as soon as possible by adding an exception to the rule for private constructors.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.