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: 578bdfb074760ab399c493dc51e8bd5a3bf0098edc7953e7d13efd398069eb4e
4
- data.tar.gz: 1637cf8a334a77a3c0f99c78a1f53341c19ab42c54cb2a714c88cd52a83444de
3
+ metadata.gz: 4afcbde13fc201b72f5e4e9b2c16e1fb7a3192d34bc6a24149145552c75930ef
4
+ data.tar.gz: 24be28d0b9c720b9acdbb5667de251f75e96fbf23ae43981148fb0045eb2487d
5
5
  SHA512:
6
- metadata.gz: 15d50680c6225568be85e679a8ab74c11ec81f90d51219ffc14bae2a061c6a7e7c3c3205a9c10e7b2fd3187170e1c63669f8fdb8185e46a9ec9b03d4858d255a
7
- data.tar.gz: 2a6e1b2af5dabacb58fb9ad107ff52c5bb8d3cb8a4c1193113cd333aa50027c98d89ecf3da2824aff060071afbf82aeb9888eb41b0ec21ff5411631ba3fb37fe
6
+ metadata.gz: 99e702405d46d9b18ec950aa0f945b42674a6fabd3bbf5840dae78c60835afb1dcb871359cf396e553856bd1fbf66b453f4dce3815c170e574e5274f41691299
7
+ data.tar.gz: 60b3ef3bdcbd355fe2a25fc93be9a6bf9f17e8a460e65fc67fa06fb766f59819bb92e714a10e111f70bb8522dab3ac0c8f3e28a99491ab7ee1738dc6eab7264e
@@ -1,3 +1,3 @@
1
1
  module ImmosquareCleaner
2
- VERSION = "0.1.24".freeze
2
+ VERSION = "0.1.25".freeze
3
3
  end
@@ -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.24
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