Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Korayem/86060ae7642fa246e657380a39e34bdb to your computer and use it in GitHub Desktop.
Save Korayem/86060ae7642fa246e657380a39e34bdb to your computer and use it in GitHub Desktop.
Ruby script to migrate Rubocop settings from Style to Layout
# 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