Uploaded image for project: 'SonarJava'
  1. SonarJava
  2. SONARJAVA-3642

FP in S1874 when parent constructor is deprecated but not used

    Details

    • Type: False-Positive
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.11
    • Component/s: Rules
    • Labels:

      Description

      For some reason we're considering parent constructor as overridden, if in child class there is a constructor with the same signature. Look at this example:

      public class Foo {
      
          /**
           * @deprecated
           */
          @Deprecated
          public Foo() {
          }
      
          public Foo(String s) {
          }
      }
      
      class Bar extends Foo {
      
          public Bar() { // FP here: Don’t override a deprecated method or explicitly mark it as “@Deprecated”
              super("");
          }
      }
      

      According to JLS constructors can't be overridden, this message is wrong and disappointing cause removal of constructor Foo() won't break behaviour of constructor Bar()

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                michael.gumowski Michael Gumowski
                Reporter:
                margarita.nedzelska Margarita Nedzelska
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: