Forked from wojtha/migrate_rubocop_style_to_layout.rb
Last active
January 10, 2019 11:30
-
-
Save Korayem/86060ae7642fa246e657380a39e34bdb to your computer and use it in GitHub Desktop.
Ruby script to migrate Rubocop settings from Style to Layout
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
# source: https://gist.github.com/wojtha/f97f45a6a09f14a58e5721fb178f2d3f | |
# Fixes complains such as: | |
# .rubocop.yml: Style/IndentationConsistency has the wrong namespace - should be Layout | |
# .rubocop.yml: Style/IndentationWidth has the wrong namespace - should be Layout | |
# .rubocop.yml: Style/DotPosition has the wrong namespace - should be Layout | |
layouts = %w[ | |
AccessModifierIndentation | |
AlignArray | |
AlignHash | |
AlignParameters | |
BlockAlignment | |
CaseIndentation | |
ClosingParenthesisIndentation | |
CommentIndentation | |
DefEndAlignment | |
DotPosition | |
EmptyLineBetweenDefs | |
EmptyLinesAroundBlockBody | |
EmptyLinesAroundClassBody | |
EmptyLinesAroundModuleBody | |
EndAlignment | |
ExtraSpacing | |
ExtraSpacing | |
FirstParameterIndentation | |
IndentArray | |
IndentAssignment | |
IndentationConsistency | |
IndentationWidth | |
IndentHash | |
LeadingCommentSpace | |
MultilineArrayBraceLayout | |
MultilineAssignmentLayout | |
MultilineHashBraceLayout | |
MultilineMethodCallBraceLayout | |
MultilineMethodCallIndentation | |
MultilineMethodDefinitionBraceLayout | |
MultilineOperationIndentation | |
SpaceAfterComma | |
SpaceAroundBlockParameters | |
SpaceAroundEqualsInParameterDefault | |
SpaceAroundOperators | |
SpaceBeforeBlockBraces | |
SpaceBeforeComma | |
SpaceBeforeFirstArg | |
SpaceInLambdaLiteral | |
SpaceInsideBlockBraces | |
SpaceInsideBrackets | |
SpaceInsideHashLiteralBraces | |
SpaceInsideParens | |
SpaceInsideStringInterpolation | |
TrailingBlankLines | |
] | |
path = '.rubocop.yml' | |
legacy_content = File.read(path) | |
new_content = legacy_content.gsub(/Style\/(#{ layouts.join('|') })/, 'Layout/\1') | |
File.write(path, new_content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment