rubocop-sorbet 0.3.4 → 0.3.5

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: 680171335e42d9f614626c06b286af906fbd4a71473ad36a5133e343ca202376
4
- data.tar.gz: c84b1f2a66e5f2406640d5c2543f5a936b61b25141a8136a1cdf94f36f6af2cf
3
+ metadata.gz: 2dea563faa3843260cff524016317221bae41fe6eaf162b8abed91963c79e1d4
4
+ data.tar.gz: b45f03fb4a552be371a86fa6d710e53b41536a68c1fea93c5df58396d5aa4fbf
5
5
  SHA512:
6
- metadata.gz: 6c93471fa6670ce5c257fa7604bf9755bd910baffcfed62348f22dcb9242868ec42c9738f2b507317340085b22ada30140e3ad618408a5563fd00d449d4a8e81
7
- data.tar.gz: e105b484e8b8e75177e126e8dd3b682514a4deb4f9135ace3e97ca49d4f9dcd54dc23800676cb48386faabe7a779deca53335f01affdc981351d11647cbed47c
6
+ metadata.gz: 46021afef2a60b990d7db28dc1b38059e9aa36ba39e3ebcdf9185e35a9c8dbf9181df0303315b515ebcb126ba6fe0a1cc27dc8adcfcd8f4f8377e4679376738d
7
+ data.tar.gz: 00721e2b73fa61a35707c68ac8bc0466ab2b7e344c8aae200c13a03e7481407d92682ca859567f4ace4f60574a0e996f175a57d6aaf4890a3c87c65d41cb32b2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop-sorbet (0.3.4)
4
+ rubocop-sorbet (0.3.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -36,7 +36,8 @@ module RuboCop
36
36
  return unless extract_sigil(processed_source).nil?
37
37
 
38
38
  token = processed_source.tokens.first
39
- corrector.insert_before(token.pos, "# typed: #{minimum_strictness || suggested_strictness}\n")
39
+ replace_with = suggested_strictness_level(minimum_strictness, suggested_strictness)
40
+ corrector.insert_before(token.pos, "# typed: #{replace_with}\n")
40
41
  end
41
42
  end
42
43
 
@@ -64,7 +65,7 @@ module RuboCop
64
65
 
65
66
  token = processed_source.tokens.first
66
67
  if require_sigil_on_all_files?
67
- strictness = minimum_strictness || suggested_strictness
68
+ strictness = suggested_strictness_level(minimum_strictness, suggested_strictness)
68
69
  add_offense(
69
70
  token,
70
71
  location: token.pos,
@@ -75,6 +76,25 @@ module RuboCop
75
76
  false
76
77
  end
77
78
 
79
+ def suggested_strictness_level(minimum_strictness, suggested_strictness)
80
+ # if no minimum strictness is set (eg. using Sorbet/HasSigil without config) then
81
+ # we always use the suggested strictness which defaults to `false`
82
+ return suggested_strictness unless minimum_strictness
83
+
84
+ # special case: if you're using Sorbet/IgnoreSigil without config, we should recommend `ignore`
85
+ return "ignore" if minimum_strictness == "ignore" && cop_config['SuggestedStrictness'].nil?
86
+
87
+ # if a minimum strictness is set (eg. you're using Sorbet/FalseSigil)
88
+ # we want to compare the minimum strictness and suggested strictness. this is because
89
+ # the suggested strictness might be higher than the minimum (eg. if you want all new files
90
+ # at a higher strictness level, without having to migrate existing files at lower levels).
91
+
92
+ suggested_level = STRICTNESS_LEVELS.index(suggested_strictness)
93
+ minimum_level = STRICTNESS_LEVELS.index(minimum_strictness)
94
+
95
+ suggested_level > minimum_level ? suggested_strictness : minimum_strictness
96
+ end
97
+
78
98
  def check_strictness_not_empty(sigil, strictness)
79
99
  return true if strictness
80
100
 
@@ -122,12 +142,12 @@ module RuboCop
122
142
 
123
143
  # Default is `'false'`
124
144
  def suggested_strictness
125
- cop_config['SuggestedStrictness'] || 'false'
145
+ STRICTNESS_LEVELS.include?(cop_config['SuggestedStrictness']) ? cop_config['SuggestedStrictness'] : 'false'
126
146
  end
127
147
 
128
148
  # Default is `nil`
129
149
  def minimum_strictness
130
- cop_config['MinimumStrictness']
150
+ cop_config['MinimumStrictness'] if STRICTNESS_LEVELS.include?(cop_config['MinimumStrictness'])
131
151
  end
132
152
  end
133
153
  end
@@ -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.4'
8
+ spec.version = '0.3.5'
9
9
  spec.authors = ['Ufuk Kayserilioglu', 'Alan Wu', 'Alexandre Terrasa', 'Peter Zhu']
10
10
  spec.email = ['ruby@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
4
+ version: 0.3.5
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-12-02 00:00:00.000000000 Z
14
+ date: 2020-01-16 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec