Skip to content

Commit 55c4486

Browse files
authored
Merge pull request #9526 from mhashizume/maint/7.x/check-fixes
Check fixes
2 parents 40ede6b + f83f3fe commit 55c4486

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

.rubocop_todo.yml

+3
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,10 @@ Naming/VariableNumber:
920920
# SupportedStyles: inline, group
921921
Style/AccessModifierDeclarations:
922922
Exclude:
923+
- 'lib/puppet/util/command_line/trollop.rb'
923924
- 'lib/puppet/util/suidmanager.rb'
925+
- 'lib/puppet/util/windows/com.rb'
926+
- 'lib/puppet/util/windows/monkey_patches/process.rb'
924927

925928
# This cop supports safe auto-correction (--auto-correct).
926929
# Configuration parameters: EnforcedStyle.

lib/puppet/face/facts.rb

+9-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,15 @@
164164

165165
case result
166166
when Array, Hash
167-
Puppet::Util::Json.dump(result, :pretty => true)
167+
# JSON < 2.8.0 would pretty print empty arrays and hashes with newlines
168+
# Maintain that behavior for our users for now
169+
if result.is_a?(Array) && result.empty?
170+
"[\n\n]"
171+
elsif result.is_a?(Hash) && result.empty?
172+
"{\n}"
173+
else
174+
Puppet::Util::Json.dump(result, :pretty => true)
175+
end
168176
else # one of VALID_TYPES above
169177
result
170178
end

spec/unit/application/facts_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191

9292
{
9393
"type_hash" => [{'a' => 2}, "{\n \"a\": 2\n}"],
94+
"type_empty_hash" => [{}, "{\n}"],
9495
"type_array" => [[], "[\n\n]"],
9596
"type_string" => ["str", "str"],
9697
"type_int" => [1, "1"],

spec/unit/provider/package/puppetserver_gem_spec.rb

+7-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,13 @@
7777

7878
it "raises if given an invalid URI" do
7979
resource[:source] = 'h;ttp://rubygems.com'
80-
expect { provider.install }.to raise_error(Puppet::Error, /Invalid source '': bad URI\(is not URI\?\)/)
80+
# Older versions of URI don't have a space before the opening
81+
# parenthesis in the error message, newer versions do
82+
if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('3.0.0')
83+
expect { provider.install }.to raise_error(Puppet::Error, /Invalid source '': bad URI\(is not URI\?\)/)
84+
else
85+
expect { provider.install }.to raise_error(Puppet::Error, /Invalid source '': bad URI \(is not URI\?\)/)
86+
end
8187
end
8288
end
8389
end

0 commit comments

Comments
 (0)