Class: Solargraph::TypeChecker::Rules
- Inherits:
-
Object
- Object
- Solargraph::TypeChecker::Rules
- Defined in:
- lib/solargraph/type_checker/rules.rb
Overview
Definitions of type checking rules to be performed at various levels
Constant Summary collapse
- LEVELS =
{ normal: 0, typed: 1, strict: 2, strong: 3, alpha: 4 }.freeze
Instance Attribute Summary collapse
- #level ⇒ Symbol readonly
- #rank ⇒ Integer readonly
Instance Method Summary collapse
- #ignore_all_undefined? ⇒ Boolean
-
#initialize(level, overrides) ⇒ Rules
constructor
A new instance of Rules.
- #must_tag_or_infer? ⇒ Boolean
- #report_undefined? ⇒ Boolean
- #require_all_return_types_match_inferred? ⇒ Boolean
- #require_type_tags? ⇒ Boolean
- #validate_calls? ⇒ Boolean
- #validate_consts? ⇒ Boolean
-
#validate_sg_ignores? ⇒ Boolean
We keep this at strong because if you added an @ sg-ignore to address a strong-level issue, then ran at a lower level, you’d get a false positive - we don’t run stronger level checks than requested for performance reasons.
- #validate_tags? ⇒ Boolean
Constructor Details
#initialize(level, overrides) ⇒ Rules
Returns a new instance of Rules.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/solargraph/type_checker/rules.rb', line 24 def initialize level, overrides @rank = if LEVELS.key?(level) LEVELS[level] else Solargraph.logger.warn "Unrecognized TypeChecker level #{level}, assuming normal" 0 end @level = LEVELS[LEVELS.values.index(@rank)] @overrides = overrides end |
Instance Attribute Details
#level ⇒ Symbol (readonly)
17 18 19 |
# File 'lib/solargraph/type_checker/rules.rb', line 17 def level @level end |
#rank ⇒ Integer (readonly)
20 21 22 |
# File 'lib/solargraph/type_checker/rules.rb', line 20 def rank @rank end |
Instance Method Details
#ignore_all_undefined? ⇒ Boolean
35 36 37 |
# File 'lib/solargraph/type_checker/rules.rb', line 35 def ignore_all_undefined? !report_undefined? end |
#must_tag_or_infer? ⇒ Boolean
55 56 57 |
# File 'lib/solargraph/type_checker/rules.rb', line 55 def must_tag_or_infer? report?(:must_tag_or_infer, :strict) end |
#report_undefined? ⇒ Boolean
39 40 41 |
# File 'lib/solargraph/type_checker/rules.rb', line 39 def report_undefined? report?(:report_undefined, :strict) end |
#require_all_return_types_match_inferred? ⇒ Boolean
63 64 65 |
# File 'lib/solargraph/type_checker/rules.rb', line 63 def require_all_return_types_match_inferred? report?(:require_all_return_types_match_inferred, :alpha) end |
#require_type_tags? ⇒ Boolean
51 52 53 |
# File 'lib/solargraph/type_checker/rules.rb', line 51 def report?(:validate_type_tags, :strong) end |
#validate_calls? ⇒ Boolean
47 48 49 |
# File 'lib/solargraph/type_checker/rules.rb', line 47 def validate_calls? report?(:validate_calls, :strict) end |
#validate_consts? ⇒ Boolean
43 44 45 |
# File 'lib/solargraph/type_checker/rules.rb', line 43 def validate_consts? report?(:validate_consts, :strict) end |
#validate_sg_ignores? ⇒ Boolean
We keep this at strong because if you added an @ sg-ignore to address a strong-level issue, then ran at a lower level, you’d get a false positive - we don’t run stronger level checks than requested for performance reasons
71 72 73 |
# File 'lib/solargraph/type_checker/rules.rb', line 71 def validate_sg_ignores? report?(:validate_sg_ignores, :strong) end |
#validate_tags? ⇒ Boolean
59 60 61 |
# File 'lib/solargraph/type_checker/rules.rb', line 59 def report?(:validate_tags, :typed) end |