Class: RuboCop::Cop::Gusto::DatadogConstant

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/gusto/datadog_constant.rb

Overview

Disallow referencing the ‘Datadog` constant directly. Calls should go through an approved wrapper library so instrumentation stays consistent and swappable.

Examples:

# bad
Datadog::Tracing.active_trace

# good
Observability.active_trace

Constant Summary collapse

MSG =
"Do not call Datadog directly, use an appropriate wrapper library."
NAMESPACE =
"Datadog"

Instance Method Summary collapse

Instance Method Details

#on_const(node) ⇒ Object



20
21
22
# File 'lib/rubocop/cop/gusto/datadog_constant.rb', line 20

def on_const(node)
  add_offense(node) if node.const_name == NAMESPACE
end