rubocop-infinum 0.9.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/CHANGELOG.md +4 -0
- data/lib/rubocop/cop/infinum/attribute_default_block_value.rb +9 -10
- data/lib/rubocop/cop/infinum/factory_bot_association.rb +15 -12
- data/lib/rubocop/infinum/version.rb +1 -1
- data/rubocop-infinum.gemspec +3 -1
- data/rubocop.yml +2 -0
- metadata +31 -3
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/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
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
|
+
|
3
7
|
## 0.9.0 (Oct 7th 2024)
|
4
8
|
|
5
9
|
- "Cop#corrections is deprecated" warning fixed ([PR#21](https://github.com/infinum/rubocop-infinum/pull/21) tnx @unavailabl3)
|
@@ -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,7 +56,7 @@ 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
|
|
@@ -63,21 +66,21 @@ module RuboCop
|
|
63
66
|
|
64
67
|
message = format(MSG, association_name: association_name.to_s, factory_name: factory_name.first.to_s)
|
65
68
|
|
66
|
-
|
69
|
+
handle_offense(node, message)
|
67
70
|
end
|
68
71
|
end
|
69
72
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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}) }")
|
77
80
|
end
|
78
|
-
end
|
79
81
|
|
80
|
-
|
82
|
+
ignore_node(node)
|
83
|
+
end
|
81
84
|
|
82
85
|
def expression(node)
|
83
86
|
if node.block_type?
|
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,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-infinum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marko Ćilimković
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-10-
|
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
|
- - ">="
|