Uploaded image for project: 'Java'
  1. Java
  2. SONARJAVA-194

Rule: Useless parentheses around expressions should be removed to prevent any misunderstanding

    Details

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

      Description

      This ticket should lead to the depreciation of the following rules:

      • Checkstyle: UnnecessaryParenthesesCheck
      • PMD: UnnecessaryParentheses

        Activity

        Hide
        freddy.mallet Freddy Mallet added a comment -
        Show
        freddy.mallet Freddy Mallet added a comment - Implements http://jira.sonarsource.com/browse/RSPEC-1110
        Hide
        dinesh.bolkensteyn Dinesh Bolkensteyn added a comment -

        Done

        Show
        dinesh.bolkensteyn Dinesh Bolkensteyn added a comment - Done
        Hide
        dinesh.bolkensteyn Dinesh Bolkensteyn added a comment -

        4,165 violations

        Show
        dinesh.bolkensteyn Dinesh Bolkensteyn added a comment - 4,165 violations
        Hide
        fabemn OLD - Fabrice Bellingard added a comment -

        The following case is detected by PMD and should be covered:

        (new String("")).toString();
        
        Show
        fabemn OLD - Fabrice Bellingard added a comment - The following case is detected by PMD and should be covered: ( new String ("")).toString();
        Hide
        dinesh.bolkensteyn Dinesh Bolkensteyn added a comment -

        As discussed, some might want to have parenthesis for that use case for clarity, whereas the goal of this rule is really to find only totally useless ones.

        Another rule could cover all these 'redundant' or 'extra' parenthesis, but I would not say that they are totally 'useless'.

        Show
        dinesh.bolkensteyn Dinesh Bolkensteyn added a comment - As discussed, some might want to have parenthesis for that use case for clarity, whereas the goal of this rule is really to find only totally useless ones. Another rule could cover all these 'redundant' or 'extra' parenthesis, but I would not say that they are totally 'useless'.

          People

          • Assignee:
            dinesh.bolkensteyn Dinesh Bolkensteyn
            Reporter:
            freddy.mallet Freddy Mallet
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: