Created
June 26, 2020 07:11
-
-
Save davidstosik/cb0f3d712b15e231fe72ea0a8db48cd5 to your computer and use it in GitHub Desktop.
Automating the team's code style guides with RuboCop - ColonMethodDefinition
This file contains hidden or 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
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