Skip to content

Fix danger rule for Analytics Instrumentation

What does this MR do and why?

Analytics Instrumentation review did not trigger most calls to Gitlab::Tracking.event. This MR fixes that.

The rule would only trigger if Gitlab::Tracking.event was at the end of a line. In most cases it is not at the end of the line.

This fix also applies to calls to Gitlab::Tracking.enabled? and Gitlab::Tracking.options.

How to set up and validate locally

On master the below steps does not provide a warning. On this branch it should output an error like this

image

  1. Create a new Ruby file that calls Gitlab::Tracking.event:
    echo -e "# frozen_string_literal: true\n" \
      "\n" \
      "module Demo\n" \
      "  Gitlab::Tracking.event('abc')\n" \
      "end" > demo.rb
  2. Make a new commit with the change git add demo.rb && git commit -m"To test danger"
  3. Run Danger: bundle exec rake danger_local

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #427889 (closed)

Edited by Jonas Larsen

Merge request reports