Class: ConditionMetric

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

Instance Method Summary collapse

Methods included from Weights

#weights

Instance Method Details

#metric(statement) ⇒ Object


9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cfn-nag/iam_complexity_metric/condition_metric.rb', line 9

def metric(statement)
  return 0 if statement.condition.nil?

  aggregate = 0
  aggregate += statement.condition.size * weights[:Condition]
  aggregate += confusing_value_operators(statement.condition)
  aggregate += if_exists_operators(statement.condition)
  aggregate += weights[:Null] if null_operator?(statement.condition)
  aggregate += values_with_policy_tags(statement.condition)
  aggregate
end