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

S2226 should ignore fields assigned in `init` method

    XMLWordPrintable

    Details

    • Type: False-Positive
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Rules
    • Labels:
      None

      Description

      When processing assignments in the init method, S2226 fails to identify instance variables that are referred to using the prefix this.

      public class S2226FP extends HttpServlet {
        private int first; // Compliant FP
        private long second; // Compliant
      
        @Override
        public void init() throws ServletException {
          this.first = 42;
          second = this.first * 2;
        }
      }
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            dorian.burihabwa Dorian Burihabwa
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: