Class SelfAssignment

    • Constructor Detail

      • SelfAssignment

        public SelfAssignment()
    • Method Detail

      • describeForVarDecl

        public Description describeForVarDecl​(com.sun.source.tree.VariableTree tree,
                                              VisitorState state)
      • describeForAssignment

        public Description describeForAssignment​(com.sun.source.tree.AssignmentTree assignmentTree,
                                                 VisitorState state)
        We expect that the lhs is a field and the rhs is an identifier, specifically a parameter to the method. We base our suggested fixes on this expectation.

        Case 1: If lhs is a field and rhs is an identifier, find a method parameter of the same type and similar name and suggest it as the rhs. (Guess that they have misspelled the identifier.)

        Case 2: If lhs is a field and rhs is not an identifier, find a method parameter of the same type and similar name and suggest it as the rhs.

        Case 3: If lhs is not a field and rhs is an identifier, find a class field of the same type and similar name and suggest it as the lhs.

        Case 4: Otherwise suggest deleting the assignment.