Commit ab2eb49f authored by Peter Leitzen's avatar Peter Leitzen

Configure excluded directories for Gitlab/RailsLogger cop

Avoid programmatic checks because they are slower as well.
parent ba920779
......@@ -543,3 +543,8 @@ Migration/CreateTableWithForeignKeys:
# Disable this cop for all the existing migrations
Exclude:
- !ruby/regexp /\Adb\/(?:post_)?migrate\/(?:201[0-9]\d+|20200[0-8][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9])_.+\.rb\z/
Gitlab/RailsLogger:
Exclude:
- 'spec/**/*.rb'
- 'ee/spec/**/*.rb'
......@@ -24,27 +24,11 @@ module RuboCop
(send (const nil? :Rails) :logger ... )
PATTERN
WHITELISTED_DIRECTORIES = %w[
spec
].freeze
def on_send(node)
return if in_whitelisted_directory?(node)
return unless rails_logger?(node)
add_offense(node, location: :expression)
end
def in_whitelisted_directory?(node)
path = file_path_for_node(node)
WHITELISTED_DIRECTORIES.any? do |directory|
path.start_with?(
File.join(rails_root, directory),
File.join(rails_root, 'ee', directory)
)
end
end
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment