Sha256: dfebb66dcf6a98651883700f49bd19b35b2ed72324d96981b62c3e6deb67fc15

Contents?: true

Size: 1.67 KB

Versions: 3

Compression:

Stored size: 1.67 KB

Contents

module Steep
  class Project
    class Options
      attr_accessor :allow_fallback_any
      attr_accessor :allow_missing_definitions
      attr_accessor :allow_unknown_constant_assignment
      attr_accessor :allow_unknown_method_calls
      attr_accessor :vendored_stdlib_path
      attr_accessor :vendored_gems_path
      attr_reader :libraries

      def initialize
        apply_default_typing_options!
        self.vendored_gems_path = nil
        self.vendored_stdlib_path = nil

        @libraries = []
      end

      def apply_default_typing_options!
        self.allow_fallback_any = true
        self.allow_missing_definitions = true
        self.allow_unknown_constant_assignment = false
        self.allow_unknown_method_calls = false
      end

      def apply_strict_typing_options!
        self.allow_fallback_any = false
        self.allow_missing_definitions = false
        self.allow_unknown_constant_assignment = false
        self.allow_unknown_method_calls = false
      end

      def apply_lenient_typing_options!
        self.allow_fallback_any = true
        self.allow_missing_definitions = true
        self.allow_unknown_constant_assignment = true
        self.allow_unknown_method_calls = true
      end

      def error_to_report?(error)
        case
        when error.is_a?(Errors::FallbackAny)
          !allow_fallback_any
        when error.is_a?(Errors::MethodDefinitionMissing)
          !allow_missing_definitions
        when error.is_a?(Errors::NoMethod)
          !allow_unknown_method_calls
        when error.is_a?(Errors::UnknownConstantAssigned)
          !allow_unknown_constant_assignment
        else
          true
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
steep-0.18.0 lib/steep/project/options.rb
steep-0.17.1 lib/steep/project/options.rb
steep-0.17.0 lib/steep/project/options.rb