Skip to content

Commit c980b5e

Browse files
committed
(CONT-784) Rubocop Fixes 10-15
- Layout/EmptyLineAfterGuardClause - Layout/HashAlignment - Layout/LineContinuationLeadingSpace - Layout/LineContinuationSpacing - Performance/StringInclude
1 parent 5618548 commit c980b5e

File tree

6 files changed

+33
-71
lines changed

6 files changed

+33
-71
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,6 @@
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

9-
# Offense count: 1
10-
# This cop supports safe autocorrection (--autocorrect).
11-
Layout/EmptyLineAfterGuardClause:
12-
Exclude:
13-
- 'spec/unit/facter/java_default_home_spec.rb'
14-
15-
# Offense count: 4
16-
# This cop supports safe autocorrection (--autocorrect).
17-
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
18-
# SupportedHashRocketStyles: key, separator, table
19-
# SupportedColonStyles: key, separator, table
20-
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
21-
Layout/HashAlignment:
22-
Exclude:
23-
- 'spec/classes/java_spec.rb'
24-
25-
# Offense count: 12
26-
# This cop supports safe autocorrection (--autocorrect).
27-
# Configuration parameters: EnforcedStyle.
28-
# SupportedStyles: leading, trailing
29-
Layout/LineContinuationLeadingSpace:
30-
Exclude:
31-
- 'spec/acceptance/install_spec.rb'
32-
33-
# Offense count: 27
34-
# This cop supports safe autocorrection (--autocorrect).
35-
# Configuration parameters: AutoCorrect, EnforcedStyle.
36-
# SupportedStyles: space, no_space
37-
Layout/LineContinuationSpacing:
38-
Exclude:
39-
- 'spec/acceptance/install_spec.rb'
40-
- 'spec/unit/facter/java_version_spec.rb'
41-
429
# Offense count: 12
4310
# Configuration parameters: ForbiddenDelimiters.
4411
# ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$))
@@ -49,12 +16,6 @@ Naming/HeredocDelimiterNaming:
4916
- 'spec/defines/adoptium_spec.rb'
5017
- 'spec/defines/sap_spec.rb'
5118

52-
# Offense count: 1
53-
# This cop supports unsafe autocorrection (--autocorrect-all).
54-
Performance/StringInclude:
55-
Exclude:
56-
- 'lib/facter/java_default_home.rb'
57-
5819
# Offense count: 8
5920
# Configuration parameters: Prefixes, AllowedPatterns.
6021
# Prefixes: when, with, without

lib/facter/java_default_home.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
nil
2222
else
2323
java_path = File.realpath(java_bin)
24-
java_default_home = if %r{/jre/}.match?(java_path)
24+
java_default_home = if java_path.include?(%r{jre})
2525
File.dirname(File.dirname(File.dirname(java_path)))
2626
else
2727
File.dirname(File.dirname(java_path))

spec/acceptance/install_spec.rb

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,45 @@
33
require 'spec_helper_acceptance'
44
require 'pry'
55

6-
java_class_jre = "class { 'java':\n"\
7-
" distribution => 'jre',\n"\
6+
java_class_jre = "class { 'java':\n " \
7+
"distribution => 'jre',\n" \
88
'}'
99

1010
java_class = "class { 'java': }"
1111

12-
_sources = "file_line { 'non-free source':\n"\
13-
" path => '/etc/apt/sources.list',\n"\
14-
" match => \"deb http://osmirror.delivery.puppetlabs.net/debian/ ${::lsbdistcodename} main\",\n"\
15-
" line => \"deb http://osmirror.delivery.puppetlabs.net/debian/ ${::lsbdistcodename} main non-free\",\n"\
12+
_sources = "file_line { 'non-free source':\n " \
13+
"path => '/etc/apt/sources.list',\n " \
14+
"match => \"deb http://osmirror.delivery.puppetlabs.net/debian/ ${::lsbdistcodename} main\",\n " \
15+
"line => \"deb http://osmirror.delivery.puppetlabs.net/debian/ ${::lsbdistcodename} main non-free\",\n" \
1616
'}'
1717

18-
_sun_jre = "class { 'java':\n"\
19-
" distribution => 'sun-jre',\n"\
18+
_sun_jre = "class { 'java':\n " \
19+
"distribution => 'sun-jre',\n" \
2020
'}'
2121

22-
_sun_jdk = "class { 'java':\n"\
23-
" distribution => 'sun-jdk',\n"\
22+
_sun_jdk = "class { 'java':\n " \
23+
"distribution => 'sun-jdk',\n" \
2424
'}'
2525

26-
blank_version = "class { 'java':\n"\
27-
" version => '',\n"\
26+
blank_version = "class { 'java':\n " \
27+
"version => '',\n" \
2828
'}'
2929

30-
incorrect_distro = "class { 'java':\n"\
31-
" distribution => 'xyz',\n"\
30+
incorrect_distro = "class { 'java':\n " \
31+
"distribution => 'xyz',\n" \
3232
'}'
3333

34-
blank_distro = "class { 'java':\n"\
35-
" distribution => '',\n"\
34+
blank_distro = "class { 'java':\n " \
35+
"distribution => '',\n" \
3636
'}'
3737

38-
incorrect_package = "class { 'java':\n"\
39-
" package => 'xyz',\n"\
38+
incorrect_package = "class { 'java':\n " \
39+
"package => 'xyz',\n" \
4040
'}'
4141

42-
bogus_alternative = "class { 'java':\n"\
43-
" java_alternative => 'whatever',\n"\
44-
" java_alternative_path => '/whatever',\n"\
42+
bogus_alternative = "class { 'java':\n " \
43+
"java_alternative => 'whatever',\n " \
44+
"java_alternative_path => '/whatever',\n" \
4545
'}'
4646

4747
# Oracle installs are disabled by default, because the links to valid oracle installations

spec/classes/java_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@
163163
context 'when all params provided' do
164164
let(:params) do
165165
{
166-
'distribution' => 'custom',
167-
'package' => 'custom_jdk',
168-
'java_alternative' => 'java-custom_jdk',
166+
'distribution' => 'custom',
167+
'package' => 'custom_jdk',
168+
'java_alternative' => 'java-custom_jdk',
169169
'java_alternative_path' => '/opt/custom_jdk/bin/java',
170-
'java_home' => '/opt/custom_jdk'
170+
'java_home' => '/opt/custom_jdk'
171171
}
172172
end
173173

spec/unit/facter/java_default_home_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
def unlink_and_delete(filename)
1111
File.unlink(filename) if File.symlink?(filename)
1212
return unless File.exist?(filename)
13+
1314
File.delete(filename)
1415
end
1516

spec/unit/facter/java_version_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
require 'spec_helper'
44

5-
openjdk_7_output = "Picked up JAVA_TOOL_OPTIONS: -Djava.net.preferIPv4Stack=true\n"\
6-
"openjdk version \"1.7.0_71\"\n"\
7-
"OpenJDK Runtime Environment (build 1.7.0_71-b14)\n"\
5+
openjdk_7_output = "Picked up JAVA_TOOL_OPTIONS: -Djava.net.preferIPv4Stack=true\n" \
6+
"openjdk version \"1.7.0_71\"\n" \
7+
"OpenJDK Runtime Environment (build 1.7.0_71-b14)\n" \
88
"OpenJDK 64-Bit Server VM (build 24.71-b01, mixed mode)\n"
99

10-
jdk_7_hotspot_output = "Picked up JAVA_TOOL_OPTIONS: -Djava.net.preferIPv4Stack=true\n"\
11-
"java version \"1.7.0_71\"\n"\
12-
"Java(TM) SE Runtime Environment (build 1.7.0_71-b14)\n"\
10+
jdk_7_hotspot_output = "Picked up JAVA_TOOL_OPTIONS: -Djava.net.preferIPv4Stack=true\n" \
11+
"java version \"1.7.0_71\"\n" \
12+
"Java(TM) SE Runtime Environment (build 1.7.0_71-b14)\n" \
1313
"Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)\n"
1414

1515
describe 'java_version' do

0 commit comments

Comments
 (0)