lib/rubocop/cop/style/copyright.rb in rubocop-0.35.1 vs lib/rubocop/cop/style/copyright.rb in rubocop-0.36.0
- old
+ new
@@ -1,6 +1,7 @@
# encoding: utf-8
+# frozen_string_literal: true
module RuboCop
module Cop
module Style
# Check that a copyright notice was given in each source file.
@@ -59,11 +60,11 @@
def notice_found?(processed_source)
notice_found = false
notice_regexp = Regexp.new(notice)
processed_source.tokens.each do |token|
break unless token.type == :tCOMMENT
- notice_found = !((token.text =~ notice_regexp).nil?)
+ notice_found = !(token.text =~ notice_regexp).nil?
break if notice_found
end
notice_found
end
@@ -73,14 +74,14 @@
regex = Regexp.new(notice)
fail Warning, "AutocorrectNotice '#{autocorrect_notice}' must " \
"match Notice /#{notice}/" unless autocorrect_notice =~ regex
lambda do |corrector|
- if token.nil?
- range = Parser::Source::Range.new('', 0, 0)
- else
- range = token.pos
- end
+ range = if token.nil?
+ Parser::Source::Range.new('', 0, 0)
+ else
+ token.pos
+ end
corrector.insert_before(range, "#{autocorrect_notice}\n")
end
end
end
end