sevencop 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/lib/rubocop/cop/sevencop/hash_literal_order.rb +19 -8
- data/lib/sevencop/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f744cb31d07cadbb924e1ce690b85ee2c771ff9264333c153fcc52244d596dd6
|
4
|
+
data.tar.gz: c594faf493963d8f188559ca1f77b7b8570c05b5936356d6fc259de2417200a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee20da1638b96c6256a257b6602afcc90a22b33c4988fd8a44b50d5f93b7ab311e7ce052f3aeef4dd0b08c40028cb1c371184a3569e8656086a96b685b62d4d9
|
7
|
+
data.tar.gz: 266bdf4e223ce62e269da6e850b22491d8b1dc052a8f686b972c895a86d29d067b4105e1716c78c9b5f7c2cd231b567ac1b26e58cac656f45843f2dabf5b432f
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -54,12 +54,11 @@ module RuboCop
|
|
54
54
|
# @param [RuboCop::AST::HashNode] node
|
55
55
|
# @return [String]
|
56
56
|
def autocorrect(node)
|
57
|
-
whitespace = whitespace_leading(node)
|
58
57
|
[
|
59
58
|
'{',
|
60
|
-
|
61
|
-
sort(node.pairs).map(&:source).join(",#{
|
62
|
-
|
59
|
+
whitespace_leading(node),
|
60
|
+
sort(node.pairs).map(&:source).join(",#{whitespace_between(node)}"),
|
61
|
+
whitespace_trailing(node),
|
63
62
|
'}'
|
64
63
|
].join
|
65
64
|
end
|
@@ -86,15 +85,27 @@ module RuboCop
|
|
86
85
|
|
87
86
|
# @param [RuboCop::AST::HashNode] node
|
88
87
|
# @return [String]
|
89
|
-
# { a: 1,
|
90
|
-
#
|
91
|
-
def
|
88
|
+
# { a: 1, b: 1 }
|
89
|
+
# ^^^
|
90
|
+
def whitespace_between(node)
|
91
|
+
if node.pairs.length >= 2
|
92
|
+
node.source[node.pairs[0].location.expression.end_pos + 1...node.pairs[1].location.expression.begin_pos]
|
93
|
+
else
|
94
|
+
' '
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# @param [RuboCop::AST::HashNode] node
|
99
|
+
# @return [String]
|
100
|
+
# { a: 1, b: 1 }
|
101
|
+
# ^^
|
102
|
+
def whitespace_trailing(node)
|
92
103
|
node.source[node.pairs[-1].location.expression.end_pos...node.location.end.begin_pos]
|
93
104
|
end
|
94
105
|
|
95
106
|
# @param [RuboCop::AST::HashNode] node
|
96
107
|
# @return [String]
|
97
|
-
# { a: 1,
|
108
|
+
# { a: 1, b: 1 }
|
98
109
|
# ^^^^
|
99
110
|
def whitespace_leading(node)
|
100
111
|
node.source[node.location.begin.end_pos...node.pairs[0].location.expression.begin_pos]
|
data/lib/sevencop/version.rb
CHANGED