class RuboCop::Cop::InSpecStyle::FirstCop

TODO: Write cop description and example of bad / good code. For every `SupportedStyle` and unique configuration, there needs to be examples. Examples must have valid Ruby syntax. Do not use upticks.

@example EnforcedStyle: bar (default)

# Description of the `bar` style.

# bad
bad_bar_method

# bad
bad_bar_method(args)

# good
good_bar_method

# good
good_bar_method(args)

@example EnforcedStyle: foo

# Description of the `foo` style.

# bad
bad_foo_method

# bad
bad_foo_method(args)

# good
good_foo_method

# good
good_foo_method(args)

Constants

MSG

TODO: Implement the cop in here.

In many cases, you can use a node matcher for matching node pattern. See github.com/rubocop-hq/rubocop/blob/master/lib/rubocop/node_pattern.rb

For example

Public Instance Methods

autocorrect(node) click to toggle source
# File lib/rubocop/cop/inspecstyle/first_cop.rb, line 60
def autocorrect(node)
  ->(corrector) do
    corrector.insert_before(node.source_range, 'good_method')
    corrector.remove(node.source_range)
  end
end
on_send(node) click to toggle source
# File lib/rubocop/cop/inspecstyle/first_cop.rb, line 54
def on_send(node)
  return unless bad_method?(node)
  message = format(MSG, example_insertion: node.first.source)
  add_offense(node, message: message)
end