Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save davidstosik/cb0f3d712b15e231fe72ea0a8db48cd5 to your computer and use it in GitHub Desktop.
Save davidstosik/cb0f3d712b15e231fe72ea0a8db48cd5 to your computer and use it in GitHub Desktop.
Automating the team's code style guides with RuboCop - ColonMethodDefinition
class ColonMethodDefinition < Cop
MSG = 'Do not use `::` for defining class methods.'
def on_defs(node)
return unless node.loc.operator.source == '::'
add_offense(node, location: :operator)
end
def autocorrect(node)
->(corrector) { corrector.replace(node.loc.operator, '.') }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment