Skip to content

Commit 1899f97

Browse files
committed
(PUP-11993) Style/RedundantParentheses
This commit enables the Style/RedundantParentheses cop and fixes 50 autocorrectable offenses.
1 parent 7dc9c0d commit 1899f97

33 files changed

+44
-48
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -668,10 +668,6 @@ Style/RedundantFetchBlock:
668668
Style/RedundantInterpolation:
669669
Enabled: false
670670

671-
# This cop supports safe auto-correction (--auto-correct).
672-
Style/RedundantParentheses:
673-
Enabled: false
674-
675671
# This cop supports safe auto-correction (--auto-correct).
676672
Style/RedundantPercentQ:
677673
Exclude:

lib/puppet/application/agent.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ def enable_disable_client(agent)
509509
end
510510

511511
def setup_agent
512-
agent = Puppet::Agent.new(Puppet::Configurer, (!(Puppet[:onetime])))
512+
agent = Puppet::Agent.new(Puppet::Configurer, !(Puppet[:onetime]))
513513

514514
enable_disable_client(agent) if options[:enable] or options[:disable]
515515

lib/puppet/application/describe.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def wrap(txt, opts)
1111
return "" unless txt && !txt.empty?
1212

1313
work = (opts[:scrub] ? scrub(txt) : txt)
14-
indent = (opts[:indent] || 0)
14+
indent = opts[:indent] || 0
1515
textLen = @width - indent
1616
patt = Regexp.new("\\A(.{0,#{textLen}})[ \n]")
1717
prefix = " " * indent

lib/puppet/application/face_base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def setup
205205
@arguments << options
206206

207207
# If we don't have a rendering format, set one early.
208-
self.render_as ||= (@action.render_as || :console)
208+
self.render_as ||= @action.render_as || :console
209209
end
210210

211211
def main

lib/puppet/defaults.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ def self.initialize_default_settings!(settings)
489489
},
490490
:daemonize => {
491491
:type => :boolean,
492-
:default => (!Puppet::Util::Platform.windows?),
492+
:default => !Puppet::Util::Platform.windows?,
493493
:desc => "Whether to send the process into the background. This defaults
494494
to true on POSIX systems, and to false on Windows (where Puppet
495495
currently cannot daemonize).",

lib/puppet/face/help.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def erb(name)
147147
# Return a list of applications that are not simply just stubs for Faces.
148148
def legacy_applications
149149
Puppet::Application.available_application_names.reject do |appname|
150-
(is_face_app?(appname)) or (exclude_from_docs?(appname))
150+
is_face_app?(appname) or exclude_from_docs?(appname)
151151
end.sort
152152
end
153153

lib/puppet/file_serving/metadata.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class MetaStat
4747

4848
def initialize(stat, source_permissions)
4949
@stat = stat
50-
@source_permissions_ignore = (!source_permissions || source_permissions == :ignore)
50+
@source_permissions_ignore = !source_permissions || source_permissions == :ignore
5151
end
5252

5353
def owner
@@ -111,16 +111,16 @@ def collect(source_permissions = nil)
111111

112112
case stat.ftype
113113
when "file"
114-
@checksum = ("{#{@checksum_type}}") + send("#{@checksum_type}_file", real_path).to_s
114+
@checksum = "{#{@checksum_type}}" + send("#{@checksum_type}_file", real_path).to_s
115115
when "directory" # Always just timestamp the directory.
116116
@checksum_type = "ctime"
117-
@checksum = ("{#{@checksum_type}}") + send("#{@checksum_type}_file", path).to_s
117+
@checksum = "{#{@checksum_type}}" + send("#{@checksum_type}_file", path).to_s
118118
when "link"
119119
@destination = Puppet::FileSystem.readlink(real_path)
120-
@checksum = ("{#{@checksum_type}}") + send("#{@checksum_type}_file", real_path).to_s rescue nil
120+
@checksum = "{#{@checksum_type}}" + send("#{@checksum_type}_file", real_path).to_s rescue nil
121121
when "fifo", "socket"
122122
@checksum_type = "none"
123-
@checksum = ("{#{@checksum_type}}") + send("#{@checksum_type}_file", real_path).to_s
123+
@checksum = "{#{@checksum_type}}" + send("#{@checksum_type}_file", real_path).to_s
124124
else
125125
raise ArgumentError, _("Cannot manage files of type %{file_type}") % { file_type: stat.ftype }
126126
end

lib/puppet/forge.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def unpack(file, destination)
231231
end
232232

233233
def deprecated?
234-
@data['module'] && (!@data['module']['deprecated_at'].nil?)
234+
@data['module'] && !@data['module']['deprecated_at'].nil?
235235
end
236236
end
237237

lib/puppet/functions/regsubst.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def regsubst_string(target, pattern, replacement, flags = nil, encoding = nil)
9292
end
9393

9494
def regsubst_regexp(target, pattern, replacement, flags = nil)
95-
pattern = (pattern.pattern || '') if pattern.is_a?(Puppet::Pops::Types::PRegexpType)
95+
pattern = pattern.pattern || '' if pattern.is_a?(Puppet::Pops::Types::PRegexpType)
9696
inner_regsubst(target, pattern, replacement, flags == 'G' ? :gsub : :sub)
9797
end
9898

lib/puppet/indirector/catalog/compiler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def inlineable?(resource, sources)
169169
when sources.empty?
170170
# TRANSLATORS Inlining refers to adding additional metadata (in this case we are not inlining)
171171
return Puppet::Util::Profiler.profile(_("Not inlining resource without sources"), [:compiler, :static_compile_inlining, :skipped_file_metadata, :no_sources]) { false }
172-
when (!(sources.all? { |source| source =~ /^puppet:/ }))
172+
when !(sources.all? { |source| source =~ /^puppet:/ })
173173
# TRANSLATORS Inlining refers to adding additional metadata (in this case we are not inlining)
174174
return Puppet::Util::Profiler.profile(_("Not inlining unsupported source scheme"), [:compiler, :static_compile_inlining, :skipped_file_metadata, :unsupported_scheme]) { false }
175175
else

0 commit comments

Comments
 (0)