Question/Rule Proposal for blank line after one line if
See original GitHub issueI didn’t find any rule to check for a blank line after one line if statements that don’t use braces. I don’t want to force the use of curly braces for one line if statements to be able to enforce a blank line separation from if to if (rule 1513)
If there is no such rule, I would like to propose it, something like “Single line if statements should be followed by a blank line”
I want to avoid this type of code:
if (somevar == somevalue)
// A line of code
if (someothervar == someothervalue)
// Another line of code
and favor this:
if (somevar == somevalue)
// A line of code
if (someothervar == someothervalue)
// Another line of code
without having to do this:
if (somevar == somevalue)
{
// A line of code
}
if (someothervar == someothervalue)
{
// Another line of code
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:13 (7 by maintainers)
Top Results From Across the Web
Why will a blank line not be added if I add a "\n" before and ...
Whether an empty line appears before The number of odd numbers is depends on the terminal: on linux and OS/X, reading from the...
Read more >How to insert a blank line above another line
You can make use of the :g command. There are probably already answers here on how to use :g and there is also...
Read more >notepad - Find and replace multiple blank lines
Within notepad there is no way to use the Find and Replace and target blank lines. Consider Notepad++ and the regex search and...
Read more >Solved: How do I get rid of the blank line at the beginnin...
Solved: I've added a Table of Contents Zone macro and set the minimum heading level to 2, but a blank line still precedes...
Read more >Removing blank lines - Power Platform Community - Microsoft
When I try to remove the blank line. replace(body('Html_to_text'),variables('txtCR'),'') //txtCR is just a variable with a line break. I get this:.
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
Hey, you asked me why i dislike options in codestyle. The answer was about this, and not about your requested new rule.
Your answers appear to me as if i personally attack you in any way. This is not the case. Or at least i did not intend to do so.
Regarding breaking a build on violating sc rules. I can understand why people do this, but i never ever would work with that tool if I wouldn’t have to. Especially with legacy code.
Regarding StyleCop in the compiler: i never got the point why Microsoft did not communicate sc as their suggested codestyle. Some blogs about this mention that people there are just as stubborn as developers everywhere else. So now we get a new codestyle every second year or so from some important team at ms, and everyone feels the urge to change his style to this. 🤷♂️
Closing this bucket of discussion now.
I’m generally in favor of having an analyzer for this case, but there are a few exceptions that I believe would be important. The first two that come to mind are:
else
orelse if
to follow without a blank lineif
statements without a blank line if the child of each one either returns or throws (i.e. the behavior is equivalent to usingelse if
)