Skip to content

Commit

Permalink
Merge pull request #1899 from ksss/rubocop-on-rbs
Browse files Browse the repository at this point in the history
Introduce rubocop-on-rbs
  • Loading branch information
soutaro committed Sep 13, 2024
2 parents 4192ea1 + 79f2839 commit c64bc1d
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 18 deletions.
26 changes: 25 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
require: rubocop-rubycw
require:
- rubocop-rubycw
- rubocop-on-rbs

AllCops:
TargetRubyVersion: 3.0
DisabledByDefault: true
Expand All @@ -9,6 +12,27 @@ Rubycw/Rubycw:
Exclude:
- 'test/**/*_test.rb'

RBS:
Enabled: true
RBS/Layout:
Enabled: true
Exclude:
- 'sig/**/*'
- 'test/**/*'
RBS/Layout/CommentIndentation:
Exclude:
- core/string.rbs
RBS/Lint:
Enabled: true
Exclude:
- 'sig/**/*'
- 'test/**/*'
RBS/Style:
Enabled: false
Exclude:
- 'sig/**/*'
- 'test/**/*'

Lint/DuplicateMethods:
Enabled: true
Include:
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ gem "test-unit"
gem "rspec"
gem "rubocop"
gem "rubocop-rubycw"
gem "rubocop-on-rbs" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1')
gem "json"
gem "json-schema"
gem "goodcheck"
Expand Down
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ GEM
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.3)
parser (>= 3.3.1.0)
rubocop-on-rbs (0.6.0)
rbs (~> 3.5)
rubocop (~> 1.41)
zlib
rubocop-rubycw (0.1.6)
rubocop (~> 1.0)
ruby-progressbar (1.13.0)
Expand Down Expand Up @@ -142,6 +146,7 @@ GEM
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
zlib (3.1.1)

PLATFORMS
ruby
Expand Down Expand Up @@ -172,6 +177,7 @@ DEPENDENCIES
rdoc
rspec
rubocop
rubocop-on-rbs
rubocop-rubycw
stackprof
steep (~> 1.7.1)
Expand Down
8 changes: 7 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,13 @@ task :raap => :compile do
end

task :rubocop do
sh "rubocop --parallel"
format = if ENV["CI"]
"github"
else
"progress"
end

sh "rubocop --parallel --format #{format}"
end

namespace :generate do
Expand Down
2 changes: 1 addition & 1 deletion core/enumerable.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
def entries: () -> ::Array[Elem]

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

%a{annotate:rdoc:skip}
alias to_enum enum_for
Expand Down
2 changes: 1 addition & 1 deletion core/kernel.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ module Kernel : BasicObject
| (int | _ToR rational_like, exception: bool) -> Rational?
| (int | _ToR numer, ?int | _ToR denom, ?exception: true) -> Rational
| (int | _ToR numer, ?int | _ToR denom, exception: bool) -> Rational?
| [T] (Numeric&_RationalDiv[T] numer, Numeric denom, ?exception: bool) -> T
| [T] (Numeric & _RationalDiv[T] numer, Numeric denom, ?exception: bool) -> T
| [T < Numeric] (T value, 1, ?exception: bool) -> T
| (untyped, ?untyped, ?exception: bool) -> Rational?

Expand Down
14 changes: 7 additions & 7 deletions core/rbs/unnamed/env_class.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ module RBS
#
%a{annotate:rdoc:copy:ENV.fetch}
def fetch: (String name) -> String
| [X] (String name, X default) -> (String | X)
| [X] (String name) { (String) -> X } -> (String | X)
| [X] (String name, X default) -> (String | X)
| [X] (String name) { (String) -> X } -> (String | X)

# <!--
# rdoc-file=hash.c
Expand Down Expand Up @@ -382,7 +382,7 @@ module RBS
#
%a{annotate:rdoc:copy:ENV.each_pair}
def each_pair: () -> ::Enumerator[[ String, String ], self]
| () { ([ String, String ]) -> void } -> self
| () { ([ String, String ]) -> void } -> self

# <!--
# rdoc-file=hash.c
Expand Down Expand Up @@ -479,7 +479,7 @@ module RBS
#
%a{annotate:rdoc:copy:ENV.delete_if}
def delete_if: () -> ::Enumerator[[ String, String ], self]
| () { (String name, String value) -> boolish } -> self
| () { (String name, String value) -> boolish } -> self

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

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

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

# <!--
# rdoc-file=hash.c
Expand Down
12 changes: 6 additions & 6 deletions core/rbs/unnamed/random.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,12 @@ module RBS
#
%a{annotate:rdoc:copy:Random::Formatter#random_number}
def random_number: () -> Float
| (?Float? n) -> Float
| (?Integer? n) -> Integer
| (?Numeric? n) -> Numeric
| (?::Range[Float]? n) -> Float
| (?::Range[Integer]? n) -> Integer
| (?::Range[Numeric]? n) -> Numeric
| (?Float? n) -> Float
| (?Integer? n) -> Integer
| (?Numeric? n) -> Numeric
| (?::Range[Float]? n) -> Float
| (?::Range[Integer]? n) -> Integer
| (?::Range[Numeric]? n) -> Numeric

# <!--
# rdoc-file=lib/random/formatter.rb
Expand Down
2 changes: 1 addition & 1 deletion stdlib/zlib/0/deflate.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ module Zlib
# SYNC_FLUSH, FULL_FLUSH and FINISH.
#
def flush: (?Integer flush) -> String
| (?Integer flush) {(String chunk) -> nil } -> nil
| (?Integer flush) { (String chunk) -> nil } -> nil

# <!--
# rdoc-file=ext/zlib/zlib.c
Expand Down

0 comments on commit c64bc1d

Please sign in to comment.