Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-3235

Redundant parentheses should not be used

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Remove these redundant parentheses.
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Targeted languages:
      C++, JavaScript
    • Covered Languages:
      C#
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      2min
    • Analysis Scope:
      Main Sources, Test Sources
    • ESLint:
      no-extra-parens
    • ReSharper:
      RedundantAttributeParentheses, RedundantEmptyObjectCreationArgumentList
    • Quick-fixes:
      Hide

      Remove redundant parentheses

      Show
      Remove redundant parentheses

      Description

      Redundant parentheses are simply wasted keystrokes, and should be removed.

      Noncompliant Code Example

      [MyAttribute()] //Noncompliant
      class MyClass
      {
        public int MyProperty { get; set; }
        public static MyClass CreateNew(int propertyValue)
        {
          return new MyClass() //Noncompliant
          {
            MyProperty = propertyValue
          };
        }
      }
      

      Compliant Solution

      [MyAttribute] 
      class MyClass
      {
        public int MyProperty { get; set; }
        public static MyClass CreateNew(int propertyValue)
        {
          return new MyClass 
          {
            MyProperty = propertyValue
          };
        }
      }
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            tamas.vajk Tamas Vajk (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: