-
Notifications
You must be signed in to change notification settings - Fork 630
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
Add new rules related to blank lines in switch statements #1621
Merged
nicklockwood
merged 7 commits into
nicklockwood:develop
from
calda:cal--switch-statement-blank-lines
Feb 3, 2024
Merged
Add new rules related to blank lines in switch statements #1621
nicklockwood
merged 7 commits into
nicklockwood:develop
from
calda:cal--switch-statement-blank-lines
Feb 3, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b7972fb
to
03a7cc7
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## develop #1621 +/- ##
===========================================
+ Coverage 95.07% 95.15% +0.07%
===========================================
Files 20 20
Lines 22095 22319 +224
===========================================
+ Hits 21007 21237 +230
+ Misses 1088 1082 -6 ☔ View full report in Codecov by Sentry. |
nicklockwood
pushed a commit
that referenced
this pull request
Feb 3, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Feb 12, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Feb 16, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Feb 17, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Feb 25, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Feb 25, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Feb 26, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Feb 26, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Mar 2, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Mar 2, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Mar 6, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Mar 9, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Mar 9, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Mar 16, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Mar 17, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Mar 27, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Mar 28, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Mar 28, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Mar 30, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Apr 2, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Apr 6, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Apr 11, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Apr 13, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Apr 13, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Apr 13, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Apr 14, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Apr 14, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Apr 16, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Apr 20, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Apr 22, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Apr 22, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Apr 22, 2024
nicklockwood
pushed a commit
that referenced
this pull request
May 12, 2024
nicklockwood
pushed a commit
that referenced
this pull request
May 12, 2024
nicklockwood
pushed a commit
that referenced
this pull request
May 17, 2024
nicklockwood
pushed a commit
that referenced
this pull request
May 18, 2024
nicklockwood
pushed a commit
that referenced
this pull request
May 18, 2024
nicklockwood
pushed a commit
that referenced
this pull request
May 18, 2024
nicklockwood
pushed a commit
that referenced
this pull request
May 18, 2024
nicklockwood
pushed a commit
that referenced
this pull request
May 24, 2024
nicklockwood
pushed a commit
that referenced
this pull request
May 28, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Jun 1, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Jun 5, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Jun 5, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Jun 8, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Jun 9, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Jun 9, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Jun 9, 2024
nicklockwood
pushed a commit
that referenced
this pull request
Jun 9, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds two new rules related to blank lines in switch statements.
blankLineAfterMultilineSwitchCase
This rule inserts a blank line following any switch statement case that spans multiple lines:
consistentSwitchStatementSpacing
This rule ensures that the cases in a switch statement have consistent spacing. If the majority of cases have a blank line, then all cases should have a blank line. This is complimentary with the above rule, and improves cases like this:
func handle(_ action: SpaceshipAction) { switch action { case .engageWarpDrive: navigationComputer.destination = targetedDestination await warpDrive.spinUp() warpDrive.activate() case .enableArtificialGravity: artificialGravityEngine.enable(strength: .oneG) + case let .scanPlanet(planet): scanner.target = planet scanner.scanAtmosphere() scanner.scanBiosphere() scanner.scanForArtificialLife() case .handleIncomingEnergyBlast: energyShields.engage() } }
This rule also works in the other direction, and will remove unnecessary blank lines if the majority of cases don't have one:
Combined example
These two rules compliment each other and combine nicely. When both rules are enabled, they will take a complex switch statement like the one below and add a blank line after all of the cases:
while preserving the common pattern where simple switch statements don't use any blank lines: