Sha256: 7fcf85ad81b1479639ba9b0ea707833b89c422d47daec1f3cd72191e24966850

Contents?: true

Size: 981 Bytes

Versions: 6

Compression:

Stored size: 981 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
      # Context duck type for this atypical smell detector
      DummyContext = Struct.new(:exp, :full_name)
      # Exp duck type for this atypical smell detector
      DummyExp = Struct.new(:source)

      def self.contexts
        []
      end

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

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
reek-4.8.2 lib/reek/smell_detectors/syntax.rb
reek-4.8.1 lib/reek/smell_detectors/syntax.rb
reek-4.8.0 lib/reek/smell_detectors/syntax.rb
reek-4.7.3 lib/reek/smell_detectors/syntax.rb
reek-4.7.2 lib/reek/smell_detectors/syntax.rb
reek-4.7.1 lib/reek/smell_detectors/syntax.rb