rubocop-sorbet 0.7.5 → 0.7.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: 9b2451806224baad5c72fb848ae38e6510037b2e26415afc236c3639f8504655
4
- data.tar.gz: e55c4a39d87a4fe345a6257e14483de155738ea5d39c25ef1e7822a2174321cb
3
+ metadata.gz: 6bb19df178a322278126862ef69ee548a1480a3273b2fa7cb390efea682076d3
4
+ data.tar.gz: a4808b614e42b591e1254298ae40b41327b5762f5d7e494e5dbd476034d7f5a8
5
5
  SHA512:
6
- metadata.gz: d05d0627ce52223c931f3461e221f6cb105838c21eeae6d68a7270934e6e292fcd2a7390453583c95d721bc1544125cb74f2d65ef6161c4d8fe823c3ee8217e6
7
- data.tar.gz: adf840bad5a49581286937604e83b3ee864f45031efb115db9faed9032da04d4178d7022b3d2040e08e8b10dc5f7a95bc8bf8a0ee1ac06ba74780b135d947b26
6
+ metadata.gz: 495f4c62a3e669483d4a2fb958672480e1f50519589bbef0efab007b32f56c32fad54a795a47ee8da6157d4595da0a50f845744578e0f44fab34e57fc67aa28e
7
+ data.tar.gz: 3e07de7f56533ed0c86dfb510e8efa0a3d1c9eb79cd130f24235cd6919a1f05ca88afc8fa7ae114de9de3ed49beac2ddc16d0d0c3e37a0a2bf6f7404ac80dcaa
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop-sorbet (0.7.5)
4
+ rubocop-sorbet (0.7.6)
5
5
  rubocop (>= 0.90.0)
6
6
 
7
7
  GEM
data/config/default.yml CHANGED
@@ -89,6 +89,11 @@ Sorbet/ForbidIncludeConstLiteral:
89
89
  VersionAdded: 0.2.0
90
90
  VersionChanged: 0.5.0
91
91
 
92
+ Sorbet/ForbidTypeAliasedShapes:
93
+ Description: 'Forbids defining type aliases that contain shapes'
94
+ Enabled: false
95
+ VersionAdded: 0.7.6
96
+
92
97
  Sorbet/ForbidSuperclassConstLiteral:
93
98
  Description: 'Forbid superclasses which are non-literal constants.'
94
99
  Enabled: false
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rubocop"
4
+
5
+ module RuboCop
6
+ module Cop
7
+ module Sorbet
8
+ # Disallows defining type aliases that contain shapes
9
+ #
10
+ # @example
11
+ #
12
+ # # bad
13
+ # Foo = T.type_alias { { foo: Integer } }
14
+ #
15
+ # # good
16
+ # class Foo
17
+ # extend T::Sig
18
+ #
19
+ # sig { params(foo: Integer).void }
20
+ # def initialize(foo)
21
+ # @foo = foo
22
+ # end
23
+ # end
24
+ class ForbidTypeAliasedShapes < RuboCop::Cop::Base
25
+ MSG = "Type aliases shouldn't contain shapes because of significant performance overhead"
26
+
27
+ # @!method shape_type_alias?(node)
28
+ def_node_matcher(:shape_type_alias?, <<-PATTERN)
29
+ (block
30
+ (send (const {nil? cbase} :T) :type_alias)
31
+ (args)
32
+ `hash
33
+ )
34
+ PATTERN
35
+
36
+ def on_block(node)
37
+ add_offense(node) if shape_type_alias?(node)
38
+ end
39
+
40
+ alias_method :on_numblock, :on_block
41
+ end
42
+ end
43
+ end
44
+ end
@@ -7,6 +7,7 @@ require_relative "sorbet/binding_constant_without_type_alias"
7
7
  require_relative "sorbet/constants_from_strings"
8
8
  require_relative "sorbet/forbid_superclass_const_literal"
9
9
  require_relative "sorbet/forbid_include_const_literal"
10
+ require_relative "sorbet/forbid_type_aliased_shapes"
10
11
  require_relative "sorbet/forbid_untyped_struct_props"
11
12
  require_relative "sorbet/implicit_conversion_method"
12
13
  require_relative "sorbet/one_ancestor_per_line"
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Sorbet
5
- VERSION = "0.7.5"
5
+ VERSION = "0.7.6"
6
6
  end
7
7
  end
data/manual/cops.md CHANGED
@@ -23,6 +23,7 @@ In the following section you find all available cops:
23
23
  * [Sorbet/ForbidTStruct](cops_sorbet.md#sorbetforbidtstruct)
24
24
  * [Sorbet/ForbidTUnsafe](cops_sorbet.md#sorbetforbidtunsafe)
25
25
  * [Sorbet/ForbidTUntyped](cops_sorbet.md#sorbetforbidtuntyped)
26
+ * [Sorbet/ForbidTypeAliasedShapes](cops_sorbet.md#sorbetforbidtypealiasedshapes)
26
27
  * [Sorbet/ForbidUntypedStructProps](cops_sorbet.md#sorbetforbiduntypedstructprops)
27
28
  * [Sorbet/HasSigil](cops_sorbet.md#sorbethassigil)
28
29
  * [Sorbet/IgnoreSigil](cops_sorbet.md#sorbetignoresigil)
@@ -496,6 +496,31 @@ sig { params(my_argument: String).void }
496
496
  def foo(my_argument); end
497
497
  ```
498
498
 
499
+ ## Sorbet/ForbidTypeAliasedShapes
500
+
501
+ Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
502
+ --- | --- | --- | --- | ---
503
+ Disabled | Yes | No | 0.7.6 | -
504
+
505
+ Disallows defining type aliases that contain shapes
506
+
507
+ ### Examples
508
+
509
+ ```ruby
510
+ # bad
511
+ Foo = T.type_alias { { foo: Integer } }
512
+
513
+ # good
514
+ class Foo
515
+ extend T::Sig
516
+
517
+ sig { params(foo: Integer).void }
518
+ def initialize(foo)
519
+ @foo = foo
520
+ end
521
+ end
522
+ ```
523
+
499
524
  ## Sorbet/ForbidUntypedStructProps
500
525
 
501
526
  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.7.5
4
+ version: 0.7.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: 2023-10-31 00:00:00.000000000 Z
14
+ date: 2023-12-04 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec
@@ -95,6 +95,7 @@ files:
95
95
  - lib/rubocop/cop/sorbet/forbid_t_struct.rb
96
96
  - lib/rubocop/cop/sorbet/forbid_t_unsafe.rb
97
97
  - lib/rubocop/cop/sorbet/forbid_t_untyped.rb
98
+ - lib/rubocop/cop/sorbet/forbid_type_aliased_shapes.rb
98
99
  - lib/rubocop/cop/sorbet/forbid_untyped_struct_props.rb
99
100
  - lib/rubocop/cop/sorbet/implicit_conversion_method.rb
100
101
  - lib/rubocop/cop/sorbet/mixin/signature_help.rb
@@ -154,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
155
  - !ruby/object:Gem::Version
155
156
  version: '0'
156
157
  requirements: []
157
- rubygems_version: 3.4.21
158
+ rubygems_version: 3.4.22
158
159
  signing_key:
159
160
  specification_version: 4
160
161
  summary: Automatic Sorbet code style checking tool.