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) ⇒ Rules
constructor
A new instance of Rules.
- #must_tag_or_infer? ⇒ Boolean
- #require_all_return_types_match_inferred? ⇒ Boolean
- #require_type_tags? ⇒ Boolean
- #validate_calls? ⇒ Boolean
- #validate_consts? ⇒ Boolean
- #validate_tags? ⇒ Boolean
Constructor Details
#initialize(level) ⇒ Rules
Returns a new instance of Rules.
23 24 25 26 27 28 29 30 31 |
# File 'lib/solargraph/type_checker/rules.rb', line 23 def initialize level @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)] 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
33 34 35 |
# File 'lib/solargraph/type_checker/rules.rb', line 33 def ignore_all_undefined? rank < LEVELS[:strict] end |
#must_tag_or_infer? ⇒ Boolean
49 50 51 |
# File 'lib/solargraph/type_checker/rules.rb', line 49 def must_tag_or_infer? rank > LEVELS[:typed] end |
#require_all_return_types_match_inferred? ⇒ Boolean
57 58 59 |
# File 'lib/solargraph/type_checker/rules.rb', line 57 def require_all_return_types_match_inferred? rank >= LEVELS[:alpha] end |
#require_type_tags? ⇒ Boolean
45 46 47 |
# File 'lib/solargraph/type_checker/rules.rb', line 45 def rank >= LEVELS[:strong] end |
#validate_calls? ⇒ Boolean
41 42 43 |
# File 'lib/solargraph/type_checker/rules.rb', line 41 def validate_calls? rank >= LEVELS[:strict] end |
#validate_consts? ⇒ Boolean
37 38 39 |
# File 'lib/solargraph/type_checker/rules.rb', line 37 def validate_consts? rank >= LEVELS[:strict] end |
#validate_tags? ⇒ Boolean
53 54 55 |
# File 'lib/solargraph/type_checker/rules.rb', line 53 def rank > LEVELS[:normal] end |