Sha256: be409e31a47443efb6996c00e28c13ad1456872bef52edbdc19cc331a25bfec2

Contents?: true

Size: 944 Bytes

Versions: 3

Compression:

Stored size: 944 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Lint
      # This cop actually inspects nothing, just repacks Parser's diagnostics
      # into RuboCop's offences.
      # The purpose of this cop is to support disabling Syntax offences with
      # config or inline comments by conforming to the cop framework.
      class Syntax < Cop
        def self.offences_from_diagnostics(diagnostics)
          diagnostics.map do |diagnostic|
            offence_from_diagnostic(diagnostic)
          end
        end

        def self.offence_from_diagnostic(diagnostic)
          Offence.new(
            diagnostic.level,
            diagnostic.location,
            diagnostic.message,
            cop_name
          )
        end

        def investigate(processed_source)
          processed_source.diagnostics.each do |d|
            add_offence(d.level, nil, d.location, d.message)
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubocop-0.15.0 lib/rubocop/cop/lint/syntax.rb
rubocop-0.14.1 lib/rubocop/cop/lint/syntax.rb
rubocop-0.14.0 lib/rubocop/cop/lint/syntax.rb