lib/rubocop/cop/base.rb in rubocop-1.12.1 vs lib/rubocop/cop/base.rb in rubocop-1.13.0
- old
+ new
@@ -185,12 +185,11 @@
# Returns true if the cop name or the cop namespace matches any of the
# given names.
def self.match?(given_names)
return false unless given_names
- given_names.include?(cop_name) ||
- given_names.include?(department.to_s)
+ given_names.include?(cop_name) || given_names.include?(department.to_s)
end
def cop_name
@cop_name ||= self.class.cop_name
end
@@ -204,17 +203,15 @@
# configuration override.
@cop_config ||= @config.for_badge(self.class.badge)
end
def config_to_allow_offenses
- Formatter::DisabledConfigFormatter
- .config_to_allow_offenses[cop_name] ||= {}
+ Formatter::DisabledConfigFormatter.config_to_allow_offenses[cop_name] ||= {}
end
def config_to_allow_offenses=(hash)
- Formatter::DisabledConfigFormatter.config_to_allow_offenses[cop_name] =
- hash
+ Formatter::DisabledConfigFormatter.config_to_allow_offenses[cop_name] = hash
end
def target_ruby_version
@config.target_ruby_version
end
@@ -229,9 +226,14 @@
!file_name_matches_any?(file, 'Exclude', false)
end
def excluded_file?(file)
!relevant_file?(file)
+ end
+
+ # There should be very limited reasons for a Cop to do it's own parsing
+ def parse(source, path = nil)
+ ProcessedSource.new(source, target_ruby_version, path)
end
### Persistence
# Override if your cop should be called repeatedly for multiple investigations