rubocop-gusto 10.0.0 → 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 +4 -4
- data/CHANGELOG.md +4 -0
- data/config/default.yml +3 -0
- data/lib/rubocop/cop/gusto/ignored_columns_assignment.rb +42 -0
- data/lib/rubocop/gusto/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53a74cd600bf2446b894971dad3e18c55cf1f3c76485c3a5b4f00c65d672f658
|
4
|
+
data.tar.gz: a39f3b4113a0ac8f9ab0abb1d4d1b8ca77f540f620873db86e533bc465221bf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b23cefe43c61ff7af9988fd5e0eeb7e63fadf62ee961e77edd65a132a3ccbb7c92541ff3206b1e217128d8676933bf37c650c3d6abb8416742828125e4c62a3
|
7
|
+
data.tar.gz: 04c1cb8f540994333c88372160840f00d4b51bbd9bfa093238ef65edcab9f15837496729c4621e7930c57e2312af61749642c0d4c4cf0d11f88eae4c59174538
|
data/CHANGELOG.md
CHANGED
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
|
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.
|
4
|
+
version: 10.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gusto Engineering
|
@@ -43,14 +43,14 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
46
|
+
version: '1.76'
|
47
47
|
type: :runtime
|
48
48
|
prerelease: false
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '1.76'
|
54
54
|
- !ruby/object:Gem::Dependency
|
55
55
|
name: rubocop-performance
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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.
|
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: []
|