Skip to content

Commit 9494a1f

Browse files
committed
[build] upgrade rubocop and only run on jruby-10
We don't need to actually run rubocop via older JRuby; just ensure compatibility with JRuby 9.3 which can be addressed via .rubocop.yml target syntax.
1 parent 2de59c7 commit 9494a1f

12 files changed

Lines changed: 34 additions & 32 deletions

.github/workflows/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ jobs:
2727
- name: Run test
2828
run: jruby -Ilib -rbundler/setup -S rake specs
2929
- name: Run RuboCop
30-
run: jruby -Ilib -rbundler/setup -S rubocop lib
30+
if: matrix.ruby-version == 'jruby-10.0' # Only run RuboCop on modern JRuby; target older jrubies via .rubocop.yml
31+
run: jruby -Ilib -rbundler/setup -S rubocop lib specs

.rubocop.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
require:
1+
plugins:
22
- rubocop-rake
33
- rubocop-performance
4+
- rubocop-minitest
45

56
AllCops:
67
TargetRubyVersion: 2.6

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ group :development do
88
gem 'rake', require: false
99
gem 'ruby-debug', '~> 0.11', require: false
1010

11-
gem 'rubocop', '~> 1.50.0', require: false
11+
gem 'rubocop', require: false
12+
gem 'rubocop-minitest', require: false
1213
gem 'rubocop-performance', require: false
1314
gem 'rubocop-rake', require: false
1415
end

lib/jar_dependencies.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def require?
9595
if @require.nil?
9696
if (require = to_boolean(REQUIRE)).nil?
9797
no_require = to_boolean(NO_REQUIRE)
98-
@require = no_require.nil? ? true : !no_require
98+
@require = no_require.nil? || !no_require
9999
else
100100
@require = require
101101
end

lib/jars/gemspec_artifacts.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def new(*args)
1212
if low == high
1313
low
1414
else
15-
super "#{low || '[0'},#{high || ')'}"
15+
super("#{low || '[0'},#{high || ')'}")
1616
end
1717
end
1818
end
@@ -26,17 +26,17 @@ def convert(arg, low = nil, high = nil)
2626
["[#{snapshot_version(val)}", "#{snapshot_version(last)}]"]
2727
elsif arg.include?('>=')
2828
val = arg.sub(/>=\s*/, '')
29-
["[#{snapshot_version(val)}", (nil || high)]
29+
["[#{snapshot_version(val)}", high]
3030
elsif arg.include?('<=')
3131
val = arg.sub(/<=\s*/, '')
32-
[(nil || low), "#{snapshot_version(val)}]"]
32+
[low, "#{snapshot_version(val)}]"]
3333
# treat '!' the same way as '>' since maven can not describe such range
3434
elsif /[!>]/.match?(arg)
3535
val = arg.sub(/[!>]\s*/, '')
36-
["(#{snapshot_version(val)}", (nil || high)]
36+
["(#{snapshot_version(val)}", high]
3737
elsif arg.include?('<')
3838
val = arg.sub(/<\s*/, '')
39-
[(nil || low), "#{snapshot_version(val)})"]
39+
[low, "#{snapshot_version(val)})"]
4040
elsif arg.include?('=')
4141
val = arg.sub(/=\s*/, '')
4242
# for prereleased version pick the maven version (no version range)
@@ -133,12 +133,12 @@ def self.new(line)
133133

134134
if /[\[()\]]/.match?(line)
135135
index = line.index(/[\[(].+$/)
136-
version = line[index..].sub(/:/, ', ')
137-
line = line[0..index - 1].strip.sub(/:$/, '')
136+
version = line[index..].sub(':', ', ')
137+
line = line[0..(index - 1)].strip.sub(/:$/, '')
138138
else
139139
index = line.index(/:[^:]+$/)
140-
version = line[index + 1..]
141-
line = line[0..index - 1].strip
140+
version = line[(index + 1)..]
141+
line = line[0..(index - 1)].strip
142142
end
143143

144144
case line.count(':')

lib/jars/gemspec_pom.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
def eval_file(file)
66
file = File.join(__dir__, file)
7-
eval(File.read(file), nil, file) # rubocop:disable Security/Eval
7+
eval(File.read(file), nil, file) # rubocop:disable Security/Eval
88
end
99

1010
eval_file('attach_jars_pom.rb')

lib/jars/lock.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def process(scope)
5757
File.read(@file).each_line do |line|
5858
next unless /:.+:/.match?(line)
5959

60-
jar = JarDetails.new(line.strip.sub(/:jar:/, ':').sub(/:$/, ': ').split(':'))
60+
jar = JarDetails.new(line.strip.sub(':jar:', ':').sub(/:$/, ': ').split(':'))
6161
case scope
6262
when :all, :test
6363
yield jar

lib/jars/lock_down.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def attach_jar_coordinates_from_bundler_dependencies(maven)
4444
Bundler.setup('default')
4545
maven.property('jars.bundler', true)
4646
cwd = File.expand_path('.')
47-
Gem.loaded_specs.each do |_name, spec|
47+
Gem.loaded_specs.each_value do |spec|
4848
# if gemspec is local then include all dependencies
4949
maven.attach_jars(spec, all_dependencies: cwd == spec.full_gem_path)
5050
end

lib/jars/output_jars_pom.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
if ENV_JAVA['jars.quiet'] != 'true'
66
model.dependencies.each do |d|
77
puts " #{d.group_id}:#{d.artifact_id}" \
8-
"#{d.classifier ? ":#{d.classifier}" : ''}" \
8+
"#{":#{d.classifier}" if d.classifier}" \
99
":#{d.version}:#{d.scope || 'compile'}"
1010
next if d.exclusions.empty?
1111

specs/classpath_spec.rb

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,22 +142,23 @@ def self.prepare(array)
142142
it 'resolves classpath_string from gemspec' do
143143
ENV_JAVA['jars.quiet'] = 'true'
144144
Dir.chdir(File.dirname(example_spec)) do
145-
_(Helper.prepare(subject.classpath_string.split(File::PATH_SEPARATOR))).must_equal Helper.prepare(example_expected)
145+
_(Helper.prepare(subject.classpath_string.split(File::PATH_SEPARATOR)))
146+
.must_equal Helper.prepare(example_expected)
146147

147148
_(Helper.prepare(subject.classpath_string(:compile).split(File::PATH_SEPARATOR)))
148-
.must_equal Helper.prepare(
149-
expected_with_bc + ['org/slf4j/slf4j-simple/1.7.7/slf4j-simple-1.7.7.jar']
150-
)
149+
.must_equal Helper.prepare(
150+
expected_with_bc + ['org/slf4j/slf4j-simple/1.7.7/slf4j-simple-1.7.7.jar']
151+
)
151152

152153
_(Helper.prepare(subject.classpath_string(:test).split(File::PATH_SEPARATOR)))
153-
.must_equal Helper.prepare(expected_with_bc + [
154-
'junit/junit/4.12/junit-4.12.jar',
155-
'org/slf4j/slf4j-simple/1.7.7/slf4j-simple-1.7.7.jar',
156-
'org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar'
157-
])
154+
.must_equal Helper.prepare(expected_with_bc + [
155+
'junit/junit/4.12/junit-4.12.jar',
156+
'org/slf4j/slf4j-simple/1.7.7/slf4j-simple-1.7.7.jar',
157+
'org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar'
158+
])
158159

159160
_(Helper.prepare(subject.classpath_string(:runtime).split(File::PATH_SEPARATOR)))
160-
.must_equal Helper.prepare(example_expected)
161+
.must_equal Helper.prepare(example_expected)
161162
end
162163
end
163164

0 commit comments

Comments
 (0)