Method: Inspec::Rule.merge
- Defined in:
- lib/inspec/rule.rb
.merge(dst, src) ⇒ Object
rubocop:disable Metrics/AbcSize
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/inspec/rule.rb', line 196 def self.merge(dst, src) # rubocop:disable Metrics/AbcSize if src.id != dst.id # TODO: register an error, this case should not happen return end sp = rule_id(src) dp = rule_id(dst) if sp != dp # TODO: register an error, this case should not happen return end # merge all fields dst.impact(src.impact) unless src.impact.nil? dst.title(src.title) unless src.title.nil? dst.desc(src.desc) unless src.desc.nil? dst.tag(src.tag) unless src.tag.nil? dst.ref(src.ref) unless src.ref.nil? # use the most recent source location dst.instance_variable_set( :@__source_location, src.instance_variable_get(:@__source_location), ) # merge indirect fields # checks defined in the source will completely eliminate # all checks that were defined in the destination sc = checks(src) dst.instance_variable_set(:@__checks, sc) unless sc.empty? sr = skip_status(src) set_skip_rule(dst, sr) unless sr.nil? # increment merge count dst.instance_variable_set(:@__merge_count, merge_count(dst) + 1) end |