Module: RuboCop::Cop::TargetRubyVersion
- Included in:
- Layout::HeredocIndentation, Lint::CircularArgumentReference, Lint::DuplicateMatchPattern, Lint::EmptyInPattern, Lint::ErbNewArguments, Lint::ItWithoutArgumentsInBlock, Lint::NonDeterministicRequireOrder, Lint::RedundantDirGlobSort, Lint::RefinementImportMethods, Lint::SafeNavigationChain, Lint::UselessElseWithoutRescue, Naming::BlockForwarding, Security::YAMLLoad, Style::AmbiguousEndlessMethodDefinition, Style::ArgumentsForwarding, Style::ArrayIntersect, Style::BitwisePredicate, Style::CollectionCompact, Style::ComparableClamp, Style::DataInheritance, Style::Dir, Style::DirEmpty, Style::EndlessMethod, Style::FileEmpty, Style::FrozenStringLiteralComment, Style::HashExcept, Style::HashTransformKeys, Style::HashTransformValues, Style::InPatternThen, Style::MapToHash, Style::MultilineInPatternThen, Style::NestedFileDirname, Style::NumberedParameters, Style::NumberedParametersLimit, Style::ObjectThen, Style::RedundantInterpolationUnfreeze, Style::SafeNavigation, Style::SlicingWithRange, Style::SymbolArray, Style::UnpackFirst
- Defined in:
- lib/rubocop/cop/mixin/target_ruby_version.rb
Overview
Common functionality for checking target ruby version.
Instance Method Summary collapse
- #maximum_target_ruby_version(version) ⇒ Object
- #minimum_target_ruby_version(version) ⇒ Object
- #required_maximum_ruby_version ⇒ Object
- #required_minimum_ruby_version ⇒ Object
- #support_target_ruby_version?(version) ⇒ Boolean
Instance Method Details
#maximum_target_ruby_version(version) ⇒ Object
19 20 21 |
# File 'lib/rubocop/cop/mixin/target_ruby_version.rb', line 19 def maximum_target_ruby_version(version) @maximum_target_ruby_version = version end |
#minimum_target_ruby_version(version) ⇒ Object
15 16 17 |
# File 'lib/rubocop/cop/mixin/target_ruby_version.rb', line 15 def minimum_target_ruby_version(version) @minimum_target_ruby_version = version end |
#required_maximum_ruby_version ⇒ Object
11 12 13 |
# File 'lib/rubocop/cop/mixin/target_ruby_version.rb', line 11 def required_maximum_ruby_version @maximum_target_ruby_version end |
#required_minimum_ruby_version ⇒ Object
7 8 9 |
# File 'lib/rubocop/cop/mixin/target_ruby_version.rb', line 7 def required_minimum_ruby_version @minimum_target_ruby_version end |
#support_target_ruby_version?(version) ⇒ Boolean
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rubocop/cop/mixin/target_ruby_version.rb', line 23 def support_target_ruby_version?(version) # By default, no minimum or maximum versions of ruby are required # to run any cop. In order to do a simple numerical comparison of # the requested version against any requirements, we use 0 and # Infinity as the default values to indicate no minimum (0) and no # maximum (Infinity). min = required_minimum_ruby_version || 0 max = required_maximum_ruby_version || Float::INFINITY min <= version && max >= version end |