class RuboCop::PendingCopsReporter
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.
Constants
- PENDING_BANNER
Attributes
Public Class Methods
Source
# 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
Private Class Methods
Source
# 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
Source
# 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
Source
# 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
Source
# File lib/rubocop/pending_cops_reporter.rb, line 48 def warn_pending_cop(cop) version = cop.metadata['VersionAdded'] || 'N/A' warn Rainbow("#{cop.name}: # new in #{version}").yellow warn Rainbow(' Enabled: true').yellow end