rubocop-sorbet 0.4.1 → 0.5.0

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: b73993245df905cf40d9e0dbc440d613315e5b32d89e9b61ee123994fee53e73
4
- data.tar.gz: '019d4212c2c204492aa38f928ddfc31cceac5d79fe6ee09927c889e3b245f999'
3
+ metadata.gz: d705f397454c9a1658a3fc81f98df969c2ca5d5119924404f9195d3e878d6119
4
+ data.tar.gz: 62f7e2f18940530a2a757b0c085463b8462edceb8c2f987f4038c3d71ff8fd0e
5
5
  SHA512:
6
- metadata.gz: d491ed5a48d75c2f5151329fc0018ca56ed57504d6d1e338befe0c9395bf85824b65f68164538667b4720eca216eeb15c29c6ed379524ae9ed1a8215cf6daf84
7
- data.tar.gz: 7944aa4817f48ca0bb43c47dabcf197ced656674ab59ce261705b946045a2e3c0de813200187829cf9936a2144a5203ed625c8cdd89a33b7e80876229f7f2748
6
+ metadata.gz: cf74e543eb073e9db8fd3f38a0914124d06fd8b586eda66da33376486998d94f0c735ad31c3cbc32b4fc6f436a4f1288f9f232e32c1a014389969f7101f58d72
7
+ data.tar.gz: 4aab7f7d8e47a91ea405042143a04252218b66ec264969a11494d695f66ad1583d9d362d1dfe9c7a15b8084a92ceb00df565345b047265ed8068eadb2abadcca
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop-sorbet (0.4.1)
4
+ rubocop-sorbet (0.5.0)
5
5
  rubocop
6
6
 
7
7
  GEM
@@ -55,13 +55,15 @@ Sorbet/FalseSigil:
55
55
 
56
56
  Sorbet/ForbidIncludeConstLiteral:
57
57
  Description: 'Forbids include of non-literal constants.'
58
- Enabled: true
58
+ Enabled: false
59
59
  VersionAdded: 0.2.0
60
+ VersionChanged: 0.5.0
60
61
 
61
62
  Sorbet/ForbidSuperclassConstLiteral:
62
63
  Description: 'Forbid superclasses which are non-literal constants.'
63
- Enabled: true
64
+ Enabled: false
64
65
  VersionAdded: 0.2.0
66
+ VersionChanged: 0.5.0
65
67
 
66
68
  Sorbet/ForbidUntypedStructProps:
67
69
  Description: >-
@@ -14,15 +14,6 @@ require 'rubocop'
14
14
  # end
15
15
  # ```
16
16
  #
17
- # This cop replaces them by:
18
- #
19
- # ```ruby
20
- # class MyClass
21
- # MyClassInclude = send_expr
22
- # include MyClassInclude
23
- # end
24
- # ```
25
- #
26
17
  # Multiple occurences of this can be found in Shopify's code base like:
27
18
  #
28
19
  # ```ruby
@@ -61,37 +52,6 @@ module RuboCop
61
52
  return unless [:module, :class, :sclass].include?(parent.type)
62
53
  add_offense(node)
63
54
  end
64
-
65
- def autocorrect(node)
66
- lambda do |corrector|
67
- # Find parent class node
68
- parent = node.parent
69
- parent = parent.parent if parent.type == :begin
70
-
71
- # Build include variable name
72
- class_name = (parent.child_nodes.first.const_name || 'Anon').split('::').last
73
- include_name = find_free_name("#{class_name}Include")
74
- used_names << include_name
75
-
76
- # Apply fix
77
- indent = ' ' * node.loc.column
78
- fix = "#{include_name} = #{node.child_nodes.first.source}\n#{indent}"
79
- corrector.insert_before(node.loc.expression, fix)
80
- corrector.replace(node.child_nodes.first.loc.expression, include_name)
81
- end
82
- end
83
-
84
- # Find a free local variable name
85
- #
86
- # Since each include uses its own local variable to store the send result,
87
- # we need to ensure that we don't use the same name twice in the same
88
- # module.
89
- def find_free_name(base_name)
90
- return base_name unless used_names.include?(base_name)
91
- i = 2
92
- i += 1 while used_names.include?("#{base_name}#{i}")
93
- "#{base_name}#{i}"
94
- end
95
55
  end
96
56
  end
97
57
  end
@@ -12,13 +12,6 @@ require 'rubocop'
12
12
  # class Foo < send_expr; end
13
13
  # ```
14
14
  #
15
- # This cop replaces them by:
16
- #
17
- # ```ruby
18
- # FooParent = send_expr
19
- # class Foo < FooParent; end
20
- # ```
21
- #
22
15
  # Multiple occurences of this can be found in Shopify's code base like:
23
16
  #
24
17
  # ```ruby
@@ -46,16 +39,6 @@ module RuboCop
46
39
  return unless not_lit_const_superclass?(node)
47
40
  add_offense(node.child_nodes[1])
48
41
  end
49
-
50
- def autocorrect(node)
51
- lambda do |corrector|
52
- class_name = node.parent.child_nodes.first.const_name
53
- parent_name = "#{class_name}Parent"
54
- indent = ' ' * node.parent.loc.column
55
- corrector.insert_before(node.parent.loc.expression, "#{parent_name} = #{node.source}\n#{indent}")
56
- corrector.replace(node.loc.expression, parent_name)
57
- end
58
- end
59
42
  end
60
43
  end
61
44
  end
@@ -28,6 +28,8 @@ module RuboCop
28
28
  # Only `typed`, `(en)?coding`, `warn_indent` and `frozen_string_literal` magic comments are considered,
29
29
  # other comments or magic comments are left in the same place.
30
30
  class EnforceSigilOrder < ValidSigil
31
+ include RangeHelp
32
+
31
33
  def investigate(processed_source)
32
34
  return if processed_source.tokens.empty?
33
35
 
@@ -49,6 +51,14 @@ module RuboCop
49
51
  tokens.each_with_index do |token, index|
50
52
  corrector.replace(token.pos, expected[index].text)
51
53
  end
54
+
55
+ # Remove blank lines between the magic comments
56
+ lines = tokens.map(&:line).to_set
57
+ (lines.min...lines.max).each do |line|
58
+ next if lines.include?(line)
59
+ next unless processed_source[line - 1].empty?
60
+ corrector.remove(source_range(processed_source.buffer, line, 0))
61
+ end
52
62
  end
53
63
  end
54
64
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module RuboCop
3
3
  module Sorbet
4
- VERSION = "0.4.1"
4
+ VERSION = "0.5.0"
5
5
  end
6
6
  end
@@ -175,7 +175,7 @@ Exclude | `bin/**/*`, `db/**/*.rb`, `script/**/*` | Array
175
175
 
176
176
  Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
177
177
  --- | --- | --- | --- | ---
178
- Enabled | Yes | Yes | 0.2.0 | -
178
+ Disabled | Yes | No | 0.2.0 | 0.5.0
179
179
 
180
180
  No documentation
181
181
 
@@ -183,7 +183,7 @@ No documentation
183
183
 
184
184
  Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
185
185
  --- | --- | --- | --- | ---
186
- Enabled | Yes | Yes | 0.2.0 | -
186
+ Disabled | Yes | No | 0.2.0 | 0.5.0
187
187
 
188
188
  No documentation
189
189
 
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.4.1
4
+ version: 0.5.0
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: 2020-08-20 00:00:00.000000000 Z
14
+ date: 2020-10-01 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec