momocop 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd1936728acc124e621799990c68af8e6aa54c7cd984ce038efcbe8929c2416c
|
4
|
+
data.tar.gz: 0b6b2242cb847844e0279ff35193c391922facae5c32dc2ca86cf7778e97aebc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34e3af0e7bcb5a2b3091fa79e713ceb4fd50acc2bec9c7c815680fb93cb37e0052ba08d70e2adc35a5ba4718c4b622e738acfc0a0e6f33113021978eedb3b1f7
|
7
|
+
data.tar.gz: fa078fbc91b3bfe61ac9da25463b59eaab3871e882c16f9e59e8d40d04bb12d82e948d6c08d933a6534b7600661fb6ce13db3009fbfcf850d5ca4cdf2708ce85
|
data/.rubocop.yml
CHANGED
data/lib/momocop/version.rb
CHANGED
@@ -47,7 +47,7 @@ module RuboCop
|
|
47
47
|
unless block_node
|
48
48
|
add_offense(node, message: MSG) do |corrector|
|
49
49
|
indentation = ' ' * node.loc.column
|
50
|
-
corrector.
|
50
|
+
corrector.replace(node.source_range, "#{node.source} do\n#{indentation}end")
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -54,7 +54,7 @@ module RuboCop
|
|
54
54
|
unless block_node
|
55
55
|
add_offense(node, message: MSG) do |corrector|
|
56
56
|
indentation = ' ' * node.loc.column
|
57
|
-
corrector.
|
57
|
+
corrector.replace(node.source_range, "#{node.source} do\n#{indentation}end")
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -55,7 +55,9 @@ module RuboCop
|
|
55
55
|
|
56
56
|
sections =
|
57
57
|
entire_definitions
|
58
|
-
.slice_when { |a, b|
|
58
|
+
.slice_when { |a, b|
|
59
|
+
(range_with_comments(b).first_line - range_with_comments(a).last_line) > 1
|
60
|
+
}
|
59
61
|
.select { |definitions| definitions.size >= 2 }
|
60
62
|
|
61
63
|
sections.each do |definitions|
|
@@ -85,14 +87,28 @@ module RuboCop
|
|
85
87
|
|
86
88
|
private def defined_properties(block_node)
|
87
89
|
body_node = block_node&.children&.last
|
88
|
-
|
90
|
+
|
91
|
+
# empty block
|
92
|
+
return [] unless body_node
|
93
|
+
|
94
|
+
# begin
|
95
|
+
if body_node.begin_type?
|
96
|
+
body_node&.children&.select { |node| definition_node?(node) } || []
|
97
|
+
# block
|
98
|
+
elsif body_node.send_type? && definition_node?(body_node)
|
99
|
+
[body_node]
|
100
|
+
else
|
101
|
+
[]
|
102
|
+
end
|
89
103
|
end
|
90
104
|
|
105
|
+
RUBOCOP_HELPER_METHODS = %i[trait transient before after].freeze
|
106
|
+
|
91
107
|
private def definition_node?(node)
|
92
108
|
if node.send_type?
|
93
|
-
return node.method_name
|
109
|
+
return !RUBOCOP_HELPER_METHODS.include?(node.method_name)
|
94
110
|
elsif node.block_type? && node.children.first.send_type?
|
95
|
-
return node.children.first.method_name
|
111
|
+
return !RUBOCOP_HELPER_METHODS.include?(node.children.first.method_name)
|
96
112
|
end
|
97
113
|
|
98
114
|
return false
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: momocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- supermomonga
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.49.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 1.49.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rubocop-rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|