From ae7bfa5c9d960c946a7d6ea6f464159e39edce25 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 10 Jun 2022 14:57:28 +0200 Subject: [PATCH 01/11] rubocop: Fix Layout/SpaceBeforeBlockBraces --- .rubocop_todo.yml | 11 +---------- spec/unit/puppet/catalog_diff/comparer_spec.rb | 2 +- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6c0f018..186cafa 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,20 +1,11 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2022-06-10 12:48:42 UTC using RuboCop version 1.22.3. +# on 2022-06-10 12:56:45 UTC using RuboCop version 1.22.3. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceBeforeBlockBraces: - Exclude: - - 'spec/unit/puppet/catalog_diff/comparer_spec.rb' - # Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. diff --git a/spec/unit/puppet/catalog_diff/comparer_spec.rb b/spec/unit/puppet/catalog_diff/comparer_spec.rb index 885c481..60384a0 100644 --- a/spec/unit/puppet/catalog_diff/comparer_spec.rb +++ b/spec/unit/puppet/catalog_diff/comparer_spec.rb @@ -88,7 +88,7 @@ latin1_string = [246].pack('C*').force_encoding('UTF-8') res1[0][:parameters][:content] = latin1_string - expect{compare_resources(res1, res2, show_resource_diff: true)}.not_to raise_error + expect {compare_resources(res1, res2, show_resource_diff: true)}.not_to raise_error diffs = compare_resources(res1, res2, show_resource_diff: true) ruby_default_replacement_string_for_invalid_characters = '�' From a13dd72f32f6462d16819a9e787365a73b706248 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 10 Jun 2022 14:58:26 +0200 Subject: [PATCH 02/11] rubocop: Fix Style/ClassEqualityComparison --- .rubocop_todo.yml | 10 +--------- lib/puppet/catalog-diff/comparer.rb | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 186cafa..4980796 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2022-06-10 12:56:45 UTC using RuboCop version 1.22.3. +# on 2022-06-10 12:58:15 UTC using RuboCop version 1.22.3. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -107,14 +107,6 @@ Style/CaseLikeIf: - 'lib/puppet/catalog-diff/formater.rb' - 'lib/puppet/face/catalog/diff.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: IgnoredMethods. -# IgnoredMethods: ==, equal?, eql? -Style/ClassEqualityComparison: - Exclude: - - 'lib/puppet/catalog-diff/comparer.rb' - # Offense count: 1 Style/ClassVars: Exclude: diff --git a/lib/puppet/catalog-diff/comparer.rb b/lib/puppet/catalog-diff/comparer.rb index 5f7b613..d8256b3 100644 --- a/lib/puppet/catalog-diff/comparer.rb +++ b/lib/puppet/catalog-diff/comparer.rb @@ -93,7 +93,7 @@ def sort_dependencies!(params) params.each do |x| next unless %i[require before notify subscribe].include?(x[0]) - if x[1].class == Array + if x[1].instance_of?(Array) x[1].sort! end end From ac56050371c5593500a682be8d70b3c923b6c899 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 10 Jun 2022 14:59:07 +0200 Subject: [PATCH 03/11] rubocop: Fix Style/RedundantSelfAssignment --- .rubocop_todo.yml | 8 +------- lib/puppet/catalog-diff/searchfacts.rb | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4980796..cb82b6c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2022-06-10 12:58:15 UTC using RuboCop version 1.22.3. +# on 2022-06-10 12:58:42 UTC using RuboCop version 1.22.3. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -232,12 +232,6 @@ Style/RedundantParentheses: - 'lib/puppet/catalog-diff/differ.rb' - 'lib/puppet/catalog-diff/formater.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Style/RedundantSelfAssignment: - Exclude: - - 'lib/puppet/catalog-diff/searchfacts.rb' - # Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, AllowInnerSlashes. diff --git a/lib/puppet/catalog-diff/searchfacts.rb b/lib/puppet/catalog-diff/searchfacts.rb index f63a510..1cb8d1a 100644 --- a/lib/puppet/catalog-diff/searchfacts.rb +++ b/lib/puppet/catalog-diff/searchfacts.rb @@ -31,7 +31,7 @@ def build_query(env, version) classes = Hash[@facts.select { |_k, v| v.nil? }].keys classes.each do |c| capit = c.split('::').map(&:capitalize).join('::') - query = query.concat( + query.concat( [['in', 'certname', ['extract', 'certname', ['select-resources', From 2c82d534c37eb1de3343f5f8e0308973f51c19e9 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 10 Jun 2022 14:59:35 +0200 Subject: [PATCH 04/11] rubocop: Fix Style/RedundantAssignment --- .rubocop_todo.yml | 8 +------- lib/puppet/catalog-diff/searchfacts.rb | 3 +-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index cb82b6c..15d182f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2022-06-10 12:58:42 UTC using RuboCop version 1.22.3. +# on 2022-06-10 12:59:22 UTC using RuboCop version 1.22.3. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -219,12 +219,6 @@ Style/NumericPredicate: - 'spec/**/*' - 'lib/puppet/catalog-diff/differ.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Style/RedundantAssignment: - Exclude: - - 'lib/puppet/catalog-diff/searchfacts.rb' - # Offense count: 3 # Cop supports --auto-correct. Style/RedundantParentheses: diff --git a/lib/puppet/catalog-diff/searchfacts.rb b/lib/puppet/catalog-diff/searchfacts.rb index 1cb8d1a..dfeb33c 100644 --- a/lib/puppet/catalog-diff/searchfacts.rb +++ b/lib/puppet/catalog-diff/searchfacts.rb @@ -76,8 +76,7 @@ def find_nodes_puppetdb(env, puppetdb) rescue PSON::ParserError => e raise "Error parsing json output of puppet search: #{e.message}" end - names = filtered.map { |node| node['certname'] } - names + filtered.map { |node| node['certname'] } end end end From bffaed751918fe80020dfcd450b61ade5fa94633 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 10 Jun 2022 15:00:12 +0200 Subject: [PATCH 05/11] rubocop: Fix Style/NumericPredicate --- .rubocop_todo.yml | 11 +---------- lib/puppet/catalog-diff/differ.rb | 2 +- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 15d182f..75572f5 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2022-06-10 12:59:22 UTC using RuboCop version 1.22.3. +# on 2022-06-10 12:59:54 UTC using RuboCop version 1.22.3. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -210,15 +210,6 @@ Style/MultipleComparison: Exclude: - 'lib/puppet/catalog-diff/compilecatalog.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IgnoredMethods. -# SupportedStyles: predicate, comparison -Style/NumericPredicate: - Exclude: - - 'spec/**/*' - - 'lib/puppet/catalog-diff/differ.rb' - # Offense count: 3 # Cop supports --auto-correct. Style/RedundantParentheses: diff --git a/lib/puppet/catalog-diff/differ.rb b/lib/puppet/catalog-diff/differ.rb index 176a785..2977f0a 100644 --- a/lib/puppet/catalog-diff/differ.rb +++ b/lib/puppet/catalog-diff/differ.rb @@ -119,7 +119,7 @@ def diff(options = {}) output[:added_and_removed_resources] = "#{(!additions.zero? && "+#{additions}" || 0)} / #{(!subtractions.zero? && "-#{subtractions}" || 0)}" divide_by = (changes_percentage.zero? ? 0 : 1) + (additions_percentage.zero? ? 0 : 1) + (subtractions_percentage.zero? ? 0 : 1) - output[:node_percentage] = (divide_by == 0 && 0 || additions_percentage == 100 && 100 || (changes_percentage + additions_percentage + subtractions_percentage) / divide_by).to_f + output[:node_percentage] = (divide_by.zero? && 0 || additions_percentage == 100 && 100 || (changes_percentage + additions_percentage + subtractions_percentage) / divide_by).to_f output[:node_differences] = (additions.abs.to_i + subtractions.abs.to_i + changes.abs.to_i) output end From cec5a9dd3d0434273f0c9fe253863fddf54687a9 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 10 Jun 2022 15:01:00 +0200 Subject: [PATCH 06/11] rubocop: Fix Style/MultipleComparison --- .rubocop_todo.yml | 9 +-------- lib/puppet/catalog-diff/compilecatalog.rb | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 75572f5..31a0946 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2022-06-10 12:59:54 UTC using RuboCop version 1.22.3. +# on 2022-06-10 13:00:29 UTC using RuboCop version 1.22.3. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -203,13 +203,6 @@ Style/MultilineBlockChain: Exclude: - 'lib/puppet/face/catalog/diff.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: AllowMethodComparison. -Style/MultipleComparison: - Exclude: - - 'lib/puppet/catalog-diff/compilecatalog.rb' - # Offense count: 3 # Cop supports --auto-correct. Style/RedundantParentheses: diff --git a/lib/puppet/catalog-diff/compilecatalog.rb b/lib/puppet/catalog-diff/compilecatalog.rb index c92a92e..fbe3328 100644 --- a/lib/puppet/catalog-diff/compilecatalog.rb +++ b/lib/puppet/catalog-diff/compilecatalog.rb @@ -158,7 +158,7 @@ def clean_nested_sensitive_parameters!(catalog) def redact_sensitive(data) if data.is_a?(Hash) && data.key?('__ptype') data[:catalog_diff_hash] = Digest::SHA256.hexdigest Marshal.dump(data['__pvalue']) - data.reject! { |k| k == '__ptype' || k == '__pvalue' } + data.reject! { |k| %w[__ptype __pvalue].include?(k) } elsif data.is_a? Hash data.each do |_k, v| redact_sensitive(v) if v.is_a?(Hash) || v.is_a?(Array) From b1b4b230bd0d0202c9044f5d0f6d616f75ce4125 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 10 Jun 2022 15:01:32 +0200 Subject: [PATCH 07/11] rubocop: Fix Style/HashSyntax --- .rubocop_todo.yml | 10 +--------- lib/puppet/catalog-diff/comparer.rb | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 31a0946..e057208 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2022-06-10 13:00:29 UTC using RuboCop version 1.22.3. +# on 2022-06-10 13:01:21 UTC using RuboCop version 1.22.3. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -173,14 +173,6 @@ Style/HashConversion: - 'lib/puppet/face/catalog/diff.rb' - 'lib/puppet/face/catalog/pull.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. -# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys -Style/HashSyntax: - Exclude: - - 'lib/puppet/catalog-diff/comparer.rb' - # Offense count: 11 # Cop supports --auto-correct. Style/IfUnlessModifier: diff --git a/lib/puppet/catalog-diff/comparer.rb b/lib/puppet/catalog-diff/comparer.rb index d8256b3..16fb276 100644 --- a/lib/puppet/catalog-diff/comparer.rb +++ b/lib/puppet/catalog-diff/comparer.rb @@ -123,7 +123,7 @@ def do_str_diff(str1, str2) def validate_encoding(str) unless str.valid_encoding? Puppet::debug("Detected that string used in diff had invalid #{str.encoding} encoding. Replacing invalid characters in diff output.") - str.encode!('UTF-8', 'UTF-8', :invalid => :replace) + str.encode!('UTF-8', 'UTF-8', invalid: :replace) end str end From 498b060ac485df87a222422325a79d654299fdb9 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 10 Jun 2022 15:02:31 +0200 Subject: [PATCH 08/11] rubocop: Fix Style/CollectionCompact --- .rubocop_todo.yml | 8 +------- lib/puppet/catalog-diff/searchfacts.rb | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e057208..2252e1b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2022-06-10 13:01:21 UTC using RuboCop version 1.22.3. +# on 2022-06-10 13:02:07 UTC using RuboCop version 1.22.3. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -112,12 +112,6 @@ Style/ClassVars: Exclude: - 'lib/puppet/catalog-diff/comparer.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Style/CollectionCompact: - Exclude: - - 'lib/puppet/catalog-diff/searchfacts.rb' - # Offense count: 3 # Cop supports --auto-correct. Style/ColonMethodCall: diff --git a/lib/puppet/catalog-diff/searchfacts.rb b/lib/puppet/catalog-diff/searchfacts.rb index dfeb33c..84735ef 100644 --- a/lib/puppet/catalog-diff/searchfacts.rb +++ b/lib/puppet/catalog-diff/searchfacts.rb @@ -26,7 +26,7 @@ def build_query(env, version) base_query = ['and', ['=', %w[node active], true]] query_field_catalog_environment = Puppet::Util::Package.versioncmp(version, '3') >= 0 ? 'catalog_environment' : 'catalog-environment' base_query.concat([['=', query_field_catalog_environment, env]]) if env - real_facts = @facts.reject { |_k, v| v.nil? } + real_facts = @facts.compact query = base_query.concat(real_facts.map { |k, v| ['=', ['fact', k], v] }) classes = Hash[@facts.select { |_k, v| v.nil? }].keys classes.each do |c| From ef676535f9e2266e6abcc9cbeb26717c76de41c9 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 10 Jun 2022 15:03:08 +0200 Subject: [PATCH 09/11] rubocop: Fix Layout/SpaceInsideBlockBraces --- .rubocop_todo.yml | 11 +---------- spec/unit/puppet/catalog_diff/comparer_spec.rb | 2 +- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2252e1b..ace38ab 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,20 +1,11 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2022-06-10 13:02:07 UTC using RuboCop version 1.22.3. +# on 2022-06-10 13:02:56 UTC using RuboCop version 1.22.3. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideBlockBraces: - Exclude: - - 'spec/unit/puppet/catalog_diff/comparer_spec.rb' - # Offense count: 3 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. diff --git a/spec/unit/puppet/catalog_diff/comparer_spec.rb b/spec/unit/puppet/catalog_diff/comparer_spec.rb index 60384a0..9758af6 100644 --- a/spec/unit/puppet/catalog_diff/comparer_spec.rb +++ b/spec/unit/puppet/catalog_diff/comparer_spec.rb @@ -88,7 +88,7 @@ latin1_string = [246].pack('C*').force_encoding('UTF-8') res1[0][:parameters][:content] = latin1_string - expect {compare_resources(res1, res2, show_resource_diff: true)}.not_to raise_error + expect { compare_resources(res1, res2, show_resource_diff: true) }.not_to raise_error diffs = compare_resources(res1, res2, show_resource_diff: true) ruby_default_replacement_string_for_invalid_characters = '�' From bca5036aad474882a213451563a6512383b5313a Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 10 Jun 2022 15:03:40 +0200 Subject: [PATCH 10/11] rubocop: Fix Layout/SpaceInsideHashLiteralBraces --- .rubocop_todo.yml | 12 +----------- lib/puppet/catalog-diff/compilecatalog.rb | 2 +- lib/puppet/catalog-diff/searchfacts.rb | 4 ++-- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ace38ab..e02d845 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,21 +1,11 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2022-06-10 13:02:56 UTC using RuboCop version 1.22.3. +# on 2022-06-10 13:03:28 UTC using RuboCop version 1.22.3. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideHashLiteralBraces: - Exclude: - - 'lib/puppet/catalog-diff/compilecatalog.rb' - - 'lib/puppet/catalog-diff/searchfacts.rb' - # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: AllowInHeredoc. diff --git a/lib/puppet/catalog-diff/compilecatalog.rb b/lib/puppet/catalog-diff/compilecatalog.rb index fbe3328..1f4c77b 100644 --- a/lib/puppet/catalog-diff/compilecatalog.rb +++ b/lib/puppet/catalog-diff/compilecatalog.rb @@ -55,7 +55,7 @@ def get_catalog_from_puppetdb(node_name, server, puppetdb) query.concat([['=', 'environment', environment]]) json_query = URI.encode_www_form_component(query.to_json) request_url = URI("#{puppetdb}/pdb/query/v4/catalogs?query=#{json_query}") - headers = { 'Accept-Content' => 'application/json'} + headers = { 'Accept-Content' => 'application/json' } ret = Puppet.runtime[:http].get(request_url, headers: headers) unless ret.success? raise "HTTP request to PuppetDB failed with: HTTP #{ret.code} - #{ret.reason}" diff --git a/lib/puppet/catalog-diff/searchfacts.rb b/lib/puppet/catalog-diff/searchfacts.rb index 84735ef..3515b18 100644 --- a/lib/puppet/catalog-diff/searchfacts.rb +++ b/lib/puppet/catalog-diff/searchfacts.rb @@ -44,7 +44,7 @@ def build_query(env, version) end def get_puppetdb_version(server) - headers = { 'Accept' => 'application/json'} + headers = { 'Accept' => 'application/json' } result = Puppet.runtime[:http].get(URI("#{server}/pdb/meta/v1/version"), headers: headers) if result.code == 200 body = JSON.parse(result.body) @@ -61,7 +61,7 @@ def find_nodes_puppetdb(env, puppetdb) puppetdb_version = get_puppetdb_version(puppetdb) query = build_query(env, puppetdb_version) json_query = URI.escape(query.to_json) - headers = { 'Accept' => 'application/json'} + headers = { 'Accept' => 'application/json' } Puppet.debug("Querying #{puppetdb} for environment #{env}") begin result = Puppet.runtime[:http].get(URI("#{puppetdb}/pdb/query/v4/nodes?query=#{json_query}"), headers: headers) From cb77f2090ddf0dc7f0fc03de46c05bafb008d13c Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 10 Jun 2022 15:04:08 +0200 Subject: [PATCH 11/11] rubocop: Fix Layout/TrailingWhitespace --- .rubocop_todo.yml | 9 +-------- spec/unit/puppet/catalog_diff/comparer_spec.rb | 8 ++++---- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e02d845..44870bc 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,18 +1,11 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2022-06-10 13:03:28 UTC using RuboCop version 1.22.3. +# on 2022-06-10 13:03:56 UTC using RuboCop version 1.22.3. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: AllowInHeredoc. -Layout/TrailingWhitespace: - Exclude: - - 'spec/unit/puppet/catalog_diff/comparer_spec.rb' - # Offense count: 21 # Cop supports --auto-correct. Lint/AmbiguousOperatorPrecedence: diff --git a/spec/unit/puppet/catalog_diff/comparer_spec.rb b/spec/unit/puppet/catalog_diff/comparer_spec.rb index 9758af6..993eb38 100644 --- a/spec/unit/puppet/catalog_diff/comparer_spec.rb +++ b/spec/unit/puppet/catalog_diff/comparer_spec.rb @@ -79,18 +79,18 @@ diffs = compare_resources(res1, res2, show_resource_diff: true) expect(diffs[:string_diffs]['file.foo'][3]).to eq("-\t content => \"foo content\"") end - + it 'returns string_diffs with show_resource_diff with content encoded in ISO8859-1 (latin1)' do # Without this the unit test fails when running on LC_ALL=C but works with LC_ALL=en_US.UTF-8 # With this it works on both. Encoding.default_internal = 'UTF-8' Encoding.default_external = 'UTF-8' # Needed because diff uses tempfile. - + latin1_string = [246].pack('C*').force_encoding('UTF-8') - res1[0][:parameters][:content] = latin1_string + res1[0][:parameters][:content] = latin1_string expect { compare_resources(res1, res2, show_resource_diff: true) }.not_to raise_error diffs = compare_resources(res1, res2, show_resource_diff: true) - + ruby_default_replacement_string_for_invalid_characters = '�' expect(diffs[:string_diffs]['file.foo'][3]).to \ eq("-\t content => \"" + ruby_default_replacement_string_for_invalid_characters + '"')