Skip to content

Commit 2fa6252

Browse files
committed
(PUP-11993) Style/OneLineConditional
This commit enables the Style/OneLineConditional cop and fixes 3 autocorrectable offenses.
1 parent acee715 commit 2fa6252

File tree

4 files changed

+3
-11
lines changed

4 files changed

+3
-11
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -635,14 +635,6 @@ Style/MutableConstant:
635635
Style/NumericPredicate:
636636
Enabled: false
637637

638-
# This cop supports safe auto-correction (--auto-correct).
639-
# Configuration parameters: AlwaysCorrectToMultiline.
640-
Style/OneLineConditional:
641-
Exclude:
642-
- 'lib/puppet/pops/parser/evaluating_parser.rb'
643-
- 'lib/puppet/provider/package/yum.rb'
644-
- 'lib/puppet/provider/service/openwrt.rb'
645-
646638
# Configuration parameters: AllowedMethods.
647639
# AllowedMethods: respond_to_missing?
648640
Style/OptionalBooleanParameter:

lib/puppet/pops/parser/evaluating_parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def self.quote(x)
146146
when '"'
147147
escaped << '\\"'
148148
when '\\'
149-
escaped << if c == '$' || c == 's'; p; else '\\\\'; end # don't escape \ when followed by s or $
149+
escaped << ((c == '$' || c == 's') ? p : '\\\\') # don't escape \ when followed by s or $
150150
else
151151
escaped << p
152152
end

lib/puppet/provider/package/yum.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def install
313313

314314
# Yum on el-4 and el-5 returns exit status 0 when trying to install a package it doesn't recognize;
315315
# ensure we capture output to check for errors.
316-
no_debug = if Puppet.runtime[:facter].value('os.release.major').to_i > 5 then ["-d", "0"] else [] end
316+
no_debug = Puppet.runtime[:facter].value('os.release.major').to_i > 5 ? ["-d", "0"] : []
317317
command = [command(:cmd)] + no_debug + ["-e", error_level, "-y", install_options, operation, wanted].compact
318318
output = execute(command)
319319

lib/puppet/provider/service/openwrt.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def disable
2727

2828
def enabled?
2929
# We can't define the "command" for the init script, so we call system?
30-
if system(self.initscript, 'enabled') then return :true else return :false end
30+
system(self.initscript, 'enabled') ? (return :true) : (return :false)
3131
end
3232

3333
# Purposely leave blank so we fail back to ps based status detection

0 commit comments

Comments
 (0)