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

Getter/Setter methods are sometimes badly not considered as accessors

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Here is an example with a setter which returns the current object(well-known pattern):

      public Class Man {
      
           private String name; 
      
           public Man setName(String name){
                this.name = name;
                return this;
           }
      }
      

      And another exemple with a getter using the this. prefix :

      public String getName() {
          return this.name;
      }
      

      In both case, Sonar doesn't consider those methods as being some accessors

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              freddy.mallet Freddy Mallet (Inactive)
              Reporter:
              freddy.mallet Freddy Mallet (Inactive)
              Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: