-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Enable IDE0048: AddRequiredParentheses #13936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/System.Management.Automation/engine/hostifaces/LocalConnection.cs
Outdated
Show resolved
Hide resolved
iSazonov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rule is contradictory: parentheses are good for complex expressions to eliminate errors, but no doubt they are superfluous for simple expressions where they worsen readability.
I think it is better to set "suggestion" for the rule.
|
@iSazonov Could you leave more review comments to give examples of where readability has been worsened? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Less readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For most people it is obvious that multiplication has a higher precedence than addition, so the parenthesis are probably not necessary. However while readability might not be any better, it is not really any worse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiplicative > Additive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Less readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiplicative > Additive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Less readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiplicative > Additive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Less readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiplicative > Additive
src/Microsoft.PowerShell.Commands.Utility/commands/utility/Set-PSBreakpoint.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Less readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiplicative > Additive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd wonder if anybody wanted parentheses in such expressions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiplicative > Additive
src/System.Management.Automation/FormatAndOutput/common/OutputQueue.cs
Outdated
Show resolved
Hide resolved
|
@iSazonov It seems all your examples of worsened readability are for the higher precedence of multiplicative vs additive operators. Unfortunately the analyzer does not provide configuration at this level, the closest option is |
|
This is a controversial rule that depends on context. For simple expressions, no additional parentheses are needed. For complex expressions, good formatting and descriptive names are more important. I suppose we can turn this off at all. |
OK so we use a lesser severity, |
Is there Quick fix in VS Code? If yes, I agree with "suggestion", otherwise it is better to hide. |
|
@xtqqczze I close the PR since it is controversial. I suggest these rules to "suggestion" in new PR. |
https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0047-ide0048
Follow-up to #13896, after
EnforceCodeStyleInBuildwas enabled in #13957.