Sha256: d9938da68f02d1dcc368cf6da9e619597f1fd281ecf95cb970cc0c9196cdb9cb
Contents?: true
Size: 1.21 KB
Versions: 6507
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module Style # This cop checks for trailing code after the method definition. # # @example # # bad # def some_method; do_stuff # end # # def f(x); b = foo # b[c: x] # end # # # good # def some_method # do_stuff # end # # def f(x) # b = foo # b[c: x] # end # class TrailingBodyOnMethodDefinition < Cop include Alignment include TrailingBody MSG = "Place the first line of a multi-line method definition's " \ 'body on its own line.'.freeze def on_def(node) return unless trailing_body?(node) add_offense(node, location: first_part_of(node.body)) end alias on_defs on_def def autocorrect(node) lambda do |corrector| LineBreakCorrector.correct_trailing_body( configured_width: configured_indentation_width, corrector: corrector, node: node, processed_source: processed_source ) end end end end end end
Version data entries
6,507 entries across 6,501 versions & 25 rubygems