lib/rubocop/cop/rspec/described_class.rb in rubocop-rspec-1.3.1 vs lib/rubocop/cop/rspec/described_class.rb in rubocop-rspec-1.4.0
- old
+ new
@@ -1,6 +1,7 @@
# encoding: utf-8
+# frozen_string_literal: true
module RuboCop
module Cop
module RSpec
# If the first argument of describe is a class, the class is exposed to
@@ -18,11 +19,11 @@
# subject { described_class.do_something }
# end
class DescribedClass < Cop
include RuboCop::RSpec::TopLevelDescribe
- MESSAGE = 'Use `described_class` instead of `%s`'
+ MESSAGE = 'Use `described_class` instead of `%s`'.freeze
def on_block(node)
method, _args, body = *node
return unless top_level_describe?(method)
@@ -45,10 +46,10 @@
return unless node.is_a? Parser::AST::Node
return if scope_change?(node) || node.type == :const
node.children.each do |child|
if child == object
- name = object.loc.expression.source
+ name = object.loc.expression.source
add_offense(child, :expression, format(MESSAGE, name))
break
end
inspect_children(child, object)
end