Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'rubocop/usage_data_helpers.rb')
-rw-r--r--rubocop/usage_data_helpers.rb19
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