Skip to content

Commit 86e443a

Browse files
chore: add Rubocop additional linter (#1836)
* feat: additional rubocop linter * lint * add rubocop performance --------- Co-authored-by: Kayla Reopelle <87386821+kaylareopelle@users.noreply.github.com>
1 parent b2cac91 commit 86e443a

File tree

62 files changed

+268
-146
lines changed

Some content is hidden

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

62 files changed

+268
-146
lines changed

api/Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ source 'https://rubygems.org'
88

99
gemspec
1010

11+
eval_gemfile '../contrib/Gemfile.shared'
12+
1113
group :test, :development do
1214
gem 'opentelemetry-test-helpers', path: '../test_helpers'
1315
end

api/Rakefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ YARD::Rake::YardocTask.new do |t|
2121
t.stats_options = ['--list-undoc']
2222
end
2323

24-
if RUBY_ENGINE == 'truffleruby'
25-
task default: %i[test]
26-
else
27-
task default: %i[test rubocop yard]
28-
end
24+
default_tasks =
25+
if RUBY_ENGINE == 'truffleruby'
26+
%i[test]
27+
else
28+
%i[test rubocop yard]
29+
end
30+
31+
task default: default_tasks

api/test/opentelemetry/trace/propagation/trace_context/trace_parent_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
value = '00-0000000000000000000000000000000a-000000000000000a-ff'
8181
assert TraceParent.from_string(value).sampled?
8282
value = '00-0000000000000000000000000000000a-000000000000000a-04'
83-
assert !TraceParent.from_string(value).sampled?
83+
refute TraceParent.from_string(value).sampled?
8484
end
8585

8686
it 'must have a trace id of 16 hex bytes' do

api/test/opentelemetry/trace/tracestate_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
_(tracestate.to_h).must_equal('the-good-key' => ' the-good-value', '0x_the-vendor/key@my*v3nd0r' => 'another-great-value')
7676
end
7777
it 'will not exceed 32 members' do
78-
tracestate = OpenTelemetry::Trace::Tracestate.from_hash(33.times.collect { |n| [n.to_s, n.to_s] }.to_h)
78+
tracestate = OpenTelemetry::Trace::Tracestate.from_hash(Array.new(33) { |n| [n.to_s, n.to_s] }.to_h)
7979
_(tracestate.to_h.size).must_be :<=, 32
8080
end
8181
end
@@ -92,7 +92,7 @@
9292

9393
describe '#set_value' do
9494
it 'will not exceed 32 members' do
95-
tracestate = OpenTelemetry::Trace::Tracestate.from_hash(31.times.collect { |n| [n.to_s, n.to_s] }.to_h)
95+
tracestate = OpenTelemetry::Trace::Tracestate.from_hash(Array.new(31) { |n| [n.to_s, n.to_s] }.to_h)
9696
tracestate = tracestate.set_value('a', 'a').set_value('b', 'b')
9797
_(tracestate.to_h.size).must_be :<=, 32
9898
end

common/Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ source 'https://rubygems.org'
88

99
gemspec
1010

11+
eval_gemfile '../contrib/Gemfile.shared'
12+
1113
group :development, :test do
1214
# Use the opentelemetry-api gem from source
1315
gem 'opentelemetry-api', path: '../api'

common/Rakefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ YARD::Rake::YardocTask.new do |t|
2222
t.stats_options = ['--list-undoc']
2323
end
2424

25-
if RUBY_ENGINE == 'truffleruby'
26-
task default: %i[test]
27-
else
28-
task default: %i[test rubocop yard]
29-
end
25+
default_tasks =
26+
if RUBY_ENGINE == 'truffleruby'
27+
%i[test]
28+
else
29+
%i[test rubocop yard]
30+
end
31+
32+
task default: default_tasks

common/test/opentelemetry/common/utilities_test.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ def shutdown(timeout: nil); end
1919

2020
describe '#untraced?' do
2121
it 'returns true within an untraced block' do
22-
assert_equal(true, common_utils.untraced { common_utils.untraced? })
22+
assert(common_utils.untraced { common_utils.untraced? })
2323
end
2424

2525
it 'returns false outside an untraced block' do
2626
common_utils.untraced {}
27-
assert_equal(false, common_utils.untraced?)
27+
refute(common_utils.untraced?)
2828
end
2929

3030
it 'supports non block format' do
3131
token = OpenTelemetry::Context.attach(common_utils.untraced)
32-
assert_equal(true, common_utils.untraced?)
32+
assert(common_utils.untraced?)
3333
OpenTelemetry::Context.detach(token)
34-
assert_equal(false, common_utils.untraced?)
34+
refute(common_utils.untraced?)
3535
end
3636
end
3737

@@ -48,7 +48,7 @@ def shutdown(timeout: nil); end
4848
end
4949

5050
it 'with invalid conversion' do
51-
time_bomb = "\xC2".dup.force_encoding(::Encoding::ASCII_8BIT)
51+
time_bomb = (+"\xC2").force_encoding(::Encoding::ASCII_8BIT)
5252

5353
# making sure this is indeed a problem
5454
assert_raises(Encoding::UndefinedConversionError) do
@@ -62,7 +62,7 @@ def shutdown(timeout: nil); end
6262
end
6363

6464
it 'with binary data' do
65-
byte_array = "keep what\xC2 is valid".dup.force_encoding(::Encoding::ASCII_8BIT)
65+
byte_array = (+"keep what\xC2 is valid").force_encoding(::Encoding::ASCII_8BIT)
6666

6767
assert_equal('keep what is valid', common_utils.utf8_encode(byte_array, binary: true))
6868
end

contrib/Gemfile.shared

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
gem 'rubocop-rspec', '~> 3.5', require: false
2+
gem 'rubocop-rake', '~> 0.7.1', require: false
3+
gem 'rubocop-minitest', '~> 0.38.0', require: false
4+
gem 'rubocop-performance', '~> 1.25', require: false

contrib/rubocop.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
plugins:
2+
- rubocop-minitest
3+
- rubocop-rspec
4+
- rubocop-rake
5+
- rubocop-performance
6+
17
AllCops:
28
NewCops: disable
39
SuggestExtensions: false

exporter/jaeger/Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ source 'https://rubygems.org'
88

99
gemspec
1010

11+
eval_gemfile '../../contrib/Gemfile.shared'
12+
1113
group :test, :development do
1214
gem 'opentelemetry-api', path: '../../api'
1315
gem 'opentelemetry-common', path: '../../common'

0 commit comments

Comments
 (0)