Skip to content

Commit c64bc1d

Browse files
authored
Merge pull request #1899 from ksss/rubocop-on-rbs
Introduce rubocop-on-rbs
2 parents 4192ea1 + 79f2839 commit c64bc1d

File tree

9 files changed

+55
-18
lines changed

9 files changed

+55
-18
lines changed

.rubocop.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
require: rubocop-rubycw
1+
require:
2+
- rubocop-rubycw
3+
- rubocop-on-rbs
4+
25
AllCops:
36
TargetRubyVersion: 3.0
47
DisabledByDefault: true
@@ -9,6 +12,27 @@ Rubycw/Rubycw:
912
Exclude:
1013
- 'test/**/*_test.rb'
1114

15+
RBS:
16+
Enabled: true
17+
RBS/Layout:
18+
Enabled: true
19+
Exclude:
20+
- 'sig/**/*'
21+
- 'test/**/*'
22+
RBS/Layout/CommentIndentation:
23+
Exclude:
24+
- core/string.rbs
25+
RBS/Lint:
26+
Enabled: true
27+
Exclude:
28+
- 'sig/**/*'
29+
- 'test/**/*'
30+
RBS/Style:
31+
Enabled: false
32+
Exclude:
33+
- 'sig/**/*'
34+
- 'test/**/*'
35+
1236
Lint/DuplicateMethods:
1337
Enabled: true
1438
Include:

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ gem "test-unit"
1010
gem "rspec"
1111
gem "rubocop"
1212
gem "rubocop-rubycw"
13+
gem "rubocop-on-rbs" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1')
1314
gem "json"
1415
gem "json-schema"
1516
gem "goodcheck"

Gemfile.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ GEM
110110
unicode-display_width (>= 2.4.0, < 3.0)
111111
rubocop-ast (1.32.3)
112112
parser (>= 3.3.1.0)
113+
rubocop-on-rbs (0.6.0)
114+
rbs (~> 3.5)
115+
rubocop (~> 1.41)
116+
zlib
113117
rubocop-rubycw (0.1.6)
114118
rubocop (~> 1.0)
115119
ruby-progressbar (1.13.0)
@@ -142,6 +146,7 @@ GEM
142146
tzinfo (2.0.6)
143147
concurrent-ruby (~> 1.0)
144148
unicode-display_width (2.5.0)
149+
zlib (3.1.1)
145150

146151
PLATFORMS
147152
ruby
@@ -172,6 +177,7 @@ DEPENDENCIES
172177
rdoc
173178
rspec
174179
rubocop
180+
rubocop-on-rbs
175181
rubocop-rubycw
176182
stackprof
177183
steep (~> 1.7.1)

Rakefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,13 @@ task :raap => :compile do
110110
end
111111

112112
task :rubocop do
113-
sh "rubocop --parallel"
113+
format = if ENV["CI"]
114+
"github"
115+
else
116+
"progress"
117+
end
118+
119+
sh "rubocop --parallel --format #{format}"
114120
end
115121

116122
namespace :generate do

core/enumerable.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
529529
def entries: () -> ::Array[Elem]
530530

531531
def enum_for: (Symbol method, *untyped, **untyped) ?{ (?) -> Integer } -> Enumerator[untyped, untyped]
532-
| () ?{ () -> Integer } -> Enumerator[Elem, self]
532+
| () ?{ () -> Integer } -> Enumerator[Elem, self]
533533

534534
%a{annotate:rdoc:skip}
535535
alias to_enum enum_for

core/kernel.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ module Kernel : BasicObject
675675
| (int | _ToR rational_like, exception: bool) -> Rational?
676676
| (int | _ToR numer, ?int | _ToR denom, ?exception: true) -> Rational
677677
| (int | _ToR numer, ?int | _ToR denom, exception: bool) -> Rational?
678-
| [T] (Numeric&_RationalDiv[T] numer, Numeric denom, ?exception: bool) -> T
678+
| [T] (Numeric & _RationalDiv[T] numer, Numeric denom, ?exception: bool) -> T
679679
| [T < Numeric] (T value, 1, ?exception: bool) -> T
680680
| (untyped, ?untyped, ?exception: bool) -> Rational?
681681

core/rbs/unnamed/env_class.rbs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ module RBS
231231
#
232232
%a{annotate:rdoc:copy:ENV.fetch}
233233
def fetch: (String name) -> String
234-
| [X] (String name, X default) -> (String | X)
235-
| [X] (String name) { (String) -> X } -> (String | X)
234+
| [X] (String name, X default) -> (String | X)
235+
| [X] (String name) { (String) -> X } -> (String | X)
236236

237237
# <!--
238238
# rdoc-file=hash.c
@@ -382,7 +382,7 @@ module RBS
382382
#
383383
%a{annotate:rdoc:copy:ENV.each_pair}
384384
def each_pair: () -> ::Enumerator[[ String, String ], self]
385-
| () { ([ String, String ]) -> void } -> self
385+
| () { ([ String, String ]) -> void } -> self
386386

387387
# <!--
388388
# rdoc-file=hash.c
@@ -479,7 +479,7 @@ module RBS
479479
#
480480
%a{annotate:rdoc:copy:ENV.delete_if}
481481
def delete_if: () -> ::Enumerator[[ String, String ], self]
482-
| () { (String name, String value) -> boolish } -> self
482+
| () { (String name, String value) -> boolish } -> self
483483

484484
# <!--
485485
# rdoc-file=hash.c
@@ -501,7 +501,7 @@ module RBS
501501
#
502502
%a{annotate:rdoc:copy:ENV.keep_if}
503503
def keep_if: () -> ::Enumerator[[ String, String ], self]
504-
| () { (String name, String value) -> boolish } -> self
504+
| () { (String name, String value) -> boolish } -> self
505505

506506
# <!--
507507
# rdoc-file=hash.c
@@ -588,7 +588,7 @@ module RBS
588588
#
589589
%a{annotate:rdoc:copy:ENV.reject!}
590590
def reject!: () -> ::Enumerator[[ String, String ], self?]
591-
| () { (String name, String value) -> boolish } -> self?
591+
| () { (String name, String value) -> boolish } -> self?
592592

593593
# <!--
594594
# rdoc-file=hash.c
@@ -674,7 +674,7 @@ module RBS
674674
#
675675
%a{annotate:rdoc:copy:ENV.select!}
676676
def select!: () -> ::Enumerator[[ String, String ], self?]
677-
| () { (String name, String value) -> boolish } -> self?
677+
| () { (String name, String value) -> boolish } -> self?
678678

679679
# <!--
680680
# rdoc-file=hash.c

core/rbs/unnamed/random.rbs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,12 @@ module RBS
224224
#
225225
%a{annotate:rdoc:copy:Random::Formatter#random_number}
226226
def random_number: () -> Float
227-
| (?Float? n) -> Float
228-
| (?Integer? n) -> Integer
229-
| (?Numeric? n) -> Numeric
230-
| (?::Range[Float]? n) -> Float
231-
| (?::Range[Integer]? n) -> Integer
232-
| (?::Range[Numeric]? n) -> Numeric
227+
| (?Float? n) -> Float
228+
| (?Integer? n) -> Integer
229+
| (?Numeric? n) -> Numeric
230+
| (?::Range[Float]? n) -> Float
231+
| (?::Range[Integer]? n) -> Integer
232+
| (?::Range[Numeric]? n) -> Numeric
233233

234234
# <!--
235235
# rdoc-file=lib/random/formatter.rb

stdlib/zlib/0/deflate.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ module Zlib
154154
# SYNC_FLUSH, FULL_FLUSH and FINISH.
155155
#
156156
def flush: (?Integer flush) -> String
157-
| (?Integer flush) {(String chunk) -> nil } -> nil
157+
| (?Integer flush) { (String chunk) -> nil } -> nil
158158

159159
# <!--
160160
# rdoc-file=ext/zlib/zlib.c

0 commit comments

Comments
 (0)