SonarQube Java
  1. SonarQube Java
  2. SONARJAVA-291

Rule: String literals should not be duplicated

    Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4
    • Component/s: Rules
    • Labels:
      None
    • Number of attachments :
      0

      Issue Links

        Activity

        Hide
        Dinesh Bolkensteyn added a comment -

        Done

        Show
        Dinesh Bolkensteyn added a comment - Done
        Hide
        Freddy Mallet added a comment -

        @Dinesh, I've updated the specification with the following addition code snippet :

        public String exceptions(){
           String message = "foo" + "foo" + "foo";     //Compliant - concatenated literals are excluded
           String[] arrays = {"==", "/", "==", "/"};         //Compliant - literals having less than 5 characters are excluded 
           return "";                                                   //Compliant - literals having less than 5 characters are excluded 
        }
        

        Indeed the goal is really to track usage of String literals which are used as keys and for which a constant should be defined.

        Show
        Freddy Mallet added a comment - @Dinesh, I've updated the specification with the following addition code snippet : public String exceptions(){ String message = "foo" + "foo" + "foo" ; //Compliant - concatenated literals are excluded String [] arrays = { "==" , "/" , "==" , "/" }; //Compliant - literals having less than 5 characters are excluded return ""; //Compliant - literals having less than 5 characters are excluded } Indeed the goal is really to track usage of String literals which are used as keys and for which a constant should be defined.
        Hide
        Dinesh Bolkensteyn added a comment -

        As discussed, I'll only implement the 5 characters length exclusion for now.
        We'll see on Dory how good/bad this will be.

        Show
        Dinesh Bolkensteyn added a comment - As discussed, I'll only implement the 5 characters length exclusion for now. We'll see on Dory how good/bad this will be.
        Hide
        Dinesh Bolkensteyn added a comment -

        Done!

        Show
        Dinesh Bolkensteyn added a comment - Done!
        Hide
        Freddy Mallet added a comment -

        Manually tested !

        Show
        Freddy Mallet added a comment - Manually tested !

          People

          • Assignee:
            Dinesh Bolkensteyn
            Reporter:
            Freddy Mallet
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: