rubocop-infinum 0.8.0 → 0.9.1
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/.ruby-version +1 -1
- data/CHANGELOG.md +8 -0
- data/lib/rubocop/cop/infinum/attribute_default_block_value.rb +9 -10
- data/lib/rubocop/cop/infinum/factory_bot_association.rb +20 -19
- data/lib/rubocop/infinum/version.rb +1 -1
- data/rubocop-infinum.gemspec +3 -1
- data/rubocop.yml +2 -0
- metadata +36 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ce5713f9db1163d89bd60b0652f459b189563603b773964156ae9614964b0db
|
4
|
+
data.tar.gz: e81816a32ff60fe369de3d87eb8c25ead930e4b78ce27f761697d8ab4691637e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d858611ef5b4551f1bfb54815a8cd7f5f78702555fa25beacdbadb3d3f9bf48f481b948e53b3c903e0112359397209c2d88d2e49860db2bf26129efa71761954
|
7
|
+
data.tar.gz: e7e33b3116f0db388c524e33125a32a4bf2f2f9fd8e699b787a01f8a8a431f37825cdf244dbf09c56abdab9983e839d60bde89a88164e0925bc500cd6722ecdd
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.1.0
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# RuboCop Infinum Change Log
|
2
2
|
|
3
|
+
## 0.9.1 (Oct 24th 2024)
|
4
|
+
|
5
|
+
- Resolved deprecated usage of `RuboCop::Cop::Cop` and updated cops to use new rubocop API (PR[#22](https://github.com/infinum/rubocop-infinum/pull/22) @PetarCurkovic)
|
6
|
+
|
7
|
+
## 0.9.0 (Oct 7th 2024)
|
8
|
+
|
9
|
+
- "Cop#corrections is deprecated" warning fixed ([PR#21](https://github.com/infinum/rubocop-infinum/pull/21) tnx @unavailabl3)
|
10
|
+
|
3
11
|
## 0.8.0 (May 11th, 2022)
|
4
12
|
|
5
13
|
- Remove TargetRubyVersion from rubocop yml template (@cilim)
|
@@ -18,7 +18,9 @@ module RuboCop
|
|
18
18
|
# class User < ActiveRecord::Base
|
19
19
|
# attribute :confirmed_at, :datetime, default: -> { Time.zone.now }
|
20
20
|
# end
|
21
|
-
class AttributeDefaultBlockValue < ::RuboCop::Cop::
|
21
|
+
class AttributeDefaultBlockValue < ::RuboCop::Cop::Base
|
22
|
+
extend AutoCorrector
|
23
|
+
|
22
24
|
MSG = 'Pass method in a block to `:default` option.'
|
23
25
|
|
24
26
|
def_node_matcher :default_attribute, <<~PATTERN
|
@@ -29,17 +31,14 @@ module RuboCop
|
|
29
31
|
|
30
32
|
def on_send(node)
|
31
33
|
default_attribute(node) do |hash_pair|
|
32
|
-
|
33
|
-
|
34
|
-
add_offense(node, location: value) if value.send_type?
|
35
|
-
end
|
36
|
-
end
|
34
|
+
target_node = attribute(hash_pair)
|
35
|
+
return unless target_node.send_type?
|
37
36
|
|
38
|
-
|
39
|
-
|
37
|
+
add_offense(target_node, message: MSG) do |corrector|
|
38
|
+
expression = attribute(default_attribute(node))
|
40
39
|
|
41
|
-
|
42
|
-
|
40
|
+
corrector.replace(target_node, "-> { #{expression.source} }")
|
41
|
+
end
|
43
42
|
end
|
44
43
|
end
|
45
44
|
end
|
@@ -38,7 +38,10 @@ module RuboCop
|
|
38
38
|
# name { 'J. R. R. Tolkien' }
|
39
39
|
# end
|
40
40
|
# end
|
41
|
-
class FactoryBotAssociation < ::RuboCop::Cop::
|
41
|
+
class FactoryBotAssociation < ::RuboCop::Cop::Base
|
42
|
+
extend AutoCorrector
|
43
|
+
include IgnoredNode
|
44
|
+
|
42
45
|
MSG = 'Use %<association_name>s { build(:%<factory_name>s) } instead'
|
43
46
|
|
44
47
|
def_node_matcher :association_definition, <<~PATTERN
|
@@ -53,40 +56,38 @@ module RuboCop
|
|
53
56
|
inline_association_definition(node) do |association_name, factory_name|
|
54
57
|
message = format(MSG, association_name: association_name.to_s, factory_name: factory_name.to_s)
|
55
58
|
|
56
|
-
|
59
|
+
handle_offense(node, message)
|
57
60
|
end
|
58
61
|
end
|
59
62
|
|
60
63
|
def on_send(node)
|
61
|
-
return unless corrections.empty?
|
62
|
-
|
63
64
|
association_definition(node) do |association_name, factory_name|
|
64
65
|
factory_name = [association_name] if factory_name.empty?
|
65
66
|
|
66
67
|
message = format(MSG, association_name: association_name.to_s, factory_name: factory_name.first.to_s)
|
67
68
|
|
68
|
-
|
69
|
+
handle_offense(node, message)
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
73
|
+
private
|
74
|
+
|
75
|
+
def handle_offense(node, message)
|
76
|
+
add_offense(node, message: message) do |corrector|
|
77
|
+
next if part_of_ignored_node?(node)
|
78
|
+
|
79
|
+
corrector.replace(node, "#{expression(node).first} { build(:#{expression(node).last}) }")
|
79
80
|
end
|
80
|
-
end
|
81
81
|
|
82
|
-
|
82
|
+
ignore_node(node)
|
83
|
+
end
|
83
84
|
|
84
85
|
def expression(node)
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
86
|
+
if node.block_type?
|
87
|
+
inline_association_definition(node)
|
88
|
+
else
|
89
|
+
association_definition(node).flatten
|
90
|
+
end
|
90
91
|
end
|
91
92
|
end
|
92
93
|
end
|
data/rubocop-infinum.gemspec
CHANGED
@@ -31,7 +31,9 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_development_dependency('rspec', '~> 3.9')
|
32
32
|
|
33
33
|
spec.add_runtime_dependency('rubocop', '>= 1.28.0')
|
34
|
+
spec.add_runtime_dependency('rubocop-factory_bot')
|
35
|
+
spec.add_runtime_dependency('rubocop-performance')
|
34
36
|
spec.add_runtime_dependency('rubocop-rails')
|
35
37
|
spec.add_runtime_dependency('rubocop-rspec')
|
36
|
-
spec.add_runtime_dependency('rubocop-
|
38
|
+
spec.add_runtime_dependency('rubocop-rspec_rails')
|
37
39
|
end
|
data/rubocop.yml
CHANGED
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-infinum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marko Ćilimković
|
8
8
|
- Stjepan Hađić
|
9
9
|
- Tin Benaković
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2024-10-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: pry-byebug
|
@@ -54,6 +54,34 @@ dependencies:
|
|
54
54
|
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: 1.28.0
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: rubocop-factory_bot
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
type: :runtime
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: rubocop-performance
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
type: :runtime
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
57
85
|
- !ruby/object:Gem::Dependency
|
58
86
|
name: rubocop-rails
|
59
87
|
requirement: !ruby/object:Gem::Requirement
|
@@ -83,7 +111,7 @@ dependencies:
|
|
83
111
|
- !ruby/object:Gem::Version
|
84
112
|
version: '0'
|
85
113
|
- !ruby/object:Gem::Dependency
|
86
|
-
name: rubocop-
|
114
|
+
name: rubocop-rspec_rails
|
87
115
|
requirement: !ruby/object:Gem::Requirement
|
88
116
|
requirements:
|
89
117
|
- - ">="
|
@@ -96,7 +124,7 @@ dependencies:
|
|
96
124
|
- - ">="
|
97
125
|
- !ruby/object:Gem::Version
|
98
126
|
version: '0'
|
99
|
-
description:
|
127
|
+
description:
|
100
128
|
email:
|
101
129
|
- team.backend@infinum.com
|
102
130
|
executables: []
|
@@ -127,7 +155,7 @@ metadata:
|
|
127
155
|
allowed_push_host: https://rubygems.org
|
128
156
|
homepage_uri: https://github.com/infinum/rubocop-infinum
|
129
157
|
source_code_uri: https://github.com/infinum/rubocop-infinum
|
130
|
-
post_install_message:
|
158
|
+
post_install_message:
|
131
159
|
rdoc_options: []
|
132
160
|
require_paths:
|
133
161
|
- lib
|
@@ -142,9 +170,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
170
|
- !ruby/object:Gem::Version
|
143
171
|
version: '0'
|
144
172
|
requirements: []
|
145
|
-
|
146
|
-
|
147
|
-
signing_key:
|
173
|
+
rubygems_version: 3.3.3
|
174
|
+
signing_key:
|
148
175
|
specification_version: 4
|
149
176
|
summary: Automatic Infinum code style checking tool.
|
150
177
|
test_files: []
|