Class: Violation
- Inherits:
-
RuleDefinition
- Object
- RuleDefinition
- Violation
- Defined in:
- lib/cfn-nag/violation.rb
Overview
Rule definition for violations
Constant Summary
Constants inherited from RuleDefinition
RuleDefinition::FAILING_VIOLATION, RuleDefinition::WARNING
Instance Attribute Summary collapse
-
#logical_resource_ids ⇒ Object
readonly
Returns the value of attribute logical_resource_ids.
Attributes inherited from RuleDefinition
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id:, type:, message:, logical_resource_ids: nil) ⇒ Violation
constructor
A new instance of Violation.
- #to_h ⇒ Object
- #to_s ⇒ Object
Methods inherited from RuleDefinition
Constructor Details
#initialize(id:, type:, message:, logical_resource_ids: nil) ⇒ Violation
Returns a new instance of Violation.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/cfn-nag/violation.rb', line 7 def initialize(id:, type:, message:, logical_resource_ids: nil) super id: id, type: type, message: @logical_resource_ids = logical_resource_ids end |
Instance Attribute Details
#logical_resource_ids ⇒ Object (readonly)
Returns the value of attribute logical_resource_ids.
5 6 7 |
# File 'lib/cfn-nag/violation.rb', line 5 def logical_resource_ids @logical_resource_ids end |
Class Method Details
.count_failures(violations) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/cfn-nag/violation.rb', line 42 def count_failures(violations) violations.inject(0) do |count, violation| if violation.type == Violation::FAILING_VIOLATION count += if empty?(violation.logical_resource_ids) 1 else violation.logical_resource_ids.size end end count end end |
.count_warnings(violations) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cfn-nag/violation.rb', line 29 def count_warnings(violations) violations.inject(0) do |count, violation| if violation.type == Violation::WARNING count += if empty?(violation.logical_resource_ids) 1 else violation.logical_resource_ids.size end end count end end |
Instance Method Details
#to_h ⇒ Object
22 23 24 25 26 |
# File 'lib/cfn-nag/violation.rb', line 22 def to_h super.to_h.merge( logical_resource_ids: @logical_resource_ids ) end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/cfn-nag/violation.rb', line 18 def to_s "#{super} #{@logical_resource_ids}" end |