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

S2325 FP when creating non static anonymous inner class accessing members and false negative with method belonging to same hierarchy

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.12
    • Component/s: Rules
    • Labels:
      None

      Description

      static class FooBarQix {
        public void bar() {}
      
        private void foo() { //false positive
          new Plop(){
            void plop1(){
              bar();
            }
          };
        }
      }
      
      class Plop {
        Plop(){}
        void plop1(){}
      
      }
      

      False negative :

      class A {
      void foo(){
          new Plop(); // this constructor belongs to Object  so this is considered as a reference of the instance and no issue is raised.
      }
      }
      
      class Plop {} // implicit constructor belonging to Object
      
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                michael.gumowski Michael Gumowski
                Reporter:
                nicolas.peru Nicolas Peru
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: