lib/rubocop/comment_config.rb in rubocop-1.45.1 vs lib/rubocop/comment_config.rb in rubocop-1.46.0
- old
+ new
@@ -40,10 +40,14 @@
return true unless disabled_line_ranges
disabled_line_ranges.none? { |range| range.include?(line_number) }
end
+ def cop_opted_in?(cop)
+ opt_in_cops.include?(cop.cop_name)
+ end
+
def cop_disabled_line_ranges
@cop_disabled_line_ranges ||= analyze
end
def extra_enabled_comments
@@ -70,9 +74,22 @@
handle_switch(directive, names, extras)
end
end
extras
+ end
+
+ def opt_in_cops
+ @opt_in_cops ||= begin
+ cops = Set.new
+ each_directive do |directive|
+ next unless directive.enabled?
+ next if directive.all_cops?
+
+ cops.merge(directive.cop_names)
+ end
+ cops
+ end
end
def analyze # rubocop:todo Metrics/AbcSize
return {} if @no_directives