Enable IDE0048: AddRequiredParentheses#13936
Enable IDE0048: AddRequiredParentheses#13936xtqqczze wants to merge 3 commits intoPowerShell:masterfrom
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.
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.
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.
Multiplicative > Additive
There was a problem hiding this comment.
Multiplicative > Additive
There was a problem hiding this comment.
Multiplicative > Additive
There was a problem hiding this comment.
Multiplicative > Additive
src/Microsoft.PowerShell.Commands.Utility/commands/utility/Set-PSBreakpoint.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Multiplicative > Additive
There was a problem hiding this comment.
I'd wonder if anybody wanted parentheses in such expressions.
There was a problem hiding this comment.
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.