Skip to content

Commit 7fd90a4

Browse files
marcandrebbatsov
authored andcommitted
Avoid use of each_comment
1 parent d31b664 commit 7fd90a4

File tree

8 files changed

+8
-8
lines changed

8 files changed

+8
-8
lines changed

lib/rubocop/comment_config.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def directive_on_comment_line?(comment)
130130
def each_directive
131131
return if processed_source.comments.nil?
132132

133-
processed_source.each_comment do |comment|
133+
processed_source.comments.each do |comment|
134134
directive = directive_parts(comment)
135135
next unless directive
136136

lib/rubocop/cop/layout/comment_indentation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CommentIndentation < Cop
3939
'instead of %<correct_comment_indentation>d).'
4040

4141
def investigate(processed_source)
42-
processed_source.each_comment { |comment| check(comment) }
42+
processed_source.comments.each { |comment| check(comment) }
4343
end
4444

4545
def autocorrect(comment)

lib/rubocop/cop/layout/leading_comment_space.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class LeadingCommentSpace < Cop
5555
MSG = 'Missing space after `#`.'
5656

5757
def investigate(processed_source)
58-
processed_source.each_comment do |comment|
58+
processed_source.comments.each do |comment|
5959
next unless /\A#+[^#\s=:+-]/.match?(comment.text)
6060
next if comment.loc.line == 1 && allowed_on_first_line?(comment)
6161
next if doxygen_comment_style?(comment)

lib/rubocop/cop/migration/department_name.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class DepartmentName < Base
2020
DISABLING_COPS_CONTENT_TOKEN = %r{[A-z]+/[A-z]+|all}.freeze
2121

2222
def on_new_investigation
23-
processed_source.each_comment do |comment|
23+
processed_source.comments.each do |comment|
2424
next if comment.text !~ DISABLE_COMMENT_FORMAT
2525

2626
offset = Regexp.last_match(1).length

lib/rubocop/cop/style/ascii_comments.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class AsciiComments < Base
2121
MSG = 'Use only ascii symbols in comments.'
2222

2323
def on_new_investigation
24-
processed_source.each_comment do |comment|
24+
processed_source.comments.each do |comment|
2525
next if comment.text.ascii_only?
2626
next if only_allowed_non_ascii_chars?(comment.text)
2727

lib/rubocop/cop/style/block_comments.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class BlockComments < Base
2525
END_LENGTH = "\n=end".length
2626

2727
def on_new_investigation
28-
processed_source.each_comment do |comment|
28+
processed_source.comments.each do |comment|
2929
next unless comment.document?
3030

3131
add_offense(comment) do |corrector|

lib/rubocop/cop/style/commented_keyword.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class CommentedKeyword < Cop
3838
'`%<keyword>s` keyword.'
3939

4040
def investigate(processed_source)
41-
processed_source.each_comment do |comment|
41+
processed_source.comments.each do |comment|
4242
add_offense(comment) if offensive?(comment)
4343
end
4444
end

lib/rubocop/cop/style/inline_comment.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class InlineComment < Base
2121
MSG = 'Avoid trailing inline comments.'
2222

2323
def on_new_investigation
24-
processed_source.each_comment do |comment|
24+
processed_source.comments.each do |comment|
2525
next if comment_line?(processed_source[comment.loc.line - 1]) ||
2626
comment.text.match?(/\A# rubocop:(enable|disable)/)
2727

0 commit comments

Comments
 (0)