Class: RuboCop::PendingCopsReporter
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/rubocop/pending_cops_reporter.rb |
Overview
Reports information about pending cops that are not explicitly configured.
This class is responsible for displaying warnings when new cops have been added to RuboCop but have not yet been enabled or disabled in the user’s configuration. It provides a centralized way to determine whether such warnings should be shown, based on global flags or configuration settings.
Constant Summary
-
PENDING_BANNER =
# File 'lib/rubocop/pending_cops_reporter.rb', line 12<<~BANNER The following cops were added to RuboCop, but are not configured. Please set Enabled to either `true` or `false` in your `.rubocop.yml` file. Please also note that you can opt-in to new cops by default by adding this to your config: AllCops: NewCops: enable BANNER
Class Attribute Summary
Class Method Summary
Class Attribute Details
.disable_pending_cops (rw)
[ GitHub ]# File 'lib/rubocop/pending_cops_reporter.rb', line 20
attr_accessor :disable_pending_cops, :enable_pending_cops
.enable_pending_cops (rw)
[ GitHub ]# File 'lib/rubocop/pending_cops_reporter.rb', line 20
attr_accessor :disable_pending_cops, :enable_pending_cops
Class Method Details
.pending_cops_only_qualified(pending_cops) (private)
[ GitHub ]# File 'lib/rubocop/pending_cops_reporter.rb', line 31
def pending_cops_only_qualified(pending_cops) pending_cops.select { |cop| Cop::Registry.qualified_cop?(cop.name) } end
.possible_new_cops?(config) ⇒ Boolean
(private)
# File 'lib/rubocop/pending_cops_reporter.rb', line 35
def possible_new_cops?(config) disable_pending_cops || enable_pending_cops || config.disabled_new_cops? || config.enabled_new_cops? end
.warn_if_needed(config)
[ GitHub ]# File 'lib/rubocop/pending_cops_reporter.rb', line 22
def warn_if_needed(config) return if possible_new_cops?(config) pending_cops = pending_cops_only_qualified(config.pending_cops) warn_on_pending_cops(pending_cops) unless pending_cops.empty? end
.warn_on_pending_cops(pending_cops) (private)
[ GitHub ]# File 'lib/rubocop/pending_cops_reporter.rb', line 40
def warn_on_pending_cops(pending_cops) warn Rainbow(PENDING_BANNER).yellow pending_cops.each { |cop| warn_pending_cop cop } warn Rainbow('For more information: https://docs.rubocop.org/rubocop/versioning.html').yellow end
.warn_pending_cop(cop) (private)
[ GitHub ]# File 'lib/rubocop/pending_cops_reporter.rb', line 48
def warn_pending_cop(cop) version = cop. ['VersionAdded'] || 'N/A' warn Rainbow("#{cop.name}: # new in #{version}").yellow warn Rainbow(' Enabled: true').yellow end