rubocop-discourse 3.7.0 → 3.7.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb795aa24e9b2d88571ef2140d2dce87afd493b20c5d1d643b8a58b3d7b97fd5
|
4
|
+
data.tar.gz: 7950d13ba0da8dbeb2a690f48f33f1df8e72dbfd00240f4da07172dfbe3f91c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f47590c8de489ac68e8ca6d4d5ec012a5cf07455ad63c123aa14963c6ef6dec3d9f934a5106b45f01fbdca5b34e70542ac77fe9e0b46d9bb828b06d21a934d41
|
7
|
+
data.tar.gz: be49ff2f39df90a0dec57f813b621570b7fe895656ac7b65f54e4938490bc6714fdbc9fb0b9b92fe19b82fa26fe1997ceae6c3cf2734eb637714e9880569ba97
|
@@ -26,9 +26,12 @@ module RuboCop
|
|
26
26
|
# # good
|
27
27
|
# fab!(:another_user) { Fabricate(:user) }
|
28
28
|
class FabricatorShorthand < Base
|
29
|
+
extend AutoCorrector
|
30
|
+
include IgnoredNode
|
31
|
+
|
29
32
|
def_node_matcher :offending_fabricator?, <<-MATCHER
|
30
33
|
(block
|
31
|
-
(send nil? :fab!
|
34
|
+
$(send nil? :fab!
|
32
35
|
(sym $_identifier))
|
33
36
|
(args)
|
34
37
|
(send nil? :Fabricate
|
@@ -36,15 +39,22 @@ module RuboCop
|
|
36
39
|
MATCHER
|
37
40
|
|
38
41
|
def on_block(node)
|
39
|
-
offending_fabricator?(node) do |
|
40
|
-
add_offense(
|
42
|
+
offending_fabricator?(node) do |expression, _identifier|
|
43
|
+
add_offense(
|
44
|
+
node,
|
45
|
+
message: message(expression.source)
|
46
|
+
) do |corrector|
|
47
|
+
next if part_of_ignored_node?(node)
|
48
|
+
corrector.replace(node, expression.source)
|
49
|
+
end
|
50
|
+
ignore_node(node)
|
41
51
|
end
|
42
52
|
end
|
43
53
|
|
44
54
|
private
|
45
55
|
|
46
|
-
def message(
|
47
|
-
"Use the fabricator shorthand:
|
56
|
+
def message(expression)
|
57
|
+
"Use the fabricator shorthand: `#{expression}`"
|
48
58
|
end
|
49
59
|
end
|
50
60
|
end
|
data/rubocop-discourse.gemspec
CHANGED
@@ -31,4 +31,19 @@ describe RuboCop::Cop::Discourse::FabricatorShorthand, :config do
|
|
31
31
|
end
|
32
32
|
RUBY
|
33
33
|
end
|
34
|
+
|
35
|
+
it "supports autocorrect" do
|
36
|
+
expect_offense(<<~RUBY)
|
37
|
+
RSpec.describe "Foo" do
|
38
|
+
fab!(:foo) { Fabricate(:foo) }
|
39
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Discourse/FabricatorShorthand: Use the fabricator shorthand: `fab!(:foo)`
|
40
|
+
end
|
41
|
+
RUBY
|
42
|
+
|
43
|
+
expect_correction(<<~RUBY)
|
44
|
+
RSpec.describe "Foo" do
|
45
|
+
fab!(:foo)
|
46
|
+
end
|
47
|
+
RUBY
|
48
|
+
end
|
34
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-discourse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.7.
|
4
|
+
version: 3.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Discourse Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|