rubocop-on-rbs 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/config/default.yml +10 -0
- data/lib/rubocop/cop/rbs/layout/empty_lines_around_body.rb +1 -1
- data/lib/rubocop/cop/rbs/lint/top_level_interface.rb +46 -0
- data/lib/rubocop/cop/rbs/lint/top_level_type_alias.rb +43 -0
- data/lib/rubocop/cop/rbs_cops.rb +2 -0
- data/lib/rubocop/rbs/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 501f65e78ff030f4d111a08793afa70a614c28715e9d9fa4caa95e24bbcc48dd
|
4
|
+
data.tar.gz: 5600ce340c99239465721d201d75881e3bcd8343787659bbf18faaaf8f51f58f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9506a4022805eeaabedd6de962bc91812f34176e40251cb902b4abaee2a5b7fc45dd962946032dcf5cedea397f88daec6d46cae9e54ccc8d9c3f35a6b9941b15
|
7
|
+
data.tar.gz: 3b0176a6d2aa9fc2a85c21445720b9571e8881d6cd742c9b1b534ca76ff5103bc340e38a417e0bf6aec32259b5818aa24872553bdff3e6e47096eba19291cc9f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [1.1.0] - 2024-10-01
|
4
|
+
|
5
|
+
* Add RBS/Layout/EmptyLinesAroundAccessModifier by @ksss in https://github.com/ksss/rubocop-on-rbs/pull/39
|
6
|
+
* Fix error when same line with `RBS/Layout/EndAlignment` by @ksss in https://github.com/ksss/rubocop-on-rbs/pull/40
|
7
|
+
|
3
8
|
## [1.0.0] - 2024-09-17
|
4
9
|
|
5
10
|
* Add RBS/Layout/EmptyLines by @ksss in https://github.com/ksss/rubocop-on-rbs/pull/35
|
data/config/default.yml
CHANGED
@@ -118,6 +118,16 @@ RBS/Lint/Syntax:
|
|
118
118
|
Description: 'Check RBS syntax'
|
119
119
|
Enabled: true
|
120
120
|
|
121
|
+
RBS/Lint/TopLevelInterface:
|
122
|
+
Description: 'Check top level interface'
|
123
|
+
Enabled: pending
|
124
|
+
VersionAdded: '1.2.0'
|
125
|
+
|
126
|
+
RBS/Lint/TopLevelTypeAlias:
|
127
|
+
Description: 'Check top level type alias'
|
128
|
+
Enabled: pending
|
129
|
+
VersionAdded: '1.2.0'
|
130
|
+
|
121
131
|
RBS/Lint/UselessAccessModifier:
|
122
132
|
AutoCorrect: contextual
|
123
133
|
Description: 'Check useless access modifier'
|
@@ -12,6 +12,7 @@ module RuboCop
|
|
12
12
|
def check(decl)
|
13
13
|
first_line = decl.location.start_line
|
14
14
|
last_line = decl.location.end_line
|
15
|
+
return if last_line == first_line
|
15
16
|
|
16
17
|
check_beginning(first_line)
|
17
18
|
check_ending(last_line)
|
@@ -29,7 +30,6 @@ module RuboCop
|
|
29
30
|
return unless line_no.positive?
|
30
31
|
return unless processed_source.lines[line_no]
|
31
32
|
return unless processed_source.lines[line_no].empty?
|
32
|
-
return unless processed_source.lines[line_no + 1]
|
33
33
|
|
34
34
|
range = source_range(processed_source.buffer, line_no + 1, 0)
|
35
35
|
message = message(MSG_EXTRA, desc)
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module RBS
|
6
|
+
module Lint
|
7
|
+
# Top-level namespaces are likely to conflict and should be avoided.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# # bad
|
11
|
+
# interface _Option
|
12
|
+
# def option: () -> untyped
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# # good
|
16
|
+
# class Foo
|
17
|
+
# interface _Option
|
18
|
+
# def option: () -> untyped
|
19
|
+
# end
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
class TopLevelInterface < RuboCop::RBS::CopBase
|
23
|
+
MSG = 'Top level interface detected.'
|
24
|
+
|
25
|
+
def on_rbs_new_investigation
|
26
|
+
@last_end = nil
|
27
|
+
end
|
28
|
+
|
29
|
+
def on_rbs_class(decl)
|
30
|
+
return unless @last_end_pos.nil? || (@last_end_pos < decl.location.end_pos)
|
31
|
+
|
32
|
+
@last_end_pos = decl.location.end_pos
|
33
|
+
end
|
34
|
+
alias on_rbs_module on_rbs_class
|
35
|
+
|
36
|
+
def on_rbs_interface(decl)
|
37
|
+
return unless @last_end_pos.nil? || (@last_end_pos < decl.location.start_pos)
|
38
|
+
|
39
|
+
range = location_to_range(decl.location)
|
40
|
+
add_offense(range)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module RBS
|
6
|
+
module Lint
|
7
|
+
# Top-level namespaces are likely to conflict and should be avoided.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# # bad
|
11
|
+
# type foo = String
|
12
|
+
#
|
13
|
+
# # good
|
14
|
+
# class Foo
|
15
|
+
# type bar = Integer
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
class TopLevelTypeAlias < RuboCop::RBS::CopBase
|
19
|
+
MSG = 'Top level type alias detected.'
|
20
|
+
|
21
|
+
def on_rbs_new_investigation
|
22
|
+
@last_end = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def on_rbs_class(decl)
|
26
|
+
return unless @last_end_pos.nil? || (@last_end_pos < decl.location.end_pos)
|
27
|
+
|
28
|
+
@last_end_pos = decl.location.end_pos
|
29
|
+
end
|
30
|
+
alias on_rbs_module on_rbs_class
|
31
|
+
alias on_rbs_interface on_rbs_class
|
32
|
+
|
33
|
+
def on_rbs_type_alias(decl)
|
34
|
+
return unless @last_end_pos.nil? || (@last_end_pos < decl.location.start_pos)
|
35
|
+
|
36
|
+
range = location_to_range(decl.location)
|
37
|
+
add_offense(range)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/rubocop/cop/rbs_cops.rb
CHANGED
@@ -25,6 +25,8 @@ require_relative 'rbs/lint/ambiguous_operator_precedence'
|
|
25
25
|
require_relative 'rbs/lint/duplicate_overload'
|
26
26
|
require_relative 'rbs/lint/literal_intersection'
|
27
27
|
require_relative 'rbs/lint/syntax'
|
28
|
+
require_relative 'rbs/lint/top_level_interface'
|
29
|
+
require_relative 'rbs/lint/top_level_type_alias'
|
28
30
|
require_relative 'rbs/lint/useless_access_modifier'
|
29
31
|
require_relative 'rbs/lint/useless_overload_type_params'
|
30
32
|
require_relative 'rbs/lint/will_syntax_error'
|
data/lib/rubocop/rbs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-on-rbs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ksss
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbs
|
@@ -87,6 +87,8 @@ files:
|
|
87
87
|
- lib/rubocop/cop/rbs/lint/duplicate_overload.rb
|
88
88
|
- lib/rubocop/cop/rbs/lint/literal_intersection.rb
|
89
89
|
- lib/rubocop/cop/rbs/lint/syntax.rb
|
90
|
+
- lib/rubocop/cop/rbs/lint/top_level_interface.rb
|
91
|
+
- lib/rubocop/cop/rbs/lint/top_level_type_alias.rb
|
90
92
|
- lib/rubocop/cop/rbs/lint/useless_access_modifier.rb
|
91
93
|
- lib/rubocop/cop/rbs/lint/useless_overload_type_params.rb
|
92
94
|
- lib/rubocop/cop/rbs/lint/will_syntax_error.rb
|
@@ -128,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
130
|
- !ruby/object:Gem::Version
|
129
131
|
version: '0'
|
130
132
|
requirements: []
|
131
|
-
rubygems_version: 3.5.
|
133
|
+
rubygems_version: 3.5.16
|
132
134
|
signing_key:
|
133
135
|
specification_version: 4
|
134
136
|
summary: RuboCop extension for RBS file.
|