Sha256: b38a79aaf68b683fb75244367228d6141fe496228c8fbd090d8de8c80dc8701f

Contents?: true

Size: 723 Bytes

Versions: 1

Compression:

Stored size: 723 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Style
      # This cop checks for trailing inline comments.
      #
      # @example
      #
      #   # good
      #   foo.each do |f|
      #     # Standalone comment
      #     f.bar
      #   end
      #
      #   # bad
      #   foo.each do |f|
      #     f.bar # Trailing inline comment
      #   end
      class InlineComment < Cop
        MSG = 'Avoid trailing inline comments.'.freeze

        def investigate(processed_source)
          processed_source.each_comment do |comment|
            next if comment_line?(processed_source[comment.loc.line - 1])
            add_offense(comment)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-0.53.0 lib/rubocop/cop/style/inline_comment.rb