rubocop-sorbet 0.6.3 → 0.6.4

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: bd3fcc1ddd15ba9418aeb852d83149b3594fb315c7aa77ab4641c9046466d109
4
- data.tar.gz: 2b446c026647ebb8d312e8be0034af253f61dc5ac8903c2b75bf42c11be903fe
3
+ metadata.gz: ff745a34cb220b2798dcae5138ade84288219f2ce6fb2d81c12d90258a722609
4
+ data.tar.gz: 3827b4ceb6ced335573ece62da965e8f3ecc4b97313887fd5da2b7b46e1d1877
5
5
  SHA512:
6
- metadata.gz: dd23c876c6224baf1a3888c169291b6260286326329d9b48650d1c4113571257837e0fa96d12b4357d4aee62e78b20e1be6373295b0d1e7d065c139e8cf3e25f
7
- data.tar.gz: 12c3c8aae878c4474284fd41f79da1f4671399bb8e1f01403fe556d36e25274d951f42771ecd0dfc0c3527686b0f3aa1a0d3a22db9b7287c802adf9c43cbc718
6
+ metadata.gz: de19c77ff90f52a4e045509c1f7c82edb6c844a6eab9cf0d37f10d70fc7d08a6abc3b9c13cad7762445c77ed0125ed24044a068718553d48af781c84956541c1
7
+ data.tar.gz: 6dc626e0f057d495164b775f2730900acae4ea1b95d8944f42912fe20c26c416306ded1a5b4e321c47bb90bbb44b411d00f4b98f048c66df31346883ef88f635
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop-sorbet (0.6.3)
4
+ rubocop-sorbet (0.6.4)
5
5
  rubocop (>= 0.90.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # Rubocop-Sorbet
2
2
 
3
- [![Build Status](https://travis-ci.org/Shopify/rubocop-sorbet.svg?branch=master)](https://travis-ci.org/Shopify/rubocop-sorbet)
4
-
5
3
  A collection of Rubocop rules for Sorbet.
6
4
 
7
5
  ## Installation
@@ -17,7 +15,7 @@ or, if you use `Bundler`, add this line your application's `Gemfile`:
17
15
  gem 'rubocop-sorbet', require: false
18
16
  ```
19
17
 
20
- Note: in order to use the [Sorbet/SignatureBuildOrder](https://github.com/Shopify/rubocop-sorbet/blob/master/manual/cops_sorbet.md#sorbetsignaturebuildorder) cop autocorrect feature, it is necessary
18
+ Note: in order to use the [Sorbet/SignatureBuildOrder](https://github.com/Shopify/rubocop-sorbet/blob/main/manual/cops_sorbet.md#sorbetsignaturebuildorder) cop autocorrect feature, it is necessary
21
19
  to install `unparser` in addition to `rubocop-sorbet`.
22
20
 
23
21
  ```ruby
@@ -111,8 +109,8 @@ bundle exec rake generate_cops_documentation
111
109
 
112
110
  ## License
113
111
 
114
- The gem is available as open source under the terms of the [MIT License](https://github.com/Shopify/rubocop-sorbet/blob/master/LICENSE.txt).
112
+ The gem is available as open source under the terms of the [MIT License](https://github.com/Shopify/rubocop-sorbet/blob/main/LICENSE.txt).
115
113
 
116
114
  ## Code of Conduct
117
115
 
118
- Everyone interacting in the Rubocop::Sorbet project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Shopify/rubocop-sorbet/blob/master/CODE_OF_CONDUCT.md).
116
+ Everyone interacting in the Rubocop::Sorbet project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Shopify/rubocop-sorbet/blob/main/CODE_OF_CONDUCT.md).
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "pathname"
4
+
3
5
  module RuboCop
4
6
  module Cop
5
7
  module Sorbet
@@ -21,25 +23,41 @@ module RuboCop
21
23
  include RangeHelp
22
24
 
23
25
  def investigate(processed_source)
26
+ paths = allowed_paths
27
+
28
+ if paths.nil?
29
+ add_offense(
30
+ nil,
31
+ location: source_range(processed_source.buffer, 1, 0),
32
+ message: "AllowedPaths expects an array"
33
+ )
34
+ return
35
+ elsif paths.empty?
36
+ add_offense(
37
+ nil,
38
+ location: source_range(processed_source.buffer, 1, 0),
39
+ message: "AllowedPaths cannot be empty"
40
+ )
41
+ return
42
+ end
43
+
44
+ # When executed the path to the source file is absolute.
45
+ # We need to remove the exec path directory prefix before matching with the filename regular expressions.
46
+ rel_path = processed_source.file_path.sub("#{Dir.pwd}/", "")
47
+
24
48
  add_offense(
25
49
  nil,
26
50
  location: source_range(processed_source.buffer, 1, 0),
27
- message: message
28
- ) if allowed_paths.none? { |pattern| File.fnmatch(pattern, processed_source.file_path) }
51
+ message: "RBI file path should match one of: #{paths.join(", ")}"
52
+ ) if paths.none? { |pattern| File.fnmatch(pattern, rel_path) }
29
53
  end
30
54
 
31
55
  private
32
56
 
33
57
  def allowed_paths
34
- cop_config["AllowedPaths"]&.compact || []
35
- end
36
-
37
- def message
38
- if allowed_paths.empty?
39
- "RBI files should be located in an allowed path, but AllowedPaths is empty or nil"
40
- else
41
- "RBI file path should match one of: #{allowed_paths.join(", ")}"
42
- end
58
+ paths = cop_config["AllowedPaths"]
59
+ return nil unless paths.is_a?(Array)
60
+ paths.compact
43
61
  end
44
62
  end
45
63
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module RuboCop
3
3
  module Sorbet
4
- VERSION = "0.6.3"
4
+ VERSION = "0.6.4"
5
5
  end
6
6
  end
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.6.3
4
+ version: 0.6.4
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: 2021-12-03 00:00:00.000000000 Z
14
+ date: 2021-12-09 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec