Skip to content

Commit 9ef8d3e

Browse files
author
Jérémie Pierson
committed
Correct Rubocop offense about nested ifs
This is a bit less nice because the nested if allowed another comment, but hey, Rubocop.
1 parent 6ecd034 commit 9ef8d3e

File tree

1 file changed

+24
-27
lines changed

1 file changed

+24
-27
lines changed

lib/puppet/type/file/content.rb

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -54,34 +54,31 @@ module Puppet
5454
if @actual_content || resource.parameter(:source)
5555
# Actual content is already set, value contains it's checksum
5656
value
57+
elsif Puppet[:use_checksum_in_file_content]
58+
# The value passed in the "content" attribute of this file looks like
59+
# a checksum, and this is intended by the user.
60+
# Display a warning as this behavior is deprecated.
61+
Puppet.puppet_deprecation_warning([
62+
# TRANSLATORS "content" is an attribute and should not be translated
63+
_('Using a checksum in a file\'s "content" property is deprecated.'),
64+
# TRANSLATORS "filebucket" is a resource type and should not be translated. The quoted occurrence of "content" is an attribute and should not be translated.
65+
_('The ability to use a checksum to retrieve content from the filebucket using the "content" property will be removed in a future release.'),
66+
# TRANSLATORS "content" is an attribute and should not be translated.
67+
_('The literal value of the "content" property will be written to the file.'),
68+
# TRANSLATORS "static catalogs" should not be translated.
69+
_('The checksum retrieval functionality is being replaced by the use of static catalogs.'),
70+
_('See https://puppet.com/docs/puppet/latest/static_catalogs.html for more information.')
71+
].join(" "),
72+
:file => @resource.file,
73+
:line => @resource.line) if !@actual_content && !resource.parameter(:source)
74+
# We return the value assuming it really is the checksum of the
75+
# actual content we want. It should be fetched from filebucket
76+
# later on.
77+
value
5778
else
58-
# The value passed in the "content" attribute of this file looks like a checksum.
59-
if Puppet[:use_checksum_in_file_content]
60-
# Assume user wants the deprecated behavior; display a warning though.
61-
# XXX This is potentially dangerous because it means users can't write a file whose
62-
# entire contents are a plain checksum unless it is a Binary content.
63-
Puppet.puppet_deprecation_warning([
64-
# TRANSLATORS "content" is an attribute and should not be translated
65-
_('Using a checksum in a file\'s "content" property is deprecated.'),
66-
# TRANSLATORS "filebucket" is a resource type and should not be translated. The quoted occurrence of "content" is an attribute and should not be translated.
67-
_('The ability to use a checksum to retrieve content from the filebucket using the "content" property will be removed in a future release.'),
68-
# TRANSLATORS "content" is an attribute and should not be translated.
69-
_('The literal value of the "content" property will be written to the file.'),
70-
# TRANSLATORS "static catalogs" should not be translated.
71-
_('The checksum retrieval functionality is being replaced by the use of static catalogs.'),
72-
_('See https://puppet.com/docs/puppet/latest/static_catalogs.html for more information.')
73-
].join(" "),
74-
:file => @resource.file,
75-
:line => @resource.line) if !@actual_content && !resource.parameter(:source)
76-
# We return the value assuming it really is the checksum of the
77-
# actual content we want. It should be fetched from filebucket
78-
# later on.
79-
value
80-
else
81-
# The content only happens to look like a checksum by chance.
82-
@actual_content = value.is_a?(Puppet::Pops::Types::PBinaryType::Binary) ? value.binary_buffer : value
83-
resource.parameter(:checksum).sum(@actual_content)
84-
end
79+
# The content only happens to look like a checksum by chance.
80+
@actual_content = value.is_a?(Puppet::Pops::Types::PBinaryType::Binary) ? value.binary_buffer : value
81+
resource.parameter(:checksum).sum(@actual_content)
8582
end
8683
else
8784
# Our argument is definitely not a checksum: set actual_value and return calculated checksum.

0 commit comments

Comments
 (0)