Class: Violation
Constant Summary
RuleDefinition::FAILING_VIOLATION, RuleDefinition::WARNING
Instance Attribute Summary collapse
#id, #message, #type
Class Method Summary
collapse
Instance Method Summary
collapse
#==
Constructor Details
#initialize(id:, type:, message:, logical_resource_ids: nil) ⇒ Violation
Returns a new instance of Violation.
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/cfn-nag/violation.rb', line 6
def initialize(id:,
type:,
message:,
logical_resource_ids: nil)
super id: id,
type: type,
message: message
@logical_resource_ids = logical_resource_ids
end
|
Instance Attribute Details
#logical_resource_ids ⇒ Object
Returns the value of attribute logical_resource_ids.
4
5
6
|
# File 'lib/cfn-nag/violation.rb', line 4
def logical_resource_ids
@logical_resource_ids
end
|
Class Method Details
.count_failures(violations) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/cfn-nag/violation.rb', line 40
def self.count_failures(violations)
violations.inject(0) do |count, violation|
if violation.type == Violation::FAILING_VIOLATION
if empty?(violation.logical_resource_ids)
count += 1
else
count += violation.logical_resource_ids.size
end
end
count
end
end
|
.count_warnings(violations) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/cfn-nag/violation.rb', line 27
def self.count_warnings(violations)
violations.inject(0) do |count, violation|
if violation.type == Violation::WARNING
if empty?(violation.logical_resource_ids)
count += 1
else
count += violation.logical_resource_ids.size
end
end
count
end
end
|
Instance Method Details
#to_h ⇒ Object
21
22
23
24
25
|
# File 'lib/cfn-nag/violation.rb', line 21
def to_h
super.to_h.merge({
logical_resource_ids: @logical_resource_ids
})
end
|
#to_s ⇒ Object
17
18
19
|
# File 'lib/cfn-nag/violation.rb', line 17
def to_s
"#{super.to_s} #{@logical_resource_ids}"
end
|