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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6740f039852d221e50f5f80f77f899a35135dfc91f19ded44e3cc909e9ba85f4
4
- data.tar.gz: 518ecd83900a4e20548bd22b659b9853ed5742429195344ec224e29e7d127986
3
+ metadata.gz: 8df8d245c60b5f1b43fc90d1493f7c2598aa1fdaea578cb154ce2791950da576
4
+ data.tar.gz: 1ffe6aee731f47cacb38092aabbe0d45cd3aa7ce286063f6324ddf0c5be387ab
5
5
  SHA512:
6
- metadata.gz: 2b73e591e2137443e2485c596295446270a86685dc1d185ba5e2f98615b9618ed9b5c0b979d563ae18611fb9184023803de62a01db810d6ed2a0fd6475eaa840
7
- data.tar.gz: eb57d0b9971e242fb9fb42e238487339e70c463c54a121dd1b4d1c7599459ffae0cdf1628801c1c280fed5f379a13fd2699329e1833c21a98423a6f94ad4e357
6
+ metadata.gz: bc9fbe21334b3c73275104ae2c9feb2b5829eb0425dc7896197af605cd6eba1711ed09249c08e12a33f8987759458fe353fdcc8d72cd9e905637911c2fbc1a11
7
+ data.tar.gz: ebc93757b9f627f459d94a7d4a028c397548be910ef0887747793f4945dbf2f83989e105acea0bdfbf9fc4b80bcf2c207e96727f9bd07db6c656e0f18fe7460c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop-sorbet (0.3.0)
4
+ rubocop-sorbet (0.3.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -0,0 +1,3 @@
1
+ Sorbet/ValidSorbetSigil:
2
+ Enabled: true
3
+ EnforcedStyle: typed_files
@@ -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
- add_offense(
34
- token,
35
- location: token.pos,
36
- message: 'No Sorbet sigil found in file. ' \
37
- 'Try a `typed: false` to start (you can also use `rubocop -a` to automatically add this).'
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)
@@ -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.0'
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.0
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-16 00:00:00.000000000 Z
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