Class: RuboCop::Cop::Sorbet::ValidSigil
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Sorbet::ValidSigil
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/sorbet/sigils/valid_sigil.rb
Overview
Checks that every Ruby file contains a valid Sorbet sigil. Adapted from: gist.github.com/clarkdave/85aca4e16f33fd52aceb6a0a29936e52
Options:
-
‘RequireSigilOnAllFiles`: make offense if the Sorbet typed is not found in the file (default: false)
-
‘SuggestedStrictness`: Sorbet strictness level suggested in offense messages (default: ’false’)
-
‘MinimumStrictness`: If set, make offense if the strictness level in the file is below this one
-
‘ExactStrictness`: If set, make offense if the strictness level in the file is different than this one
If an ‘ExactStrictness` level is specified, it will be used in offense messages and autocorrect. Otherwise, if a `MinimumStrictness` level is specified, it will be used in offense messages and autocorrect.
Direct Known Subclasses
Instance Method Summary collapse
Instance Method Details
#on_new_investigation ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rubocop/cop/sorbet/sigils/valid_sigil.rb', line 23 def on_new_investigation return if processed_source.tokens.empty? sigil = extract_sigil(processed_source) return unless check_sigil_present(sigil) strictness = extract_strictness(sigil) return unless check_strictness_not_empty(sigil, strictness) return unless check_strictness_valid(sigil, strictness) nil unless check_strictness_level(sigil, strictness) end |