rubocop-vendor 0.8.11 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubocop/cop/vendor/strict_dry_struct.rb +33 -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: d60149702eeab325d9a01d3cc342cb3f3c17cd3b5259035471861d7fc8b82a9f
|
4
|
+
data.tar.gz: c4217f8e309e715753c8b8b967407b2a0bbc87eb5f4be16e645cbc8927800a0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f9ae4df44bab2e0d5b769c3c5d625ba9f005d07b24fc39991b367db317c1acfe5d1605d6eb33457a2c092a473a882a96b67b47f89334f2ccd88ca51a8e72481
|
7
|
+
data.tar.gz: f3a3b42987b7be2a7b6bc1307e1ba78ce09143089e53d43a8bc9ac16d7f285f5c90049d243be90846c0cd67ca345dfd39ffdb385bc223d6cad03ccd5e716cbac
|
@@ -0,0 +1,33 @@
|
|
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 unless node.parent.class_type?
|
26
|
+
return if uses_strict_mode?(node.parent)
|
27
|
+
|
28
|
+
add_offense(node)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
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.1
|
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-17 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
|