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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d188e2316802f6af64261650234eb6ee0d6cd34960faeb8caf1e84c2618ffc34
4
- data.tar.gz: ccde2a220b4a6b1b37147d44b5e10db1136528d3826fa94a2561c80905e35689
3
+ metadata.gz: d60149702eeab325d9a01d3cc342cb3f3c17cd3b5259035471861d7fc8b82a9f
4
+ data.tar.gz: c4217f8e309e715753c8b8b967407b2a0bbc87eb5f4be16e645cbc8927800a0e
5
5
  SHA512:
6
- metadata.gz: ff21a36e205c7099958a71b068017daea42700d43609b81a6056a9fce815cd1693701d198d92fe40d41feb47b60cef984f5588bc0a1a6824b5dd988250407dbf
7
- data.tar.gz: c6289c3727ebca03b4071382ab8f773133834b4a1ea3b250aa15a4e7713a17fd6cb272b5d1acb52f8aa8fb1152fc49e8e2a7ab404b66395b2051d957bf4cb3e5
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
@@ -10,3 +10,4 @@ require_relative 'vendor/rollbar_interpolation'
10
10
  require_relative 'vendor/rollbar_log'
11
11
  require_relative 'vendor/rollbar_logger'
12
12
  require_relative 'vendor/rollbar_with_exception'
13
+ require_relative 'vendor/strict_dry_struct'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Vendor
5
- VERSION = '0.8.11'
5
+ VERSION = '0.9.1'
6
6
  end
7
7
  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.8.11
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-02-03 00:00:00.000000000 Z
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