Sha256: 3697c7aeed061d5b699c2924574171ed66f18a4232dc40105b35f73073c2797b
Contents?: true
Size: 1.65 KB
Versions: 3
Compression:
Stored size: 1.65 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module Sorbet module TargetSorbetVersion class << self def included(target) target.extend(ClassMethods) end end module ClassMethods # The version of the Sorbet static type checker required by this cop def minimum_target_sorbet_static_version(version) @minimum_target_sorbet_static_version = Gem::Version.new(version) end def support_target_sorbet_static_version?(version) @minimum_target_sorbet_static_version <= Gem::Version.new(version) end end def enabled_for_sorbet_static_version? sorbet_static_version = target_sorbet_static_version_from_bundler_lock_file return false unless sorbet_static_version self.class.support_target_sorbet_static_version?(sorbet_static_version) end def target_sorbet_static_version_from_bundler_lock_file # Do memoization with the `defined?` pattern since sorbet-static version might be `nil` if defined?(@target_sorbet_static_version_from_bundler_lock_file) @target_sorbet_static_version_from_bundler_lock_file else @target_sorbet_static_version_from_bundler_lock_file = read_sorbet_static_version_from_bundler_lock_file end end def read_sorbet_static_version_from_bundler_lock_file require "bundler" ::Bundler.locked_gems.specs.find { |spec| spec.name == "sorbet-static" }&.version rescue LoadError, Bundler::GemfileNotFound nil end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems