Sha256: ff25cc2f7931097feb9c059278b65b103099444db9dd1ffb9eb979f16c1c2731

Contents?: true

Size: 808 Bytes

Versions: 1

Compression:

Stored size: 808 Bytes

Contents

# frozen_string_literal: true

require_relative 'base_detector'

module Reek
  module SmellDetectors
    # Check syntax errors.
    # Note: this detector is called by examiner directly unlike other detectors.
    class Syntax < BaseDetector
      DummyContext = Struct.new(:exp, :full_name).new(
        Struct.new('Exp', :source).new(nil),
        'This file')

      def self.contexts
        []
      end

      def self.smells_from_source(source)
        new.smells_from_source(source)
      end

      # :reek:FeatureEnvy
      def smells_from_source(source)
        source.diagnostics.map do |diagnostic|
          smell_warning(
            context: DummyContext,
            lines: [diagnostic.location.line],
            message: "has #{diagnostic.message}")
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reek-4.7.0 lib/reek/smell_detectors/syntax.rb