rubocop-sorbet 0.6.5 → 0.6.6

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: 7c1aed7de77dddecfab7d01e2370897d1da0081d92795aa9fdd221b831da980d
4
- data.tar.gz: ecc9c7d3168bd636a45d2e9f9c4c9f20e04e42379ea89280452d7a9f59e2f3f8
3
+ metadata.gz: fbc8c95598a4e9bdcc08915198dc90cea5df439d3f06ec72f7a36b6a8a792207
4
+ data.tar.gz: 7bff9273f2f52f43e18d32f32b3f58ccb988274ffc2bde3746b45556c981bf51
5
5
  SHA512:
6
- metadata.gz: 555054526bf69633f6faf63c83514255c0622c0b7604eab94dfd31933c023285e53aadd4e76eb49418d92532ca9953a8a0d42bb7d74ef0cfd7478cd4b244dab1
7
- data.tar.gz: fa2e73581f867b029b1a853647b0bbea47f433037064d29773366aa02e2374f9e79209ae712dc7cd54c2d3654dbbf097fe324a5683e34f3180a93b8c88d7da96
6
+ metadata.gz: 3c749f0f371cb8e764c1db26221d3f0bebc83afc8466b7d07753c702f6e87d67657e2b0bed70f2c738d820377538356ed1259ab7317878c254fc6d2c86dc3aaf
7
+ data.tar.gz: 359d7e9082d01e25c088b902de0fa80d93625351caaaec52983c93eaaebbf5a9488977b4c18b0d0c1d5771cc2e97cc698c4b741addf765e739e737c01274597b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop-sorbet (0.6.5)
4
+ rubocop-sorbet (0.6.6)
5
5
  rubocop (>= 0.90.0)
6
6
 
7
7
  GEM
@@ -10,12 +10,12 @@ GEM
10
10
  ast (2.4.2)
11
11
  byebug (11.1.3)
12
12
  diff-lcs (1.3)
13
- parallel (1.20.1)
13
+ parallel (1.21.0)
14
14
  parser (3.0.1.1)
15
15
  ast (~> 2.4.1)
16
- rainbow (3.0.0)
16
+ rainbow (3.1.1)
17
17
  rake (13.0.1)
18
- regexp_parser (2.1.1)
18
+ regexp_parser (2.2.0)
19
19
  rexml (3.2.5)
20
20
  rspec (3.8.0)
21
21
  rspec-core (~> 3.8.0)
@@ -30,21 +30,21 @@ GEM
30
30
  diff-lcs (>= 1.2.0, < 2.0)
31
31
  rspec-support (~> 3.8.0)
32
32
  rspec-support (3.8.2)
33
- rubocop (1.16.0)
33
+ rubocop (1.24.1)
34
34
  parallel (~> 1.10)
35
35
  parser (>= 3.0.0.0)
36
36
  rainbow (>= 2.2.2, < 4.0)
37
37
  regexp_parser (>= 1.8, < 3.0)
38
38
  rexml
39
- rubocop-ast (>= 1.7.0, < 2.0)
39
+ rubocop-ast (>= 1.15.1, < 2.0)
40
40
  ruby-progressbar (~> 1.7)
41
41
  unicode-display_width (>= 1.4.0, < 3.0)
42
- rubocop-ast (1.7.0)
42
+ rubocop-ast (1.15.1)
43
43
  parser (>= 3.0.1.1)
44
44
  rubocop-shopify (2.1.0)
45
45
  rubocop (~> 1.13)
46
46
  ruby-progressbar (1.11.0)
47
- unicode-display_width (2.0.0)
47
+ unicode-display_width (2.1.0)
48
48
  unparser (0.6.0)
49
49
  diff-lcs (~> 1.3)
50
50
  parser (>= 3.0.0)
data/config/default.yml CHANGED
@@ -197,6 +197,17 @@ Sorbet/TrueSigil:
197
197
  - db/**/*.rb
198
198
  - script/**/*
199
199
 
200
+ Sorbet/TypeAliasName:
201
+ Description: 'Type alias constant names must be in CamelCase.'
202
+ Enabled: true
203
+ VersionAdded: 0.6.6
204
+ Include:
205
+ - "**/*.{rb,rbi,rake,ru}"
206
+ Exclude:
207
+ - bin/**/*
208
+ - db/**/*.rb
209
+ - script/**/*
210
+
200
211
  Sorbet/ValidSigil:
201
212
  Description: 'All files must have a valid sigil.'
202
213
  Enabled: true
data/config/rbi.yml CHANGED
@@ -220,6 +220,9 @@ Sorbet/SignatureBuildOrder:
220
220
  Sorbet/SingleLineRbiClassModuleDefinitions:
221
221
  Enabled: true
222
222
 
223
+ Sorbet/TypeAliasName:
224
+ Enabled: true
225
+
223
226
  Sorbet/ValidSigil:
224
227
  Enabled: true
225
228
  RequireSigilOnAllFiles: true
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rubocop"
4
+
5
+ module RuboCop
6
+ module Cop
7
+ module Sorbet
8
+ # This cop ensures all constants used as `T.type_alias` are using CamelCase.
9
+ #
10
+ # @example
11
+ #
12
+ # # bad
13
+ # FOO_OR_BAR = T.type_alias { T.any(Foo, Bar) }
14
+ #
15
+ # # good
16
+ # FooOrBar = T.type_alias { T.any(Foo, Bar) }
17
+ class TypeAliasName < RuboCop::Cop::Cop
18
+ MSG = "Type alias constant name should be in CamelCase"
19
+
20
+ def_node_matcher(:casgn_type_alias?, <<-PATTERN)
21
+ (casgn
22
+ _
23
+ _
24
+ (block
25
+ (send
26
+ (const nil? :T) :type_alias)
27
+ _
28
+ _
29
+ ))
30
+ PATTERN
31
+
32
+ def on_casgn(node)
33
+ return unless casgn_type_alias?(node)
34
+
35
+ name = node.children[1]
36
+
37
+ # From https://github.com/rubocop/rubocop/blob/master/lib/rubocop/cop/naming/class_and_module_camel_case.rb
38
+ return unless /_/.match?(name)
39
+
40
+ add_offense(node)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -7,6 +7,7 @@ require_relative "sorbet/forbid_untyped_struct_props"
7
7
  require_relative "sorbet/one_ancestor_per_line"
8
8
  require_relative "sorbet/callback_conditionals_binding"
9
9
  require_relative "sorbet/forbid_t_unsafe"
10
+ require_relative "sorbet/type_alias_name"
10
11
 
11
12
  require_relative "sorbet/rbi/forbid_extend_t_sig_helpers_in_shims"
12
13
  require_relative "sorbet/rbi/forbid_rbi_outside_of_allowed_paths"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module RuboCop
3
3
  module Sorbet
4
- VERSION = "0.6.5"
4
+ VERSION = "0.6.6"
5
5
  end
6
6
  end
data/manual/cops.md CHANGED
@@ -30,6 +30,7 @@ In the following section you find all available cops:
30
30
  * [Sorbet/StrictSigil](cops_sorbet.md#sorbetstrictsigil)
31
31
  * [Sorbet/StrongSigil](cops_sorbet.md#sorbetstrongsigil)
32
32
  * [Sorbet/TrueSigil](cops_sorbet.md#sorbettruesigil)
33
+ * [Sorbet/TypeAliasName](cops_sorbet.md#sorbettypealiasname)
33
34
  * [Sorbet/ValidSigil](cops_sorbet.md#sorbetvalidsigil)
34
35
 
35
36
  <!-- END_COP_LIST -->
@@ -545,6 +545,31 @@ SuggestedStrictness | `true` | String
545
545
  Include | `**/*.{rb,rbi,rake,ru}` | Array
546
546
  Exclude | `bin/**/*`, `db/**/*.rb`, `script/**/*` | Array
547
547
 
548
+ ## Sorbet/TypeAliasName
549
+
550
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
551
+ --- | --- | --- | --- | ---
552
+ Enabled | Yes | No | 0.6.6 | -
553
+
554
+ This cop ensures all constants used as `T.type_alias` are using CamelCase.
555
+
556
+ ### Examples
557
+
558
+ ```ruby
559
+ # bad
560
+ FOO_OR_BAR = T.type_alias { T.any(Foo, Bar) }
561
+
562
+ # good
563
+ FooOrBar = T.type_alias { T.any(Foo, Bar) }
564
+ ```
565
+
566
+ ### Configurable attributes
567
+
568
+ Name | Default value | Configurable values
569
+ --- | --- | ---
570
+ Include | `**/*.{rb,rbi,rake,ru}` | Array
571
+ Exclude | `bin/**/*`, `db/**/*.rb`, `script/**/*` | Array
572
+
548
573
  ## Sorbet/ValidSigil
549
574
 
550
575
  Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-sorbet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ufuk Kayserilioglu
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2021-12-17 00:00:00.000000000 Z
14
+ date: 2022-02-09 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec
@@ -111,6 +111,7 @@ files:
111
111
  - lib/rubocop/cop/sorbet/signatures/keyword_argument_ordering.rb
112
112
  - lib/rubocop/cop/sorbet/signatures/signature_build_order.rb
113
113
  - lib/rubocop/cop/sorbet/signatures/signature_cop.rb
114
+ - lib/rubocop/cop/sorbet/type_alias_name.rb
114
115
  - lib/rubocop/cop/sorbet_cops.rb
115
116
  - lib/rubocop/sorbet.rb
116
117
  - lib/rubocop/sorbet/inject.rb