rubocop-sorbet 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/config/default.yml +3 -0
- data/lib/rubocop/cop/sorbet/valid_sorbet_sigil.rb +28 -7
- data/rubocop-sorbet.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8df8d245c60b5f1b43fc90d1493f7c2598aa1fdaea578cb154ce2791950da576
|
4
|
+
data.tar.gz: 1ffe6aee731f47cacb38092aabbe0d45cd3aa7ce286063f6324ddf0c5be387ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc9fbe21334b3c73275104ae2c9feb2b5829eb0425dc7896197af605cd6eba1711ed09249c08e12a33f8987759458fe353fdcc8d72cd9e905637911c2fbc1a11
|
7
|
+
data.tar.gz: ebc93757b9f627f459d94a7d4a028c397548be910ef0887747793f4945dbf2f83989e105acea0bdfbf9fc4b80bcf2c207e96727f9bd07db6c656e0f18fe7460c
|
data/Gemfile.lock
CHANGED
data/config/default.yml
ADDED
@@ -8,7 +8,21 @@ module RuboCop
|
|
8
8
|
# This cop checks that every Ruby file contains a valid Sorbet sigil.
|
9
9
|
# Adapted from: https://gist.github.com/clarkdave/85aca4e16f33fd52aceb6a0a29936e52
|
10
10
|
#
|
11
|
-
# @example
|
11
|
+
# @example RequireSigilOnAllFiles: false (default)
|
12
|
+
#
|
13
|
+
# # bad
|
14
|
+
# # (start of file)
|
15
|
+
# # typed: no
|
16
|
+
#
|
17
|
+
# # good
|
18
|
+
# # (start of file)
|
19
|
+
# class Foo; end
|
20
|
+
#
|
21
|
+
# # good
|
22
|
+
# # (start of file)
|
23
|
+
# # typed: true
|
24
|
+
#
|
25
|
+
# @example RequireSigilOnAllFiles: true
|
12
26
|
#
|
13
27
|
# # bad
|
14
28
|
# # (start of file)
|
@@ -30,12 +44,14 @@ module RuboCop
|
|
30
44
|
if sorbet_sigil_line.nil?
|
31
45
|
token = processed_source.tokens.first
|
32
46
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
47
|
+
if require_sorbet_sigil_on_all_files?
|
48
|
+
add_offense(
|
49
|
+
token,
|
50
|
+
location: token.pos,
|
51
|
+
message: 'No Sorbet sigil found in file. ' \
|
52
|
+
'Try a `typed: false` to start (you can also use `rubocop -a` to automatically add this).'
|
53
|
+
)
|
54
|
+
end
|
39
55
|
else
|
40
56
|
strictness = sorbet_typed_strictness(sorbet_sigil_line)
|
41
57
|
return if valid_sorbet_strictness?(strictness)
|
@@ -50,6 +66,7 @@ module RuboCop
|
|
50
66
|
|
51
67
|
def autocorrect(_node)
|
52
68
|
lambda do |corrector|
|
69
|
+
return unless require_sorbet_sigil_on_all_files?
|
53
70
|
return unless sorbet_typed_sigil_comment(processed_source).nil?
|
54
71
|
|
55
72
|
token = processed_source.tokens.first
|
@@ -60,6 +77,10 @@ module RuboCop
|
|
60
77
|
|
61
78
|
private
|
62
79
|
|
80
|
+
def require_sorbet_sigil_on_all_files?
|
81
|
+
!!cop_config['RequireSigilOnAllFiles']
|
82
|
+
end
|
83
|
+
|
63
84
|
SORBET_SIGIL_REGEX = /#\s+typed:\s+([\w]+)/
|
64
85
|
|
65
86
|
def sorbet_typed_sigil_comment(processed_source)
|
data/rubocop-sorbet.gemspec
CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'rubocop-sorbet'
|
8
|
-
spec.version = '0.3.
|
8
|
+
spec.version = '0.3.1'
|
9
9
|
spec.authors = ['Ufuk Kayserilioglu', 'Alan Wu', 'Alexandre Terrasa', 'Peter Zhu']
|
10
10
|
spec.email = ['rails@shopify.com']
|
11
11
|
|
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.3.
|
4
|
+
version: 0.3.1
|
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: 2019-07-
|
14
|
+
date: 2019-07-17 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rspec
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- bin/console
|
76
76
|
- bin/rspec
|
77
77
|
- bin/setup
|
78
|
+
- config/default.yml
|
78
79
|
- dev.yml
|
79
80
|
- lib/rubocop-sorbet.rb
|
80
81
|
- lib/rubocop/cop/sorbet/allow_incompatible_override.rb
|