rubocop-vendor 0.8.11 → 0.9.0
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/lib/rubocop/cop/vendor/strict_dry_struct.rb +32 -0
- data/lib/rubocop/cop/vendor_cops.rb +1 -0
- data/lib/rubocop/vendor/version.rb +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: e0a0ab973af3d0686d5569926ca7f0187c7e2d0f99d07c1d120dc5b5d66fdc27
|
4
|
+
data.tar.gz: a0ccd57f7940618b66cb39577e1ad253b779b0596fe86fd29aa27306e7ba8a3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0897ba86f964e4ce2d3e6b2713b10cda03630136b24f8d4ab2dddd0bceae011917b2af9fc145386cefd77dd310e4c6c61d31ae5bb73b99ba2776d539aaa5c0ee'
|
7
|
+
data.tar.gz: 9cab6bf36f9ad72bd1ce1c298bf341759439d719b56b842751a1694863cc7e2adb598bad348ab0f6a590564a38cdd9af800e927695d5715198b9aaea53e1f7da
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Vendor
|
6
|
+
# This cop flags uses of DryStruct without strict mode
|
7
|
+
#
|
8
|
+
# By default DryStruct will not throw an error if passed an attribute that wasn't defined.
|
9
|
+
# We want to enfore strict mode which will throw an error in that case.
|
10
|
+
class StrictDryStruct < RuboCop::Cop::Base
|
11
|
+
MSG = 'Avoid using `Dry::Struct` without schema schema.strict'
|
12
|
+
|
13
|
+
# @!method uses_dry_struct?(node)
|
14
|
+
def_node_matcher :uses_dry_struct?, <<-PATTERN
|
15
|
+
(const (const {nil? (cbase)} :Dry) :Struct)
|
16
|
+
PATTERN
|
17
|
+
|
18
|
+
# @!method uses_strict_mode?(node)
|
19
|
+
def_node_search :uses_strict_mode?, <<-PATTERN
|
20
|
+
(send nil? :schema (send (send nil? :schema) :strict))
|
21
|
+
PATTERN
|
22
|
+
|
23
|
+
def on_const(node)
|
24
|
+
return unless uses_dry_struct?(node)
|
25
|
+
return if uses_strict_mode?(node.parent)
|
26
|
+
|
27
|
+
add_offense(node)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-vendor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danilo Cabello
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-
|
13
|
+
date: 2023-03-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- lib/rubocop/cop/vendor/rollbar_log.rb
|
91
91
|
- lib/rubocop/cop/vendor/rollbar_logger.rb
|
92
92
|
- lib/rubocop/cop/vendor/rollbar_with_exception.rb
|
93
|
+
- lib/rubocop/cop/vendor/strict_dry_struct.rb
|
93
94
|
- lib/rubocop/cop/vendor_cops.rb
|
94
95
|
- lib/rubocop/vendor.rb
|
95
96
|
- lib/rubocop/vendor/inject.rb
|