Remove Cop/LineBreakAfterGuardClauses in favour of RuboCop's cop
What does this MR do?
Removes Cop/LineBreakAfterGuardClauses, because RuboCop's Layout/EmptyLineAfterGuardClause checks the same thing. Both were enabled, so every missing line break after a guard clause was reported twice. rubocop-layout.yml now enables Layout/EmptyLineAfterGuardClause explicitly, because RuboCop plans to disable it by default in its next major version.
Closes #85 (closed)
Breaking change: projects must remove Cop/LineBreakAfterGuardClauses from their configuration, and remove or rename its rubocop:disable comments to Layout/EmptyLineAfterGuardClause.
How the two cops compare
-
On
gitlab-org/gitlab, with disable comments ignored: our cop found 2 offenses and RuboCop's found 3. Ours found nothing that RuboCop's missed. -
Case by case:
Case Ours RuboCop's One-line guard with return,raise,fail,nextorbreakflags flags Multi-line if … return … endguardno flags Guard followed by a line starting with end…, such asending = 1no flags raise <<~MSG if x(heredoc)flags the wrong line flags correctly return if x; fooflags, and autocorrect breaks the line before ;no throw :x if yflags no -
The only real gap is
throwguard clauses, which are rare. In the other cases where the two cops differ, RuboCop's is more accurate.
Impact: besides the breaking change above, throw … if guard clauses are no longer checked.