rubocop-sorbet 0.3.6 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +2 -0
- data/.github/probots.yml +1 -1
- data/.github/stale.yml +20 -0
- data/.gitignore +0 -2
- data/.rspec +3 -0
- data/.rubocop.yml +2 -12
- data/.travis.yml +3 -1
- data/Gemfile +6 -7
- data/Gemfile.lock +27 -42
- data/README.md +64 -6
- data/Rakefile +34 -5
- data/config/default.yml +124 -2
- data/lib/rubocop-sorbet.rb +9 -1
- data/lib/rubocop/cop/sorbet/binding_constants_without_type_alias.rb +24 -1
- data/lib/rubocop/cop/sorbet/forbid_include_const_literal.rb +0 -40
- data/lib/rubocop/cop/sorbet/forbid_superclass_const_literal.rb +0 -17
- data/lib/rubocop/cop/sorbet/forbid_untyped_struct_props.rb +58 -0
- data/lib/rubocop/cop/sorbet/sigils/enforce_sigil_order.rb +11 -1
- data/lib/rubocop/cop/sorbet/sigils/valid_sigil.rb +6 -1
- data/lib/rubocop/cop/sorbet/signatures/parameters_ordering_in_signature.rb +14 -6
- data/lib/rubocop/cop/sorbet/signatures/signature_build_order.rb +13 -3
- data/lib/rubocop/cop/sorbet_cops.rb +22 -0
- data/lib/rubocop/sorbet.rb +15 -0
- data/lib/rubocop/sorbet/inject.rb +20 -0
- data/lib/rubocop/sorbet/version.rb +6 -0
- data/manual/cops.md +29 -0
- data/manual/cops_sorbet.md +340 -0
- data/rubocop-sorbet.gemspec +18 -18
- data/service.yml +1 -1
- data/tasks/cops_documentation.rake +317 -0
- metadata +23 -12
- data/lib/rubocop_sorbet.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0df763a5f1ab8de8024c732f5e3fae7d31d21e13c807fceca5c0d8c674e52d46
|
4
|
+
data.tar.gz: 36fb28afefdb665eb471bb536be012b5123efe5e19ef1ddf61415c21a6aa5892
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80f5462984070d3194ad111484b5a4f40905b9ba65ab55f95b050915a8df7fa2c2e54d30a7771738f7bb5e9c26dac8568c36a90c3e854dabb14240b255759c64
|
7
|
+
data.tar.gz: 66ed0ca23fa3b76a372fdae99273af7e037e3f0de5b437fc8a4d35ad024da31d0cd174c0afb12c0176c8b111d2b73be7be9960611f9176d58d46825e5c702015
|
data/.github/CODEOWNERS
ADDED
data/.github/probots.yml
CHANGED
data/.github/stale.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Number of days of inactivity before an issue becomes stale
|
2
|
+
daysUntilStale: 30
|
3
|
+
# Number of days of inactivity before a stale issue is closed
|
4
|
+
daysUntilClose: 7
|
5
|
+
# Issues with these labels will never be considered stale
|
6
|
+
exemptLabels:
|
7
|
+
- pinned
|
8
|
+
- security
|
9
|
+
# Label to use when marking an issue as stale
|
10
|
+
staleLabel: stale
|
11
|
+
# Comment to post when marking an issue as stale. Set to `false` to disable
|
12
|
+
markComment: >
|
13
|
+
This PR has been automatically marked as stale because it has not had
|
14
|
+
recent activity. It will be closed if no further activity occurs. Thank you
|
15
|
+
for your contributions.
|
16
|
+
# Comment to post when closing a stale issue. Set to `false` to disable
|
17
|
+
closeComment: false
|
18
|
+
#
|
19
|
+
only: pulls
|
20
|
+
#
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.rubocop.yml
CHANGED
@@ -1,23 +1,13 @@
|
|
1
1
|
# This file strictly follows the rules defined in the Ruby style guide:
|
2
2
|
# http://shopify.github.io/ruby-style-guide/
|
3
|
-
|
4
|
-
-
|
3
|
+
inherit_gem:
|
4
|
+
rubocop-shopify: rubocop.yml
|
5
5
|
|
6
6
|
AllCops:
|
7
7
|
TargetRubyVersion: 2.5
|
8
8
|
Exclude:
|
9
9
|
- vendor/**/*
|
10
10
|
|
11
|
-
Naming/AccessorMethodName:
|
12
|
-
Enabled: false
|
13
|
-
|
14
|
-
require:
|
15
|
-
- rubocop-sorbet
|
16
|
-
|
17
11
|
Naming/FileName:
|
18
12
|
Exclude:
|
19
13
|
- lib/rubocop-sorbet.rb
|
20
|
-
|
21
|
-
Lint/HandleExceptions:
|
22
|
-
Exclude:
|
23
|
-
- Rakefile
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source('https://rubygems.org')
|
4
|
-
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
5
|
-
|
6
|
-
group(:deployment) do
|
7
|
-
gem('package_cloud', '~> 0.3.05')
|
8
|
-
end
|
2
|
+
source "https://rubygems.org"
|
9
3
|
|
10
4
|
# Specify your gem's dependencies in rubocop-sorbet.gemspec
|
11
5
|
gemspec
|
6
|
+
|
7
|
+
gem "rake", ">= 12.3.3"
|
8
|
+
gem "rspec"
|
9
|
+
gem "rubocop-shopify", require: false
|
10
|
+
gem "yard", "~> 0.9"
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rubocop-sorbet (0.
|
4
|
+
rubocop-sorbet (0.5.1)
|
5
|
+
rubocop
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
@@ -15,38 +16,18 @@ GEM
|
|
15
16
|
adamantium (~> 0.2.0)
|
16
17
|
equalizer (~> 0.0.9)
|
17
18
|
diff-lcs (1.3)
|
18
|
-
domain_name (0.5.20190701)
|
19
|
-
unf (>= 0.0.5, < 1.0.0)
|
20
19
|
equalizer (0.0.11)
|
21
|
-
highline (1.6.20)
|
22
|
-
http-cookie (1.0.3)
|
23
|
-
domain_name (~> 0.5)
|
24
20
|
ice_nine (0.11.2)
|
25
|
-
jaro_winkler (1.5.3)
|
26
|
-
json_pure (1.8.1)
|
27
21
|
memoizable (0.4.2)
|
28
22
|
thread_safe (~> 0.3, >= 0.3.1)
|
29
|
-
|
30
|
-
|
31
|
-
mime-types-data (3.2019.0331)
|
32
|
-
netrc (0.11.0)
|
33
|
-
package_cloud (0.3.05)
|
34
|
-
highline (= 1.6.20)
|
35
|
-
json_pure (= 1.8.1)
|
36
|
-
rainbow (= 2.2.2)
|
37
|
-
rest-client (~> 2.0)
|
38
|
-
thor (~> 0.18)
|
39
|
-
parallel (1.17.0)
|
40
|
-
parser (2.6.3.0)
|
23
|
+
parallel (1.19.1)
|
24
|
+
parser (2.7.1.3)
|
41
25
|
ast (~> 2.4.0)
|
42
26
|
procto (0.0.3)
|
43
|
-
rainbow (
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
http-cookie (>= 1.0.2, < 2.0)
|
48
|
-
mime-types (>= 1.16, < 4.0)
|
49
|
-
netrc (~> 0.8)
|
27
|
+
rainbow (3.0.0)
|
28
|
+
rake (13.0.1)
|
29
|
+
regexp_parser (1.7.0)
|
30
|
+
rexml (3.2.4)
|
50
31
|
rspec (3.8.0)
|
51
32
|
rspec-core (~> 3.8.0)
|
52
33
|
rspec-expectations (~> 3.8.0)
|
@@ -60,38 +41,42 @@ GEM
|
|
60
41
|
diff-lcs (>= 1.2.0, < 2.0)
|
61
42
|
rspec-support (~> 3.8.0)
|
62
43
|
rspec-support (3.8.2)
|
63
|
-
rubocop (0.
|
64
|
-
jaro_winkler (~> 1.5.1)
|
44
|
+
rubocop (0.85.0)
|
65
45
|
parallel (~> 1.10)
|
66
|
-
parser (>= 2.
|
46
|
+
parser (>= 2.7.0.1)
|
67
47
|
rainbow (>= 2.2.2, < 4.0)
|
48
|
+
regexp_parser (>= 1.7)
|
49
|
+
rexml
|
50
|
+
rubocop-ast (>= 0.0.3)
|
68
51
|
ruby-progressbar (~> 1.7)
|
69
|
-
unicode-display_width (>= 1.4.0, <
|
52
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
53
|
+
rubocop-ast (0.0.3)
|
54
|
+
parser (>= 2.7.0.1)
|
55
|
+
rubocop-shopify (1.0.3)
|
56
|
+
rubocop (~> 0.85.0)
|
70
57
|
ruby-progressbar (1.10.1)
|
71
|
-
thor (0.20.3)
|
72
58
|
thread_safe (0.3.6)
|
73
|
-
|
74
|
-
|
75
|
-
unf_ext (0.0.7.6)
|
76
|
-
unicode-display_width (1.6.0)
|
77
|
-
unparser (0.4.5)
|
59
|
+
unicode-display_width (1.7.0)
|
60
|
+
unparser (0.4.7)
|
78
61
|
abstract_type (~> 0.0.7)
|
79
62
|
adamantium (~> 0.2.0)
|
80
63
|
concord (~> 0.1.5)
|
81
64
|
diff-lcs (~> 1.3)
|
82
65
|
equalizer (~> 0.0.9)
|
83
|
-
parser (
|
66
|
+
parser (>= 2.6.5)
|
84
67
|
procto (~> 0.0.2)
|
68
|
+
yard (0.9.25)
|
85
69
|
|
86
70
|
PLATFORMS
|
87
71
|
ruby
|
88
72
|
|
89
73
|
DEPENDENCIES
|
90
|
-
|
91
|
-
rspec
|
92
|
-
rubocop
|
74
|
+
rake (>= 12.3.3)
|
75
|
+
rspec
|
76
|
+
rubocop-shopify
|
93
77
|
rubocop-sorbet!
|
94
|
-
unparser
|
78
|
+
unparser
|
79
|
+
yard (~> 0.9)
|
95
80
|
|
96
81
|
BUNDLED WITH
|
97
82
|
1.17.3
|
data/README.md
CHANGED
@@ -6,29 +6,87 @@ A collection of Rubocop rules for Sorbet.
|
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
|
-
|
9
|
+
Just install the `rubocop-sorbet` gem
|
10
|
+
|
11
|
+
```sh
|
12
|
+
gem install rubocop-sorbet
|
13
|
+
```
|
14
|
+
or, if you use `Bundler`, add this line your application's `Gemfile`:
|
10
15
|
|
11
16
|
```ruby
|
12
|
-
gem 'rubocop-sorbet'
|
17
|
+
gem 'rubocop-sorbet', require: false
|
13
18
|
```
|
14
19
|
|
15
|
-
|
20
|
+
## Usage
|
16
21
|
|
17
|
-
|
22
|
+
You need to tell RuboCop to load the Sorbet extension. There are three ways to do this:
|
18
23
|
|
19
|
-
|
24
|
+
### RuboCop configuration file
|
25
|
+
|
26
|
+
Put this into your `.rubocop.yml`:
|
27
|
+
|
28
|
+
```yaml
|
29
|
+
require: rubocop-sorbet
|
30
|
+
```
|
20
31
|
|
21
|
-
|
32
|
+
Alternatively, use the following array notation when specifying multiple extensions:
|
22
33
|
|
23
34
|
```yaml
|
24
35
|
require:
|
36
|
+
- rubocop-other-extension
|
25
37
|
- rubocop-sorbet
|
26
38
|
```
|
27
39
|
|
40
|
+
Now you can run `rubocop` and it will automatically load the RuboCop Sorbet cops together with the standard cops.
|
41
|
+
|
42
|
+
### Command line
|
43
|
+
|
44
|
+
```sh
|
45
|
+
rubocop --require rubocop-sorbet
|
46
|
+
```
|
47
|
+
|
48
|
+
### Rake task
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
RuboCop::RakeTask.new do |task|
|
52
|
+
task.requires << 'rubocop-sorbet'
|
53
|
+
end
|
54
|
+
```
|
55
|
+
|
56
|
+
## The Cops
|
57
|
+
All cops are located under [`lib/rubocop/cop/sorbet`](lib/rubocop/cop/sorbet), and contain examples/documentation.
|
58
|
+
|
59
|
+
In your `.rubocop.yml`, you may treat the Sorbet cops just like any other cop. For example:
|
60
|
+
|
61
|
+
```yaml
|
62
|
+
Sorbet/FalseSigil:
|
63
|
+
Exclude:
|
64
|
+
- lib/example.rb
|
65
|
+
```
|
66
|
+
|
67
|
+
## Documentation
|
68
|
+
|
69
|
+
You can read about each cop supplied by RuboCop Sorbet in [the manual](manual/cops.md).
|
70
|
+
|
71
|
+
## Compatibility
|
72
|
+
|
73
|
+
Sorbet cops support the following versions:
|
74
|
+
|
75
|
+
- Sorbet >= 0.5
|
76
|
+
- Ruby >= 2.5
|
77
|
+
|
28
78
|
## Contributing
|
29
79
|
|
30
80
|
Bug reports and pull requests are welcome on GitHub at https://github.com/Shopify/rubocop-sorbet. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
31
81
|
|
82
|
+
To contribute a new cop, please use the supplied generator like this:
|
83
|
+
|
84
|
+
```sh
|
85
|
+
bundle exec rake new_cop[Sorbet/NewCopName]
|
86
|
+
```
|
87
|
+
|
88
|
+
which will create a skeleton cop, a skeleton spec, an entry in the default config file and will require the new cop so that it is properly exported from the gem.
|
89
|
+
|
32
90
|
## License
|
33
91
|
|
34
92
|
The gem is available as open source under the terms of the [MIT License](https://github.com/Shopify/rubocop-sorbet/blob/master/LICENSE.txt).
|
data/Rakefile
CHANGED
@@ -2,10 +2,39 @@
|
|
2
2
|
|
3
3
|
require('bundler/gem_tasks')
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
6
|
+
|
7
|
+
require 'rubocop/rake_task'
|
8
|
+
require 'rspec/core/rake_task'
|
9
|
+
|
10
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
11
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
9
12
|
end
|
10
13
|
|
11
|
-
task(default:
|
14
|
+
task(default: %i[
|
15
|
+
documentation_syntax_check
|
16
|
+
generate_cops_documentation
|
17
|
+
spec
|
18
|
+
])
|
19
|
+
|
20
|
+
desc('Generate a new cop with a template')
|
21
|
+
task :new_cop, [:cop] do |_task, args|
|
22
|
+
require 'rubocop'
|
23
|
+
|
24
|
+
cop_name = args.fetch(:cop) do
|
25
|
+
warn 'usage: bundle exec rake new_cop[Department/Name]'
|
26
|
+
exit!
|
27
|
+
end
|
28
|
+
|
29
|
+
github_user = %x(git config github.user).chop
|
30
|
+
github_user = 'Shopify' if github_user.empty?
|
31
|
+
|
32
|
+
generator = RuboCop::Cop::Generator.new(cop_name, github_user)
|
33
|
+
|
34
|
+
generator.write_source
|
35
|
+
generator.write_spec
|
36
|
+
generator.inject_require(root_file_path: 'lib/rubocop/cop/sorbet_cops.rb')
|
37
|
+
generator.inject_config(config_file_path: 'config/default.yml')
|
38
|
+
|
39
|
+
puts generator.todo
|
40
|
+
end
|
data/config/default.yml
CHANGED
@@ -1,6 +1,128 @@
|
|
1
|
-
|
1
|
+
inherit_mode:
|
2
|
+
merge:
|
3
|
+
- Exclude
|
4
|
+
|
5
|
+
Sorbet/AllowIncompatibleOverride:
|
6
|
+
Description: 'Disallows using `.override(allow_incompatible: true)`.'
|
7
|
+
Enabled: true
|
8
|
+
VersionAdded: 0.2.0
|
9
|
+
|
10
|
+
Sorbet/BindingConstantWithoutTypeAlias:
|
11
|
+
Description: >-
|
12
|
+
Disallows binding the return value of `T.any`, `T.all`, `T.enum`
|
13
|
+
to a constant directly. To bind the value, one must use `T.type_alias`.
|
14
|
+
Enabled: true
|
15
|
+
VersionAdded: 0.2.0
|
16
|
+
|
17
|
+
Sorbet/CheckedTrueInSignature:
|
18
|
+
Description: 'Disallows the usage of `checked(true)` in signatures.'
|
19
|
+
Enabled: true
|
20
|
+
VersionAdded: 0.2.0
|
21
|
+
|
22
|
+
Sorbet/ConstantsFromStrings:
|
23
|
+
Description: >-
|
24
|
+
Forbids constant access through meta-programming.
|
25
|
+
|
26
|
+
For example, things like `constantize` or `const_get`
|
27
|
+
are forbidden.
|
28
|
+
Enabled: true
|
29
|
+
VersionAdded: 0.2.0
|
30
|
+
|
31
|
+
Sorbet/EnforceSigilOrder:
|
32
|
+
Description: 'Ensures that Sorbet sigil comes first in a file.'
|
2
33
|
Enabled: true
|
3
|
-
|
34
|
+
VersionAdded: 0.3.4
|
4
35
|
|
5
36
|
Sorbet/EnforceSignatures:
|
37
|
+
Description: 'Ensures all methods have a valid signature.'
|
38
|
+
Enabled: false
|
39
|
+
VersionAdded: 0.3.4
|
40
|
+
|
41
|
+
Sorbet/FalseSigil:
|
42
|
+
Description: 'All files must be at least at strictness `false`.'
|
43
|
+
Enabled: true
|
44
|
+
VersionAdded: 0.3.3
|
45
|
+
SuggestedStrictness: true
|
46
|
+
Include:
|
47
|
+
- "**/*.rb"
|
48
|
+
- "**/*.rbi"
|
49
|
+
- "**/*.rake"
|
50
|
+
- "**/*.ru"
|
51
|
+
Exclude:
|
52
|
+
- bin/**/*
|
53
|
+
- db/**/*.rb
|
54
|
+
- script/**/*
|
55
|
+
|
56
|
+
Sorbet/ForbidIncludeConstLiteral:
|
57
|
+
Description: 'Forbids include of non-literal constants.'
|
58
|
+
Enabled: false
|
59
|
+
VersionAdded: 0.2.0
|
60
|
+
VersionChanged: 0.5.0
|
61
|
+
|
62
|
+
Sorbet/ForbidSuperclassConstLiteral:
|
63
|
+
Description: 'Forbid superclasses which are non-literal constants.'
|
64
|
+
Enabled: false
|
65
|
+
VersionAdded: 0.2.0
|
66
|
+
VersionChanged: 0.5.0
|
67
|
+
|
68
|
+
Sorbet/ForbidUntypedStructProps:
|
69
|
+
Description: >-
|
70
|
+
Disallows use of `T.untyped` or `T.nilable(T.untyped)` as a
|
71
|
+
prop type for `T::Struct` subclasses.
|
72
|
+
Enabled: true
|
73
|
+
VersionAdded: 0.4.0
|
74
|
+
|
75
|
+
Sorbet/HasSigil:
|
76
|
+
Description: 'Makes the Sorbet typed sigil mandatory in all files.'
|
77
|
+
Enabled: false
|
78
|
+
VersionAdded: 0.3.3
|
79
|
+
|
80
|
+
Sorbet/IgnoreSigil:
|
81
|
+
Description: 'All files must be at least at strictness `ignore`.'
|
82
|
+
Enabled: false
|
83
|
+
VersionAdded: 0.3.3
|
84
|
+
|
85
|
+
Sorbet/KeywordArgumentOrdering:
|
86
|
+
Description: >-
|
87
|
+
Enforces a compatible keyword arguments with Sorbet.
|
88
|
+
|
89
|
+
All keyword arguments must be at the end of the parameters
|
90
|
+
list, and all keyword arguments with a default value must be
|
91
|
+
after those without default values.
|
92
|
+
Enabled: true
|
93
|
+
VersionAdded: 0.2.0
|
94
|
+
|
95
|
+
Sorbet/ParametersOrderingInSignature:
|
96
|
+
Description: 'Enforces same parameter order between a method and its signature.'
|
97
|
+
Enabled: true
|
98
|
+
VersionAdded: 0.2.0
|
99
|
+
|
100
|
+
Sorbet/SignatureBuildOrder:
|
101
|
+
Description: >-
|
102
|
+
Enforces the order of parts in a signature.
|
103
|
+
|
104
|
+
The order is first inheritance related builders,
|
105
|
+
then params, then return and finally the modifier
|
106
|
+
such as: `abstract.params(...).returns(...).soft`.'
|
107
|
+
Enabled: true
|
108
|
+
VersionAdded: 0.3.0
|
109
|
+
|
110
|
+
Sorbet/StrictSigil:
|
111
|
+
Description: 'All files must be at least at strictness `strict`.'
|
112
|
+
Enabled: false
|
113
|
+
VersionAdded: 0.3.3
|
114
|
+
|
115
|
+
Sorbet/StrongSigil:
|
116
|
+
Description: 'All files must be at least at strictness `strong`.'
|
117
|
+
Enabled: false
|
118
|
+
VersionAdded: 0.3.3
|
119
|
+
|
120
|
+
Sorbet/TrueSigil:
|
121
|
+
Description: 'All files must be at least at strictness `true`.'
|
122
|
+
Enabled: false
|
123
|
+
VersionAdded: 0.3.3
|
124
|
+
|
125
|
+
Sorbet/ValidSigil:
|
126
|
+
Description: 'All files must have a valid sigil.'
|
6
127
|
Enabled: true
|
128
|
+
VersionAdded: 0.3.3
|