Class: RuboCop::Cop::G2::AggregatesModelBoundary

Inherits:
Cop
  • Object
show all
Defined in:
lib/rubocop/cop/g2/aggregates_model_boundary.rb

Constant Summary collapse

MSG =
'Do not directly reference an aggregate model outside of the aggregates engine. You should do all CRUD'\
' operations through new or existing service objects in the engine.'.freeze
AGGREGATE_MODELS =
%w(
  :AnswerAggregateValue
  :AnswerAggregateDistribution
  :ReportQuarterAnswerAggregateValue
  :ReportQuarterAnswerAggregateDistribution
  :HighestRatedAnswerAggregate
  :HighestRatedAnswerAggregateDistribution
).freeze
AGGREGATES_ENGINE_PATH =
'engines/aggregates'.freeze
SPEC_PATH =
'spec'.freeze

Instance Method Summary collapse

Instance Method Details

#on_const(node) ⇒ Object



24
25
26
27
# File 'lib/rubocop/cop/g2/aggregates_model_boundary.rb', line 24

def on_const(node)
  return if ignored_file?
  add_offense(node, location: :expression) if direct_model_reference?(node)
end