rubocop-sorbet 0.6.3 → 0.6.4
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +3 -5
- data/lib/rubocop/cop/sorbet/rbi/forbid_rbi_outside_of_allowed_paths.rb +29 -11
- data/lib/rubocop/sorbet/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff745a34cb220b2798dcae5138ade84288219f2ce6fb2d81c12d90258a722609
|
4
|
+
data.tar.gz: 3827b4ceb6ced335573ece62da965e8f3ecc4b97313887fd5da2b7b46e1d1877
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de19c77ff90f52a4e045509c1f7c82edb6c844a6eab9cf0d37f10d70fc7d08a6abc3b9c13cad7762445c77ed0125ed24044a068718553d48af781c84956541c1
|
7
|
+
data.tar.gz: 6dc626e0f057d495164b775f2730900acae4ea1b95d8944f42912fe20c26c416306ded1a5b4e321c47bb90bbb44b411d00f4b98f048c66df31346883ef88f635
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# Rubocop-Sorbet
|
2
2
|
|
3
|
-
[](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/
|
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/
|
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/
|
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:
|
28
|
-
) if
|
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"]
|
35
|
-
|
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
|
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.
|
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-
|
14
|
+
date: 2021-12-09 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rspec
|