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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a92716b1864cc9e66f6c3dcadb78aed34de2c23d9bcaa201f5ee7cc8f9a5cbc
4
- data.tar.gz: 57ffe424d24b7ab58cea383f6f05f2f30a726e8aa6dbf0a87989bbd219276bcc
3
+ metadata.gz: 0df763a5f1ab8de8024c732f5e3fae7d31d21e13c807fceca5c0d8c674e52d46
4
+ data.tar.gz: 36fb28afefdb665eb471bb536be012b5123efe5e19ef1ddf61415c21a6aa5892
5
5
  SHA512:
6
- metadata.gz: bea0851da95265e63fdfa0d33418f34ff7189fc778d3ad8aa6ef0e51f4af1b8f1aebdd514d678ad7affb71e06fe0607630b6019a43380d9c60396b092e5ad4fc
7
- data.tar.gz: c270ac5e4576d7f0d214e8d605356e93bb820dbab2f5062fc6ec7261eeb2437354c9326951704b40c2b0911dd41cf913220c5d848c21ede41976c9956772056d
6
+ metadata.gz: 80f5462984070d3194ad111484b5a4f40905b9ba65ab55f95b050915a8df7fa2c2e54d30a7771738f7bb5e9c26dac8568c36a90c3e854dabb14240b255759c64
7
+ data.tar.gz: 66ed0ca23fa3b76a372fdae99273af7e037e3f0de5b437fc8a4d35ad024da31d0cd174c0afb12c0176c8b111d2b73be7be9960611f9176d58d46825e5c702015
@@ -0,0 +1,2 @@
1
+ # Request a review from @Shopify/sorbet when a new PR is created
2
+ * @Shopify/sorbet
@@ -1,3 +1,3 @@
1
1
  enabled:
2
2
  - cla
3
-
3
+ - probot-stale
@@ -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
@@ -6,5 +6,3 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
-
10
- .rubocop-https--*
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -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
- inherit_from:
4
- - https://shopify.github.io/ruby-style-guide/rubocop.yml
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
@@ -3,7 +3,9 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.6.2
6
+ - 2.5
7
+ - 2.6
8
+ - 2.7
7
9
  before_install: gem install bundler -v 1.17.3
8
10
  script:
9
11
  - bundle exec rubocop --config .rubocop.yml
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"
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop-sorbet (0.3.6)
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
- mime-types (3.2.2)
30
- mime-types-data (~> 3.2015)
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 (2.2.2)
44
- rake
45
- rake (12.3.2)
46
- rest-client (2.0.2)
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.72.0)
64
- jaro_winkler (~> 1.5.1)
44
+ rubocop (0.85.0)
65
45
  parallel (~> 1.10)
66
- parser (>= 2.6)
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, < 1.7)
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
- unf (0.1.4)
74
- unf_ext
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 (~> 2.6.3)
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
- package_cloud (~> 0.3.05)
91
- rspec (~> 3.7)
92
- rubocop (~> 0.57)
74
+ rake (>= 12.3.3)
75
+ rspec
76
+ rubocop-shopify
93
77
  rubocop-sorbet!
94
- unparser (~> 0.4.2)
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
- Add this line to your application's Gemfile:
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
- And then execute:
20
+ ## Usage
16
21
 
17
- $ bundle
22
+ You need to tell RuboCop to load the Sorbet extension. There are three ways to do this:
18
23
 
19
- ## Usage
24
+ ### RuboCop configuration file
25
+
26
+ Put this into your `.rubocop.yml`:
27
+
28
+ ```yaml
29
+ require: rubocop-sorbet
30
+ ```
20
31
 
21
- And add this to your `.rubocop.yml` file:
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
- begin
6
- require('rspec/core/rake_task')
7
- RSpec::Core::RakeTask.new(:spec)
8
- rescue LoadError
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: :spec)
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
@@ -1,6 +1,128 @@
1
- Sorbet/ValidSigil:
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
- EnforcedStyle: typed_files
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