Skip to content

SA1520 consistent use of opening and closing braces on if statements#7198

Merged
Forgind merged 2 commits into
dotnet:mainfrom
elachlan:SA1520
Jan 10, 2022
Merged

SA1520 consistent use of opening and closing braces on if statements#7198
Forgind merged 2 commits into
dotnet:mainfrom
elachlan:SA1520

Conversation

@elachlan
Copy link
Copy Markdown
Contributor

@elachlan elachlan commented Jan 2, 2022

Copy link
Copy Markdown
Contributor

@sharwell sharwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Consider updating the .globalconfig to increase the severity of SA1520 to warning. Also note that you can achieve similar results using built-in code analysis rule IDE0011:

# IDE0011: Add braces
csharp_prefer_braces = when_multiline:warning
dotnet_diagnostic.IDE0011.severity = warning

@elachlan
Copy link
Copy Markdown
Contributor Author

elachlan commented Jan 3, 2022

💡 Consider updating the .globalconfig to increase the severity of SA1520 to warning. Also note that you can achieve similar results using built-in code analysis rule IDE0011:

# IDE0011: Add braces
csharp_prefer_braces = when_multiline:warning
dotnet_diagnostic.IDE0011.severity = warning

If #7192 is merged first, then we can enable the rule/s in the .globalconfig

Copy link
Copy Markdown
Contributor

@Forgind Forgind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistency is good, but having unnecessary curly braces always feels wasteful to me. Little bittersweet, but I believe others were less equivocal when we talked about it.

Comment thread src/Deprecated/Engine/Choose/GroupingCollection.cs Outdated
@Forgind Forgind merged commit cefeea2 into dotnet:main Jan 10, 2022
@elachlan elachlan deleted the SA1520 branch January 10, 2022 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants