immosquare-cleaner 0.1.24 → 0.1.25
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: 4afcbde13fc201b72f5e4e9b2c16e1fb7a3192d34bc6a24149145552c75930ef
|
4
|
+
data.tar.gz: 24be28d0b9c720b9acdbb5667de251f75e96fbf23ae43981148fb0045eb2487d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99e702405d46d9b18ec950aa0f945b42674a6fabd3bbf5840dae78c60835afb1dcb871359cf396e553856bd1fbf66b453f4dce3815c170e574e5274f41691299
|
7
|
+
data.tar.gz: 60b3ef3bdcbd355fe2a25fc93be9a6bf9f17e8a460e65fc67fa06fb766f59819bb92e714a10e111f70bb8522dab3ac0c8f3e28a99491ab7ee1738dc6eab7264e
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module RuboCop
|
2
|
+
module Cop
|
3
|
+
module Style
|
4
|
+
class MethodCallWithArgsParentheses
|
5
|
+
|
6
|
+
module RequireParentheses
|
7
|
+
private
|
8
|
+
|
9
|
+
##============================================================##
|
10
|
+
## https://github.com/rubocop/rubocop/blob/master/lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb#L31
|
11
|
+
## --
|
12
|
+
##
|
13
|
+
## We override this method to allow for the omission of parentheses
|
14
|
+
## for a new custom case "jbuider_style?"...
|
15
|
+
##
|
16
|
+
## ---Jbuilder block Example---
|
17
|
+
##
|
18
|
+
## Jbuilder.encode do |myjson|
|
19
|
+
## myjson.first_name "Jhon"
|
20
|
+
## myjson.last_name "Doe"
|
21
|
+
## myjson.id 12
|
22
|
+
## end
|
23
|
+
##
|
24
|
+
## ---- Jbuilder file Example ---
|
25
|
+
## json.first_name "Jhon"
|
26
|
+
## json.last_name "Doe"
|
27
|
+
## json.id 12
|
28
|
+
##============================================================##
|
29
|
+
def eligible_for_parentheses_omission?(node)
|
30
|
+
node.operator_method? || node.setter_method? || ignored_macro?(node) || jbuider_style?(node)
|
31
|
+
end
|
32
|
+
|
33
|
+
def jbuider_style?(node)
|
34
|
+
receiver, method_name = *node
|
35
|
+
return false unless receiver
|
36
|
+
|
37
|
+
##============================================================##
|
38
|
+
## Check if the node is in a Jbuilder block
|
39
|
+
##============================================================##
|
40
|
+
jbuilder_block_node = node.each_ancestor(:block).find do |ancestor_node|
|
41
|
+
block_method_name = ancestor_node.children.first.method_name
|
42
|
+
block_method_name == :encode && ancestor_node.children.first.receiver&.const_name == "Jbuilder"
|
43
|
+
end
|
44
|
+
|
45
|
+
##============================================================##
|
46
|
+
## Source Name is the name of the method called. Here in our
|
47
|
+
## block it will be "json" but it can be any value put in the
|
48
|
+
## Jbuilder.encode do |name|
|
49
|
+
## ----
|
50
|
+
## In .json.jbuilder files, it will always be "json"
|
51
|
+
##============================================================##
|
52
|
+
source_name = receiver.loc.expression.source
|
53
|
+
jbuilder_file = node.source_range.source_buffer.name.end_with?(".jbuilder")
|
54
|
+
|
55
|
+
|
56
|
+
(jbuilder_block_node || (source_name == "json" && jbuilder_file)) && !method_name.to_s.end_with?("=")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: immosquare-cleaner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IMMO SQUARE
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- linters/prettier.yml
|
121
121
|
- linters/rubocop-3.2.2.yml
|
122
122
|
- linters/rubocop.yml
|
123
|
+
- linters/rubocop/cop/style/method_call_with_args_parentheses_override.rb
|
123
124
|
- node_modules/.bin/acorn
|
124
125
|
- node_modules/.bin/color-support
|
125
126
|
- node_modules/.bin/eslint
|