Proposal: SA1407 configurability
See original GitHub issueWould it be possible to configure ‘aggressivity’ of SA1407 some how? It’s nice rule, but we’re not using it now because of its excessive agressivity.
Some examples where the precedence is obvious and required bracket makes only cluter:
a * b + c
a * b + c * d
a + b / c
versus
(a * b) + c
(a * b) + (c * d)
a + (b / c)
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
StyleCopAnalyzers/documentation/SA1407.md at master
An implementation of StyleCop rules using the .NET Compiler Platform - StyleCopAnalyzers/documentation/SA1407.md at master · DotNetAnalyzers/StyleCopAnalyzers.
Read more >Use StyleCop to maintain coding standards · Issue #1035
If you just plug StyleCop into the build, with no configuration at all, ... 18 - SA1407: Arithmetic expressions should declare precedence ...
Read more >Style and Consistency Rules with StyleCop
Learn how to enforce style and consistency rules to your automated tests' code. I will show you how to configure and use StyleCop...
Read more >Auto Fix StyleCop Warnings with Free Extensions - Mike Conrad
SA0001, XML comment analysis is disabled due to project configuration. SA1001, Commas should be followed by whitespace. Some, Some.
Read more >.NET Programming Standards & Reference Guide Version ...
To increase long-term maintainability of the code-base, each file should contain at most one namespace. SA1407: Arithmetic Expressions Must Declare Precedence.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It looks like this is a wontfix based on the current responses.
👎 I think the point of the rule is that a programmer doesn’t need to count on the order of precedence of operators in C#. When I did C programming, I kept a little chart on the precedence of the various operators taped to my monitor so I could figure out what was actually happening with some of the more complex C statements written by other people. With this rule in place, there is no need for a chart like that. Remember that unsafe code is almost C.
Of course, if a statement only has * and + in it, most people know the order, but I think it still makes the code more clear. I also makes it really clear what the programmer who wrote the code intended.