rubocop-infinum 0.9.0 → 1.0.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 +8 -0
- data/README.md +5 -4
- 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/plugin.rb +33 -0
- data/lib/rubocop/infinum/version.rb +1 -1
- data/lib/rubocop-infinum.rb +1 -0
- data/rubocop-infinum.gemspec +8 -4
- data/rubocop.yml +3 -1
- metadata +55 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15c594d1defeb4fe076eb18d219cd1c966bd0ad50c642ad8b1f45b9d0605ce39
|
4
|
+
data.tar.gz: 8d398bdc3702b8762b363ea922f71d38c6e0faaeb682c4ac0f429599781f348a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44a30428a78b3da72521d0dc3d19062839e1e687f22f4776eec4a6d4fa125418bbe65120387d0826958dff7043197c7ec822df5aefa2fc860fecd97bdc8002ac
|
7
|
+
data.tar.gz: 28eae8d7b3ce7da5bafb34ce42b5f8bdee3473f2e99ed072457e56f0f324c9733912ba8b1a54ca94610c5025cdcb0db6ead950bcabfff73f8f9610969b88e05f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# RuboCop Infinum Change Log
|
2
2
|
|
3
|
+
## 1.0.0 (Jun 12th 2025)
|
4
|
+
|
5
|
+
- Pluginify Rubocop Infinum (PR[#23](https://github.com/infinum/rubocop-infinum/pull/23) @imnastasia)
|
6
|
+
|
7
|
+
## 0.9.1 (Oct 24th 2024)
|
8
|
+
|
9
|
+
- 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)
|
10
|
+
|
3
11
|
## 0.9.0 (Oct 7th 2024)
|
4
12
|
|
5
13
|
- "Cop#corrections is deprecated" warning fixed ([PR#21](https://github.com/infinum/rubocop-infinum/pull/21) tnx @unavailabl3)
|
data/README.md
CHANGED
@@ -11,10 +11,11 @@ To use it, you can add this to your `Gemfile` (`group :development`):
|
|
11
11
|
And add to the top of your project's RuboCop configuration file:
|
12
12
|
|
13
13
|
~~~yml
|
14
|
-
|
15
|
-
rubocop-infinum: rubocop.yml
|
16
|
-
|
17
|
-
require: rubocop-infinum
|
14
|
+
plugins: rubocop-infinum
|
18
15
|
~~~
|
19
16
|
|
17
|
+
|
18
|
+
> [!NOTE]
|
19
|
+
> The plugin system is supported in RuboCop 1.72+. In earlier versions, use `require` instead of `plugins`.
|
20
|
+
|
20
21
|
If you dislike some rules, please check [RuboCop's documentation](https://rubocop.readthedocs.io/en/latest/configuration/#inheriting-configuration-from-a-dependency-gem) on inheriting configuration from a gem.
|
@@ -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?
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubocop/infinum/version'
|
4
|
+
require 'lint_roller'
|
5
|
+
|
6
|
+
module RuboCop
|
7
|
+
module Infinum
|
8
|
+
# The main plugin class for RuboCop Infinum.
|
9
|
+
class Plugin < LintRoller::Plugin
|
10
|
+
def about
|
11
|
+
LintRoller::About.new(
|
12
|
+
name: 'rubocop-infinum',
|
13
|
+
version: VERSION,
|
14
|
+
homepage: 'https://github.com/infinum/rubocop-infinum',
|
15
|
+
description: 'This plugin provides the RuboCop configuration file ' \
|
16
|
+
'alongside some custom cops used at Infinum.'
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def supported?(context)
|
21
|
+
context.engine == :rubocop
|
22
|
+
end
|
23
|
+
|
24
|
+
def rules(_context)
|
25
|
+
LintRoller::Rules.new(
|
26
|
+
type: :path,
|
27
|
+
config_format: :rubocop,
|
28
|
+
value: Pathname.new(__dir__).join('../../../rubocop.yml')
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/rubocop-infinum.rb
CHANGED
data/rubocop-infinum.gemspec
CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
18
18
|
spec.metadata['homepage_uri'] = spec.homepage
|
19
19
|
spec.metadata['source_code_uri'] = 'https://github.com/infinum/rubocop-infinum'
|
20
|
+
spec.metadata['default_lint_roller_plugin'] = 'RuboCop::Infinum::Plugin'
|
20
21
|
|
21
22
|
# Specify which files should be added to the gem when it is released.
|
22
23
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -30,8 +31,11 @@ Gem::Specification.new do |spec|
|
|
30
31
|
spec.add_development_dependency('pry-byebug', '< 4')
|
31
32
|
spec.add_development_dependency('rspec', '~> 3.9')
|
32
33
|
|
33
|
-
spec.
|
34
|
-
spec.
|
35
|
-
spec.add_runtime_dependency('rubocop-
|
36
|
-
spec.add_runtime_dependency('rubocop-performance')
|
34
|
+
spec.add_dependency('lint_roller')
|
35
|
+
spec.add_dependency('rubocop', '>= 1.72.1')
|
36
|
+
spec.add_runtime_dependency('rubocop-factory_bot', '>=2.27.1')
|
37
|
+
spec.add_runtime_dependency('rubocop-performance', '>= 1.24.0')
|
38
|
+
spec.add_runtime_dependency('rubocop-rails', '>= 2.30.0')
|
39
|
+
spec.add_runtime_dependency('rubocop-rspec', '>= 3.5.0')
|
40
|
+
spec.add_runtime_dependency('rubocop-rspec_rails', '>= 2.31.0')
|
37
41
|
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.
|
4
|
+
version: 1.0.0
|
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:
|
13
|
+
date: 2025-06-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: pry-byebug
|
@@ -40,62 +40,104 @@ dependencies:
|
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '3.9'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: lint_roller
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
43
57
|
- !ruby/object:Gem::Dependency
|
44
58
|
name: rubocop
|
45
59
|
requirement: !ruby/object:Gem::Requirement
|
46
60
|
requirements:
|
47
61
|
- - ">="
|
48
62
|
- !ruby/object:Gem::Version
|
49
|
-
version: 1.
|
63
|
+
version: 1.72.1
|
50
64
|
type: :runtime
|
51
65
|
prerelease: false
|
52
66
|
version_requirements: !ruby/object:Gem::Requirement
|
53
67
|
requirements:
|
54
68
|
- - ">="
|
55
69
|
- !ruby/object:Gem::Version
|
56
|
-
version: 1.
|
70
|
+
version: 1.72.1
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: rubocop-factory_bot
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.27.1
|
78
|
+
type: :runtime
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 2.27.1
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: rubocop-performance
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 1.24.0
|
92
|
+
type: :runtime
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 1.24.0
|
57
99
|
- !ruby/object:Gem::Dependency
|
58
100
|
name: rubocop-rails
|
59
101
|
requirement: !ruby/object:Gem::Requirement
|
60
102
|
requirements:
|
61
103
|
- - ">="
|
62
104
|
- !ruby/object:Gem::Version
|
63
|
-
version:
|
105
|
+
version: 2.30.0
|
64
106
|
type: :runtime
|
65
107
|
prerelease: false
|
66
108
|
version_requirements: !ruby/object:Gem::Requirement
|
67
109
|
requirements:
|
68
110
|
- - ">="
|
69
111
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
112
|
+
version: 2.30.0
|
71
113
|
- !ruby/object:Gem::Dependency
|
72
114
|
name: rubocop-rspec
|
73
115
|
requirement: !ruby/object:Gem::Requirement
|
74
116
|
requirements:
|
75
117
|
- - ">="
|
76
118
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
119
|
+
version: 3.5.0
|
78
120
|
type: :runtime
|
79
121
|
prerelease: false
|
80
122
|
version_requirements: !ruby/object:Gem::Requirement
|
81
123
|
requirements:
|
82
124
|
- - ">="
|
83
125
|
- !ruby/object:Gem::Version
|
84
|
-
version:
|
126
|
+
version: 3.5.0
|
85
127
|
- !ruby/object:Gem::Dependency
|
86
|
-
name: rubocop-
|
128
|
+
name: rubocop-rspec_rails
|
87
129
|
requirement: !ruby/object:Gem::Requirement
|
88
130
|
requirements:
|
89
131
|
- - ">="
|
90
132
|
- !ruby/object:Gem::Version
|
91
|
-
version:
|
133
|
+
version: 2.31.0
|
92
134
|
type: :runtime
|
93
135
|
prerelease: false
|
94
136
|
version_requirements: !ruby/object:Gem::Requirement
|
95
137
|
requirements:
|
96
138
|
- - ">="
|
97
139
|
- !ruby/object:Gem::Version
|
98
|
-
version:
|
140
|
+
version: 2.31.0
|
99
141
|
description:
|
100
142
|
email:
|
101
143
|
- team.backend@infinum.com
|
@@ -117,6 +159,7 @@ files:
|
|
117
159
|
- lib/rubocop/cop/infinum/factory_bot_association.rb
|
118
160
|
- lib/rubocop/cop/infinum_cops.rb
|
119
161
|
- lib/rubocop/infinum.rb
|
162
|
+
- lib/rubocop/infinum/plugin.rb
|
120
163
|
- lib/rubocop/infinum/version.rb
|
121
164
|
- rubocop-infinum.gemspec
|
122
165
|
- rubocop.yml
|
@@ -127,6 +170,7 @@ metadata:
|
|
127
170
|
allowed_push_host: https://rubygems.org
|
128
171
|
homepage_uri: https://github.com/infinum/rubocop-infinum
|
129
172
|
source_code_uri: https://github.com/infinum/rubocop-infinum
|
173
|
+
default_lint_roller_plugin: RuboCop::Infinum::Plugin
|
130
174
|
post_install_message:
|
131
175
|
rdoc_options: []
|
132
176
|
require_paths:
|