Class: StatementMetric

Inherits:
Object show all
Includes:
Weights
Defined in:
lib/cfn-nag/iam_complexity_metric/statement_metric.rb

Instance Method Summary collapse

Methods included from Weights

#weights

Instance Method Details

#metric(statement) ⇒ Object

rubocop:disable Metrics/AbcSize


11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cfn-nag/iam_complexity_metric/statement_metric.rb', line 11

def metric(statement)
  aggregate = weights[:Base_Statement]

  aggregate += effect_metrics(statement)
  aggregate += inversion_metrics(statement)
  aggregate += extra_service_count(statement) * weights[:Extra_Service]
  aggregate += misaligned_resource_action_count(statement) * weights[:Resource_Action_NotAligned]
  aggregate += mixed_wildcard(statement) * weights[:Mixed_Wildcard]

  aggregate += ConditionMetric.new.metric(statement) unless statement.condition.nil?

  aggregate
end