Sha256: d3bcdad6a4d877a3e042ed4e3649f7287bb0683c581858306f31e04999a008aa
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true module RuboCop class ConfigObsoletion # Encapsulation of a ConfigObsoletion rule for splitting a cop's # functionality into multiple new cops. # @api private class ExtractedCop < CopRule attr_reader :gem, :department def initialize(config, old_name, gem) super(config, old_name) @department, * = old_name.rpartition('/') @gem = gem end def violated? return false if gem_installed? affected_gems.any? end def rule_message msg = '%<name>s been extracted to the `%<gem>s` gem.' format(msg, name: affected_gems.size > 1 ? "`#{department}` cops have" : "`#{old_name}` has", gem: gem) end private def affected_gems return old_name unless old_name.end_with?('*') # Handle whole departments (expressed as `Department/*`) config.keys.grep(Regexp.new("^#{department}")) end def gem_installed? Lockfile.new.includes_gem?(gem) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubocop-1.6.0 | lib/rubocop/config_obsoletion/extracted_cop.rb |