rubocop-gusto 10.0.1 → 10.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d5f9caaca5dbe1a2cdd70a064d7bf6f5a29a029ae5bc5efe9071613785a698c
4
- data.tar.gz: 1b355982894e5ef91090dfb8e2d0fe4d301690d55d47c485f0951c2d38f1a77e
3
+ metadata.gz: 53a74cd600bf2446b894971dad3e18c55cf1f3c76485c3a5b4f00c65d672f658
4
+ data.tar.gz: a39f3b4113a0ac8f9ab0abb1d4d1b8ca77f540f620873db86e533bc465221bf5
5
5
  SHA512:
6
- metadata.gz: 48e622d548efed1455bccd269a0c3e459d9149e4e782058f0540505e7a528bb7e1c6ce3d5cbede01f2be62b587ef11cfd2a32ba914f2806f36a4fa57117d4f3a
7
- data.tar.gz: c11542ccc1d6029a8b15cc1ef89de87adcbb8fb2ed7eb0492efc4ce90454f959877b73daaddcdaf443417ebab40a78f60343024ca7f323fa4f1380e6b82c2c55
6
+ metadata.gz: 6b23cefe43c61ff7af9988fd5e0eeb7e63fadf62ee961e77edd65a132a3ccbb7c92541ff3206b1e217128d8676933bf37c650c3d6abb8416742828125e4c62a3
7
+ data.tar.gz: 04c1cb8f540994333c88372160840f00d4b51bbd9bfa093238ef65edcab9f15837496729c4621e7930c57e2312af61749642c0d4c4cf0d11f88eae4c59174538
data/config/default.yml CHANGED
@@ -58,6 +58,9 @@ Gusto/FactoryClassesOrModules:
58
58
  Include:
59
59
  - 'spec/**/factories/*.rb'
60
60
 
61
+ Gusto/IgnoredColumnsAssignment:
62
+ Description: 'Use `+=` with an array for `ignored_columns` assignment instead of direct assignment.'
63
+
61
64
  Gusto/MinByMaxBy:
62
65
  Description: 'Checks for the use of `min` or `max` with a proc. Corrects to `min_by` or `max_by`.'
63
66
  Safe: false
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Gusto
6
+ # Enforces proper usage of `ignored_columns` assignment
7
+ #
8
+ # This cop ensures that `ignored_columns` is assigned using `+=` with an array
9
+ # instead of direct assignment, which will overwrite the existing list of
10
+ # ignored columns for the model, or overwrite the list it should inherit in the
11
+ # case of single table inheritance.
12
+ #
13
+ # @example
14
+ #
15
+ # # bad
16
+ # self.ignored_columns = :column_name
17
+ # self.ignored_columns = 'column_name'
18
+ # self.ignored_columns = [:column_name]
19
+ # self.ignored_columns = ['column_name']
20
+ #
21
+ # # good
22
+ # self.ignored_columns += [:column_name]
23
+ # self.ignored_columns += ['column_name']
24
+ #
25
+ class IgnoredColumnsAssignment < Base
26
+ MSG = 'Use `+=` with an array for `ignored_columns` assignment instead of direct assignment.'
27
+ RESTRICT_ON_SEND = %i(ignored_columns=).freeze
28
+
29
+ # @!method ignored_columns_direct_assignment?(node)
30
+ def_node_matcher :ignored_columns_direct_assignment?, <<~PATTERN
31
+ (send (self) :ignored_columns= _)
32
+ PATTERN
33
+
34
+ def on_send(node)
35
+ if ignored_columns_direct_assignment?(node)
36
+ add_offense(node.loc.selector)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Gusto
5
- VERSION = '10.0.1'
5
+ VERSION = '10.1.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-gusto
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.1
4
+ version: 10.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gusto Engineering
@@ -127,6 +127,7 @@ files:
127
127
  - lib/rubocop/cop/gusto/datadog_constant.rb
128
128
  - lib/rubocop/cop/gusto/execute_migration.rb
129
129
  - lib/rubocop/cop/gusto/factory_classes_or_modules.rb
130
+ - lib/rubocop/cop/gusto/ignored_columns_assignment.rb
130
131
  - lib/rubocop/cop/gusto/min_by_max_by.rb
131
132
  - lib/rubocop/cop/gusto/no_metaprogramming.rb
132
133
  - lib/rubocop/cop/gusto/no_rescue_error_message_checking.rb
@@ -172,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
173
  - !ruby/object:Gem::Version
173
174
  version: '0'
174
175
  requirements: []
175
- rubygems_version: 3.6.9
176
+ rubygems_version: 3.7.1
176
177
  specification_version: 4
177
178
  summary: A gem for sharing gusto rubocop rules
178
179
  test_files: []