Skip to content

Commit 9400561

Browse files
committed
(PUP-11993) Style/ParenthesesAroundCondition
This commit enables the Style/ParenthesesAroundCondition cop and fixes 112 autocorrectable offenses.
1 parent a18eecf commit 9400561

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+112
-117
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -640,11 +640,6 @@ Style/NumericPredicate:
640640
Style/OptionalBooleanParameter:
641641
Enabled: false
642642

643-
# This cop supports safe auto-correction (--auto-correct).
644-
# Configuration parameters: AllowSafeAssignment, AllowInMultilineConditions.
645-
Style/ParenthesesAroundCondition:
646-
Enabled: false
647-
648643
# This cop supports safe auto-correction (--auto-correct).
649644
# Configuration parameters: PreferredDelimiters.
650645
Style/PercentLiteralDelimiters:

ext/windows/service/daemon.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def service_main(*argsv)
3636

3737
@LOG_TO_FILE = (argsv.index('--logtofile') ? true : false)
3838

39-
if (@LOG_TO_FILE)
39+
if @LOG_TO_FILE
4040
FileUtils.mkdir_p(File.dirname(LOG_FILE))
4141
args = args.gsub("--logtofile", "")
4242
end
@@ -131,7 +131,7 @@ def log_exception(e)
131131

132132
def log(msg, level)
133133
if LEVELS.index(level) >= @loglevel
134-
if (@LOG_TO_FILE)
134+
if @LOG_TO_FILE
135135
# without this change its possible that we get Encoding errors trying to write UTF-8 messages in current codepage
136136
File.open(LOG_FILE, 'a:UTF-8') { |f| f.puts("#{Time.now} Puppet (#{level}): #{msg}") }
137137
end
@@ -153,7 +153,7 @@ def report_windows_event(type, id, message)
153153
rescue Exception
154154
# Ignore all errors
155155
ensure
156-
unless (eventlog.nil?)
156+
unless eventlog.nil?
157157
eventlog.close
158158
end
159159
end

lib/puppet/agent/disabler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def enable
2626
def disable(msg = nil)
2727
data = {}
2828
Puppet.notice _("Disabling Puppet.")
29-
unless (msg.nil?)
29+
unless msg.nil?
3030
data[DISABLED_MESSAGE_JSON_KEY] = msg
3131
end
3232
disable_lockfile.lock(data)

lib/puppet/application.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def controlled_run(&block)
180180
def option(*options, &block)
181181
long = options.find { |opt| opt =~ /^--/ }.gsub(/^--(?:\[no-\])?([^ =]+).*$/, '\1').tr('-', '_')
182182
fname = "handle_#{long}".intern
183-
if (block_given?)
183+
if block_given?
184184
define_method(fname, &block)
185185
else
186186
define_method(fname) do |value|
@@ -242,7 +242,7 @@ def find(application_name)
242242
#### eventually we need to issue a deprecation warning here,
243243
#### and then get rid of this stanza in a subsequent release.
244244
################################################################
245-
if (clazz.nil?)
245+
if clazz.nil?
246246
class_name = application_name.capitalize
247247
clazz = try_load_class(class_name)
248248
end

lib/puppet/application/face_base.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def parse_options
8888
# when we get there. --daniel 2011-04-04
8989
if option.takes_argument? and !item.index('=')
9090
index += 1 unless
91-
(option.optional_argument? and command_line.args[index + 1] =~ /^-/)
91+
option.optional_argument? and command_line.args[index + 1] =~ /^-/
9292
end
9393
else
9494
option = find_global_settings_argument(item)
@@ -103,7 +103,7 @@ def parse_options
103103
else
104104
option = find_application_argument(item)
105105
if option
106-
index += 1 if (option[:argument] and !(option[:optional]))
106+
index += 1 if option[:argument] and !(option[:optional])
107107
else
108108
raise OptionParser::InvalidOption.new(item.sub(/=.*$/, ''))
109109
end

lib/puppet/configurer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ def run_internal(options)
390390
configured_environment = Puppet[:environment] if Puppet.settings.set_by_config?(:environment)
391391

392392
# We only need to find out the environment to run in if we don't already have a catalog
393-
unless (cached_catalog || options[:catalog] || Puppet.settings.set_by_cli?(:environment) || Puppet[:strict_environment_mode])
393+
unless cached_catalog || options[:catalog] || Puppet.settings.set_by_cli?(:environment) || Puppet[:strict_environment_mode]
394394
Puppet.debug(_("Environment not passed via CLI and no catalog was given, attempting to find out the last server-specified environment"))
395395
initial_environment, loaded_last_environment = last_server_specified_environment
396396

lib/puppet/error.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def initialize(message, file = nil, line = nil, pos = nil, original = nil)
2828

2929
super(message, original)
3030

31-
@file = file unless (file.is_a?(String) && file.empty?)
31+
@file = file unless file.is_a?(String) && file.empty?
3232
@line = line
3333
@pos = pos
3434

@@ -41,7 +41,7 @@ def initialize(message, file = nil, line = nil, pos = nil, original = nil)
4141

4242
def to_s
4343
msg = super
44-
@file = nil if (@file.is_a?(String) && @file.empty?)
44+
@file = nil if @file.is_a?(String) && @file.empty?
4545
msg += Puppet::Util::Errors.error_location_with_space(@file, @line, @pos)
4646
msg
4747
end

lib/puppet/face/epp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ def get_values(compiler, options)
417417
rescue => e
418418
Puppet.err(_("Could not load --values_file %{error}") % { error: e.message })
419419
end
420-
unless (template_values.nil? || template_values.is_a?(Hash))
420+
unless template_values.nil? || template_values.is_a?(Hash)
421421
Puppet.err(_("--values_file option must evaluate to a Hash or undef/nil, got: '%{template_class}'") % { template_class: template_values.class })
422422
end
423423
end

lib/puppet/face/help.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ def all_application_summaries
160160
available_application_names_special_sort().inject([]) do |result, appname|
161161
next result if exclude_from_docs?(appname)
162162

163-
if (appname == COMMON || appname == SPECIALIZED || appname == BLANK)
163+
if appname == COMMON || appname == SPECIALIZED || appname == BLANK
164164
result << appname
165-
elsif (is_face_app?(appname))
165+
elsif is_face_app?(appname)
166166
begin
167167
face = Puppet::Face[appname, :current]
168168
# Add deprecation message to summary if the face is deprecated

lib/puppet/face/module/list.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ def list_build_node(mod, parent, params)
259259
str << ' ' + colorize(:red, _('invalid'))
260260
elsif parent.respond_to?(:forge_name)
261261
unmet_parent = @unmet_deps[:version_mismatch][mod.forge_name][:parent]
262-
if (unmet_parent[:name] == parent.forge_name &&
263-
unmet_parent[:version] == "v#{parent.version}")
262+
if unmet_parent[:name] == parent.forge_name &&
263+
unmet_parent[:version] == "v#{parent.version}"
264264
str << ' ' + colorize(:red, _('invalid'))
265265
end
266266
end

0 commit comments

Comments
 (0)