diff options
Diffstat (limited to 'rubocop/usage_data_helpers.rb')
-rw-r--r-- | rubocop/usage_data_helpers.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/rubocop/usage_data_helpers.rb b/rubocop/usage_data_helpers.rb new file mode 100644 index 00000000000..a6252594778 --- /dev/null +++ b/rubocop/usage_data_helpers.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module RuboCop + module UsageDataHelpers + def in_usage_data_file?(node) + filepath(node).end_with?('gitlab/usage_data.rb') + end + + def in_instrumentation_file?(node) + filepath(node).start_with?('lib/gitlab/usage/metrics/instrumentations') && File.extname(filepath(node)) == '.rb' + end + + private + + def filepath(node) + node.location.expression.source_buffer.name + end + end +end |