@@ -13,6 +13,8 @@ def initialize(scheme, subdirectory = nil)
1313 # returns the most specific value provided in the mapping file for the given vrt id
1414 #
1515 # if no mapping file exists for the given version, the mapping file for the earliest version available will be used
16+ # rubocop:disable Metrics/CyclomaticComplexity
17+ # rubocop:disable Metrics/PerceivedComplexity
1618 def get ( id_list , version )
1719 # update the vrt id to the first version we have a mapping file for
1820 unless @mappings . key? ( version )
@@ -29,15 +31,17 @@ def get(id_list, version)
2931 # { remediation_advice: { remediation_advice: '...', references: [...] } }
3032 keys . each_with_object ( { } ) do |key , acc |
3133 acc [ key . to_sym ] = get_key (
32- id_list : id_list ,
33- mapping : mapping ,
34- key : key
34+ id_list :,
35+ mapping :,
36+ key :
3537 ) || default &.dig ( key )
3638 end
3739 else
38- get_key ( id_list : id_list , mapping : mapping , key : @scheme ) || default
40+ get_key ( id_list :, mapping :, key : @scheme ) || default
3941 end
4042 end
43+ # rubocop:enable Metrics/CyclomaticComplexity
44+ # rubocop:enable Metrics/PerceivedComplexity
4145
4246 private
4347
@@ -74,7 +78,7 @@ def key_by_id(mapping)
7478 if mapping . is_a? ( Array ) && mapping . first . is_a? ( Hash ) && mapping . first . key? ( 'id' )
7579 mapping . each_with_object ( { } ) { |entry , acc | acc [ entry [ 'id' ] . to_sym ] = key_by_id ( entry ) }
7680 elsif mapping . is_a? ( Hash )
77- mapping . each_with_object ( { } ) { |( key , value ) , acc | acc [ key ] = key_by_id ( value ) }
81+ mapping . transform_values { |value | key_by_id ( value ) }
7882 else
7983 mapping
8084 end
0 commit comments