Skip to content

Commit

Permalink
Remove (almost) redundant setting.
Browse files Browse the repository at this point in the history
Note that 'instance_methods' is not a valid category.
  • Loading branch information
marcandre authored and mergify[bot] committed Apr 1, 2021
1 parent 2d1fd7b commit 1cd90c7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 23 deletions.
13 changes: 0 additions & 13 deletions .rubocop.yml
Expand Up @@ -46,19 +46,6 @@ Layout/EndOfLine:

Layout/ClassStructure:
Enabled: true
Categories:
module_inclusion:
- include
- prepend
- extend
ExpectedOrder:
- module_inclusion
- constants
- public_class_methods
- initializer
- instance_methods
- protected_methods
- private_methods

Layout/TrailingWhitespace:
AllowInHeredoc: false
Expand Down
20 changes: 10 additions & 10 deletions lib/rubocop/cop/style/commented_keyword.rb
Expand Up @@ -43,16 +43,6 @@ class CommentedKeyword < Base
MSG = 'Do not place comments on the same line as the ' \
'`%<keyword>s` keyword.'

def on_new_investigation
processed_source.comments.each do |comment|
next unless (match = line(comment).match(/(?<keyword>\S+).*#/)) && offensive?(comment)

register_offense(comment, match[:keyword])
end
end

private

KEYWORDS = %w[begin class def end module].freeze
KEYWORD_REGEXES = KEYWORDS.map { |w| /^\s*#{w}\s/ }.freeze

Expand All @@ -64,6 +54,16 @@ def on_new_investigation
].freeze
ALLOWED_COMMENT_REGEXES = ALLOWED_COMMENTS.map { |c| /#\s*#{c}/ }.freeze

def on_new_investigation
processed_source.comments.each do |comment|
next unless (match = line(comment).match(/(?<keyword>\S+).*#/)) && offensive?(comment)

register_offense(comment, match[:keyword])
end
end

private

def register_offense(comment, matched_keyword)
add_offense(comment, message: format(MSG, keyword: matched_keyword)) do |corrector|
range = range_with_surrounding_space(range: comment.loc.expression, newlines: false)
Expand Down

0 comments on commit 1cd90c7

Please sign in to comment.