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[
IndentationConsistency
IndentationWidth
DotPosition
AccessModifierIndentation
IndentArray
IndentHash
MultilineOperationIndentation
SpaceAroundOperators
SpaceAroundEqualsInParameterDefault
SpaceInsideHashLiteralBraces
SpaceInsideBlockBraces
TrailingBlankLines
ExtraSpacing
SpaceBeforeComma
SpaceInsideParens
SpaceInsideStringInterpolation
SpaceBeforeBlockBraces
SpaceInsideBrackets
SpaceAfterComma
LeadingCommentSpace
MultilineMethodCallIndentation
EmptyLinesAroundClassBody
EmptyLinesAroundModuleBody
EmptyLineBetweenDefs
EmptyLinesAroundBlockBody
FirstParameterIndentation
AlignParameters
AlignArray
AlignHash
ClosingParenthesisIndentation
CommentIndentation
]
legacy_content = File.read('.rubocop.yml')
new_content = legacy_content.gsub(/Style\/(#{ layouts.join('|') })/, 'Layout/\1')
File.write('.rubocop.yml', new_content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment