Skip to content

Commit 3233c7f

Browse files
ashleywillardschoblaskaperryqh
authored
Aw js/add rubocop (#14)
* Add another supported platform Co-authored-by: Joey Schoblaska <[email protected]> * Add rubocop to code teams Co-authored-by: Joey Schoblaska <[email protected]> * re-add require "set" * add type arguments for generic class Co-authored-by: Perry Hertler <[email protected]> Co-authored-by: Ashley Willard <[email protected]> --------- Co-authored-by: Joey Schoblaska <[email protected]> Co-authored-by: Perry Hertler <[email protected]>
1 parent 8ccb17c commit 3233c7f

File tree

6 files changed

+165
-13
lines changed

6 files changed

+165
-13
lines changed

.rubocop.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# The behavior of RuboCop can be controlled via the .rubocop.yml
2+
# configuration file. It makes it possible to enable/disable
3+
# certain cops (checks) and to alter their behavior if they accept
4+
# any parameters. The file can be placed either in your home
5+
# directory or in some project directory.
6+
#
7+
# RuboCop will start looking for the configuration file in the directory
8+
# where the inspected file is and continue its way up to the root directory.
9+
#
10+
# See https://docs.rubocop.org/rubocop/configuration
11+
AllCops:
12+
NewCops: enable
13+
Exclude:
14+
- vendor/bundle/**/**
15+
TargetRubyVersion: 2.6
16+
17+
Metrics/ParameterLists:
18+
Enabled: false
19+
20+
# This cop is annoying with typed configuration
21+
Style/TrivialAccessors:
22+
Enabled: false
23+
24+
# This rubocop is annoying when we use interfaces a lot
25+
Lint/UnusedMethodArgument:
26+
Enabled: false
27+
28+
Gemspec/RequireMFA:
29+
Enabled: false
30+
31+
Lint/DuplicateBranch:
32+
Enabled: false
33+
34+
# If is sometimes easier to think about than unless sometimes
35+
Style/NegatedIf:
36+
Enabled: false
37+
38+
# Disabling for now until it's clearer why we want this
39+
Style/FrozenStringLiteralComment:
40+
Enabled: false
41+
42+
# It's nice to be able to read the condition first before reading the code within the condition
43+
Style/GuardClause:
44+
Enabled: false
45+
46+
#
47+
# Leaving length metrics to human judgment for now
48+
#
49+
Metrics/ModuleLength:
50+
Enabled: false
51+
52+
Layout/LineLength:
53+
Enabled: false
54+
55+
Metrics/BlockLength:
56+
Enabled: false
57+
58+
Metrics/MethodLength:
59+
Enabled: false
60+
61+
Metrics/AbcSize:
62+
Enabled: false
63+
64+
Metrics/ClassLength:
65+
Enabled: false
66+
67+
# This doesn't feel useful
68+
Metrics/CyclomaticComplexity:
69+
Enabled: false
70+
71+
# This doesn't feel useful
72+
Metrics/PerceivedComplexity:
73+
Enabled: false
74+
75+
# It's nice to be able to read the condition first before reading the code within the condition
76+
Style/IfUnlessModifier:
77+
Enabled: false
78+
79+
# This leads to code that is not very readable at times (very long lines)
80+
Style/ConditionalAssignment:
81+
Enabled: false
82+
83+
# For now, we prefer to lean on clean method signatures as documentation. We may change this later.
84+
Style/Documentation:
85+
Enabled: false
86+
87+
# Sometimes we leave comments in empty else statements intentionally
88+
Style/EmptyElse:
89+
Enabled: false
90+
91+
# Sometimes we want to more explicitly list out a condition
92+
Style/RedundantCondition:
93+
Enabled: false
94+
95+
# This leads to code that is not very readable at times (very long lines)
96+
Layout/MultilineMethodCallIndentation:
97+
Enabled: false
98+
99+
# Blocks across lines are okay sometimes
100+
Style/BlockDelimiters:
101+
Enabled: false
102+
103+
# Sometimes we like methods like `get_packages`
104+
Naming/AccessorMethodName:
105+
Enabled: false
106+
107+
# This leads to code that is not very readable at times (very long lines)
108+
Layout/FirstArgumentIndentation:
109+
Enabled: false
110+
111+
# This leads to code that is not very readable at times (very long lines)
112+
Layout/ArgumentAlignment:
113+
Enabled: false
114+
115+
Style/AccessorGrouping:
116+
Enabled: false
117+
118+
Style/HashSyntax:
119+
Enabled: false
120+
121+
Gemspec/DevelopmentDependencies:
122+
Enabled: true
123+
EnforcedStyle: gemspec

Gemfile.lock

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,24 @@ PATH
77
GEM
88
remote: https://rubygems.org/
99
specs:
10+
ast (2.4.2)
1011
coderay (1.1.3)
1112
diff-lcs (1.4.4)
13+
json (2.6.3)
14+
language_server-protocol (3.17.0.3)
1215
method_source (1.0.0)
16+
parallel (1.23.0)
17+
parser (3.2.2.4)
18+
ast (~> 2.4.1)
19+
racc
1320
pry (0.14.1)
1421
coderay (~> 1.1)
1522
method_source (~> 1.0)
23+
racc (1.7.3)
24+
rainbow (3.1.1)
1625
rake (13.0.6)
26+
regexp_parser (2.8.2)
27+
rexml (3.2.6)
1728
rspec (3.10.0)
1829
rspec-core (~> 3.10.0)
1930
rspec-expectations (~> 3.10.0)
@@ -27,16 +38,32 @@ GEM
2738
diff-lcs (>= 1.2.0, < 2.0)
2839
rspec-support (~> 3.10.0)
2940
rspec-support (3.10.2)
30-
sorbet (0.5.9889)
31-
sorbet-static (= 0.5.9889)
41+
rubocop (1.57.2)
42+
json (~> 2.3)
43+
language_server-protocol (>= 3.17.0)
44+
parallel (~> 1.10)
45+
parser (>= 3.2.2.4)
46+
rainbow (>= 2.2.2, < 4.0)
47+
regexp_parser (>= 1.8, < 3.0)
48+
rexml (>= 3.2.5, < 4.0)
49+
rubocop-ast (>= 1.28.1, < 2.0)
50+
ruby-progressbar (~> 1.7)
51+
unicode-display_width (>= 2.4.0, < 3.0)
52+
rubocop-ast (1.30.0)
53+
parser (>= 3.2.1.0)
54+
ruby-progressbar (1.13.0)
55+
sorbet (0.5.11122)
56+
sorbet-static (= 0.5.11122)
3257
sorbet-runtime (0.5.9976)
33-
sorbet-static (0.5.9889-universal-darwin-20)
34-
sorbet-static (0.5.9889-universal-darwin-21)
35-
sorbet-static (0.5.9889-x86_64-linux)
58+
sorbet-static (0.5.11122-universal-darwin)
59+
sorbet-static (0.5.11122-x86_64-linux)
60+
unicode-display_width (2.5.0)
3661

3762
PLATFORMS
3863
arm64-darwin-20
3964
arm64-darwin-21
65+
arm64-darwin-22
66+
arm64-darwin-23
4067
x86_64-darwin-20
4168
x86_64-linux
4269

@@ -45,6 +72,7 @@ DEPENDENCIES
4572
pry
4673
rake
4774
rspec (~> 3.0)
75+
rubocop
4876
sorbet
4977

5078
BUNDLED WITH

code_teams.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ Gem::Specification.new do |spec|
2727
spec.add_development_dependency 'pry'
2828
spec.add_development_dependency 'rake'
2929
spec.add_development_dependency 'rspec', '~> 3.0'
30+
spec.add_development_dependency 'rubocop'
3031
spec.add_development_dependency 'sorbet'
3132
end

lib/code_teams.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,16 @@ def to_tag
116116
sig { params(other: Object).returns(T::Boolean) }
117117
def ==(other)
118118
if other.is_a?(CodeTeams::Team)
119-
self.name == other.name
119+
name == other.name
120120
else
121121
false
122122
end
123123
end
124124

125-
alias_method :eql?, :==
125+
alias eql? ==
126126

127127
sig { returns(Integer) }
128-
def hash # rubocop:disable Rails/Delegate
128+
def hash
129129
name.hash
130130
end
131131
end

lib/code_teams/plugin.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def self.all_plugins
2828
end
2929

3030
sig { params(teams: T::Array[Team]).returns(T::Array[String]) }
31-
def self.validation_errors(teams) # rubocop:disable Lint/UnusedMethodArgument
31+
def self.validation_errors(teams)
3232
[]
3333
end
3434

@@ -42,9 +42,9 @@ def self.missing_key_error_message(team, key)
4242
"#{team.name} is missing required key `#{key}`"
4343
end
4444

45-
sig { returns(T::Hash[T.nilable(String), T::Hash[Class, Plugin]]) }
45+
sig { returns(T::Hash[T.nilable(String), T::Hash[T.class_of(Plugin), Plugin]]) }
4646
def self.registry
47-
@registry ||= T.let(@registry, T.nilable(T::Hash[String, T::Hash[Class, Plugin]]))
47+
@registry ||= T.let(@registry, T.nilable(T::Hash[String, T::Hash[T.class_of(Plugin), Plugin]]))
4848
@registry ||= {}
4949
@registry
5050
end

spec/lib/code_teams_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
it 'registers the team file as invalid' do
5555
expect(validation_errors).to match_array(
5656
[
57-
'More than 1 definition for My Team found',
57+
'More than 1 definition for My Team found'
5858
]
5959
)
6060
end
@@ -64,7 +64,7 @@
6464
describe '==' do
6565
it 'handles nil correctly' do
6666
expect(CodeTeams.all.first == nil).to eq false # rubocop:disable Style/NilComparison
67-
expect(nil == CodeTeams.all.first).to eq false
67+
expect(CodeTeams.all.first.nil?).to eq false
6868
end
6969
end
7070
end

0 commit comments

Comments
 (0)