rubocop-vendor 0.8.11 → 0.9.0

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: e0a0ab973af3d0686d5569926ca7f0187c7e2d0f99d07c1d120dc5b5d66fdc27
4
+ data.tar.gz: a0ccd57f7940618b66cb39577e1ad253b779b0596fe86fd29aa27306e7ba8a3f
5
5
  SHA512:
6
- metadata.gz: ff21a36e205c7099958a71b068017daea42700d43609b81a6056a9fce815cd1693701d198d92fe40d41feb47b60cef984f5588bc0a1a6824b5dd988250407dbf
7
- data.tar.gz: c6289c3727ebca03b4071382ab8f773133834b4a1ea3b250aa15a4e7713a17fd6cb272b5d1acb52f8aa8fb1152fc49e8e2a7ab404b66395b2051d957bf4cb3e5
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
@@ -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.0'
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.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-02-03 00:00:00.000000000 Z
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