lib/rubocop/cop/cop.rb in rubocop-1.12.1 vs lib/rubocop/cop/cop.rb in rubocop-1.13.0
- old
+ new
@@ -16,13 +16,11 @@
# @deprecated
Correction = Struct.new(:lambda, :node, :cop) do
def call(corrector)
lambda.call(corrector)
rescue StandardError => e
- raise ErrorWithAnalyzedFileLocation.new(
- cause: e, node: node, cop: cop
- )
+ raise ErrorWithAnalyzedFileLocation.new(cause: e, node: node, cop: cop)
end
end
def add_offense(node_or_range, location: :expression, message: nil, severity: nil, &block)
@v0_argument = node_or_range
@@ -53,13 +51,11 @@
def self.joining_forces
return unless method_defined?(:join_force?)
cop = new
- Force.all.select do |force_class|
- cop.join_force?(force_class)
- end
+ Force.all.select { |force_class| cop.join_force?(force_class) }
end
# @deprecated
def corrections
# warn 'Cop#corrections is deprecated' TODO
@@ -95,16 +91,10 @@
# @deprecated Use Registry.qualified_cop_name
def self.qualified_cop_name(name, origin)
Registry.qualified_cop_name(name, origin)
end
- # @deprecated
- # Open issue if there's a valid use case to include this in Base
- def parse(source, path = nil)
- ProcessedSource.new(source, target_ruby_version, path)
- end
-
private
def begin_investigation(processed_source)
super
@offenses = @current_offenses
@@ -128,20 +118,16 @@
raise 'Your cop must inherit from Cop::Base and extend AutoCorrector'
end
return unless lambda
- suppress_clobbering do
- lambda.call(corrector)
- end
+ suppress_clobbering { lambda.call(corrector) }
end
def correction_lambda
return unless support_autocorrect?
- dedup_on_node(@v0_argument) do
- autocorrect(@v0_argument)
- end
+ dedup_on_node(@v0_argument) { autocorrect(@v0_argument) }
end
def dedup_on_node(node)
@corrected_nodes ||= {}.compare_by_identity
yield unless @corrected_nodes.key?(node)