Skip to content

Check dangerous use of scope via RuboCop rule

Problem

In https://docs.gitlab.com/ee/development/policies.html#scope we are warning the use of scope: :subject when more both user and subject are checked:

DANGER: If you use a :scope option when the condition actually uses data from both user and subject (including a simple anonymous check!) your result is cached at too global of a scope and results in cache bugs.

Proposed solution

Create a rule to check if scope: :subject is used but user (or other receivers?) are used with a condition block.

Refs