Skip to content

Commit bffcb77

Browse files
mirymwear
andauthored
chore: Implement shared RuboCop configuration (#1587)
Mostly all gems and folders contains the same `.rubocop.yml` config file. It requires mostly to touch and verify 36 files for changes. Extract common cops and settings of rubocop to `contrib/rubocop.yml` and update all other to use it. Most common Cops put in the file and remove duplications. In an effort to streamline maintenance, a common configuration file, `contrib/rubocop.yml`, has been introduced. The majority of gems and folders previously relied on individual `.rubocop.yml` files, leading to redundancy. This change involves consolidating common Cops and settings in `contrib/rubocop.yml`, thereby reducing the need for modifications across 36 files. This modification enhances consistency and eliminates duplications in the RuboCop configurations. Signed-off-by: Michael Nikitochkin <[email protected]> Co-authored-by: Matthew Wear <[email protected]>
1 parent 94832be commit bffcb77

File tree

34 files changed

+85
-339
lines changed

34 files changed

+85
-339
lines changed

Rakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace :each do
2121
foreach_gem('bundle exec rake yard')
2222
end
2323

24+
desc "Run rubocop in each gem"
2425
task :rubocop do
2526
foreach_gem('bundle exec rake rubocop')
2627
end

api/.rubocop.yml

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,7 @@
1-
AllCops:
2-
TargetRubyVersion: "3.0"
1+
inherit_from: ../contrib/rubocop.yml
32

4-
Lint/UnusedMethodArgument:
5-
Enabled: false
6-
Metrics/AbcSize:
7-
Enabled: false
8-
Metrics/LineLength:
9-
Enabled: false
10-
Metrics/MethodLength:
11-
Max: 20
12-
Metrics/ParameterLists:
13-
Enabled: false
143
Naming/FileName:
154
Exclude:
165
- "lib/opentelemetry-api.rb"
17-
Lint/MissingSuper:
18-
Enabled: false
19-
Lint/ConstantDefinitionInBlock:
20-
Exclude:
21-
- "test/**/*"
22-
Style/StringConcatenation:
23-
Exclude:
24-
- "test/**/*"
25-
Style/ModuleFunction:
26-
Enabled: false
276
Style/ExplicitBlockArgument:
287
Enabled: false

api/lib/opentelemetry/trace/trace_flags.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class << self
1818
# @param [Integer] flags 8-bit byte of bit flags
1919
# @return [TraceFlags]
2020
def from_byte(flags)
21-
flags = 0 unless flags & ~0xFF == 0 # rubocop:disable Style/NumericPredicate
21+
flags = 0 unless flags & ~0xFF == 0
2222

2323
new(flags)
2424
end

common/.rubocop.yml

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,11 @@
1-
AllCops:
2-
TargetRubyVersion: '3.0'
3-
NewCops: disable
4-
SuggestExtensions: false
1+
inherit_from: ../contrib/rubocop.yml
52

63
Bundler/OrderedGems:
74
Exclude:
85
- gemfiles/**/*
9-
Lint/UnusedMethodArgument:
10-
Enabled: false
11-
Lint/MissingSuper:
12-
Enabled: false
13-
Lint/ConstantDefinitionInBlock:
14-
Exclude:
15-
- "test/**/*"
16-
Style/StringConcatenation:
17-
Exclude:
18-
- "test/**/*"
19-
Metrics/AbcSize:
20-
Enabled: false
21-
Layout/LineLength:
22-
Enabled: false
23-
Metrics/MethodLength:
24-
Max: 20
25-
Metrics/ParameterLists:
26-
Enabled: false
276
Style/FrozenStringLiteralComment:
287
Exclude:
298
- gemfiles/**/*
30-
Style/ModuleFunction:
31-
Enabled: false
329
Style/StringLiterals:
3310
Exclude:
3411
- gemfiles/**/*

contrib/rubocop.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
AllCops:
2+
NewCops: disable
3+
SuggestExtensions: false
4+
TargetRubyVersion: "3.0"
5+
Exclude:
6+
- "vendor/**/*"
7+
8+
Layout/LineLength:
9+
Enabled: false
10+
11+
Lint/ConstantDefinitionInBlock:
12+
Exclude:
13+
- "test/**/*"
14+
Lint/MissingSuper:
15+
Enabled: false
16+
Lint/UnusedMethodArgument:
17+
Enabled: false
18+
19+
Metrics/AbcSize:
20+
Enabled: false
21+
Metrics/MethodLength:
22+
Max: 21
23+
Metrics/ParameterLists:
24+
Enabled: false
25+
26+
Style/ModuleFunction:
27+
Enabled: false
28+
Style/NumericPredicate:
29+
Enabled: false
30+
Style/StringConcatenation:
31+
Exclude:
32+
- "test/**/*"

exporter/jaeger/.rubocop.yml

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,16 @@
1+
inherit_from: ../../contrib/rubocop.yml
2+
13
AllCops:
2-
TargetRubyVersion: "3.0"
3-
NewCops: disable
4-
SuggestExtensions: false
54
Exclude:
65
- "thrift/**/*"
76
- "vendor/**/*"
87

98
Bundler/OrderedGems:
109
Exclude:
1110
- gemfiles/**/*
12-
Lint/UnusedMethodArgument:
13-
Enabled: false
14-
Lint/MissingSuper:
15-
Enabled: false
16-
Lint/ConstantDefinitionInBlock:
17-
Exclude:
18-
- "test/**/*"
19-
Style/StringConcatenation:
20-
Exclude:
21-
- "test/**/*"
22-
Metrics/AbcSize:
23-
Enabled: false
24-
Layout/LineLength:
25-
Enabled: false
26-
Metrics/MethodLength:
27-
Max: 20
28-
Metrics/ParameterLists:
29-
Enabled: false
3011
Style/FrozenStringLiteralComment:
3112
Exclude:
3213
- gemfiles/**/*
33-
Style/ModuleFunction:
34-
Enabled: false
3514
Style/StringLiterals:
3615
Exclude:
3716
- gemfiles/**/*

exporter/otlp-common/.rubocop.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
1+
inherit_from: ../../contrib/rubocop.yml
2+
13
AllCops:
2-
TargetRubyVersion: "3.0"
34
Exclude:
45
- "lib/opentelemetry/proto/**/*"
56
- "vendor/**/*"
67

7-
Lint/UnusedMethodArgument:
8-
Enabled: false
9-
Metrics/AbcSize:
10-
Enabled: false
11-
Metrics/LineLength:
8+
Metrics/CyclomaticComplexity:
129
Enabled: false
1310
Metrics/MethodLength:
1411
Enabled: false
1512
Metrics/PerceivedComplexity:
1613
Enabled: false
17-
Metrics/CyclomaticComplexity:
18-
Enabled: false
19-
Metrics/ParameterLists:
20-
Enabled: false
14+
2115
Naming/FileName:
2216
Exclude:
2317
- "lib/opentelemetry-exporter-otlp-common.rb"
24-
Style/ModuleFunction:
25-
Enabled: false
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
inherit_from: ../.rubocop.yml
22

3-
Metrics/AbcSize:
4-
Enabled: false
53
Metrics/BlockLength:
64
Enabled: false
7-
Metrics/LineLength:
8-
Enabled: false

exporter/otlp-grpc/.rubocop.yml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
1-
AllCops:
2-
TargetRubyVersion: "3.0"
1+
inherit_from: ../../contrib/rubocop.yml
32

4-
Lint/UnusedMethodArgument:
5-
Enabled: false
6-
Metrics/AbcSize:
7-
Enabled: false
8-
Metrics/LineLength:
9-
Enabled: false
10-
Metrics/MethodLength:
11-
Max: 21
12-
Metrics/ParameterLists:
13-
Enabled: false
143
Naming/FileName:
154
Exclude:
165
- "lib/opentelemetry-exporter-otlp-grpc.rb"
17-
Style/ModuleFunction:
18-
Enabled: false

exporter/otlp-grpc/test/.rubocop.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
inherit_from: ../.rubocop.yml
22

3-
Metrics/AbcSize:
4-
Enabled: false
53
Metrics/BlockLength:
64
Enabled: false
7-
Metrics/LineLength:
8-
Enabled: false
95
Style/MethodCallWithoutArgsParentheses:
106
Exclude:
117
- 'opentelemetry/exporter/otlp/grpc/exporter_test.rb'

0 commit comments

Comments
 (0)