2020-06-30 12:48:39 +02:00
|
|
|
Redundant parentheses are simply wasted keystrokes, and should be removed.
|
|
|
|
|
|
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,text]
|
2020-06-30 12:48:39 +02:00
|
|
|
----
|
|
|
|
[MyAttribute()] //Noncompliant
|
|
|
|
class MyClass
|
|
|
|
{
|
|
|
|
public int MyProperty { get; set; }
|
|
|
|
public static MyClass CreateNew(int propertyValue)
|
|
|
|
{
|
|
|
|
return new MyClass() //Noncompliant
|
|
|
|
{
|
|
|
|
MyProperty = propertyValue
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,text]
|
2020-06-30 12:48:39 +02:00
|
|
|
----
|
|
|
|
[MyAttribute]
|
|
|
|
class MyClass
|
|
|
|
{
|
|
|
|
public int MyProperty { get; set; }
|
|
|
|
public static MyClass CreateNew(int propertyValue)
|
|
|
|
{
|
|
|
|
return new MyClass
|
|
|
|
{
|
|
|
|
MyProperty = propertyValue
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
|