Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Korayem/86060ae7642fa246e657380a39e34bdb to your computer and use it in GitHub Desktop.

Select an option

Save Korayem/86060ae7642fa246e657380a39e34bdb to your computer and use it in GitHub Desktop.
Ruby script to migrate Rubocop settings from Style to Layout
# 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
ClosingParenthesisIndentation
CommentIndentation
DotPosition
EmptyLineBetweenDefs
EmptyLinesAroundBlockBody
EmptyLinesAroundClassBody
EmptyLinesAroundModuleBody
ExtraSpacing
FirstParameterIndentation
IndentArray
IndentationConsistency
IndentationWidth
IndentHash
LeadingCommentSpace
MultilineMethodCallIndentation
MultilineOperationIndentation
SpaceAfterComma
SpaceAroundEqualsInParameterDefault
SpaceAroundOperators
SpaceBeforeBlockBraces
SpaceBeforeComma
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