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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58fe0254e47cc59376f53d38640a163d0ba80dfba6f3f41998350b1b049010fd
4
- data.tar.gz: 969301c9b0ef1af7ab3170c63fd72f5f8d6b095de2c84f2818917a003afe59cb
3
+ metadata.gz: f744cb31d07cadbb924e1ce690b85ee2c771ff9264333c153fcc52244d596dd6
4
+ data.tar.gz: c594faf493963d8f188559ca1f77b7b8570c05b5936356d6fc259de2417200a7
5
5
  SHA512:
6
- metadata.gz: be7586aef6236eab74b74494893ed7af665f01c4879ea36f63d6695250170174175859c439e7a6dd39775095b1ae210fa80a8d4e2e4f8a3c177e6ccc060c9c81
7
- data.tar.gz: 7003edbafb17736c0e0bdfaaf65c1e1340fb45b684b31b1d573d6977f19e8c192700fb8bb4b57d0003f32753d2438110b6de937da42832a06641118c6e2b0c08
6
+ metadata.gz: ee20da1638b96c6256a257b6602afcc90a22b33c4988fd8a44b50d5f93b7ab311e7ce052f3aeef4dd0b08c40028cb1c371184a3569e8656086a96b685b62d4d9
7
+ data.tar.gz: 266bdf4e223ce62e269da6e850b22491d8b1dc052a8f686b972c895a86d29d067b4105e1716c78c9b5f7c2cd231b567ac1b26e58cac656f45843f2dabf5b432f
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.6.1 - 2022-07-04
6
+
7
+ ### Fixed
8
+
9
+ - Fix `Sevencop/HashLiteralOrder` on surrounding-space-less Hash.
10
+
5
11
  ## 0.6.0 - 2022-07-04
6
12
 
7
13
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sevencop (0.6.0)
4
+ sevencop (0.6.1)
5
5
  rubocop
6
6
 
7
7
  GEM
@@ -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
- whitespace,
61
- sort(node.pairs).map(&:source).join(",#{whitespace}"),
62
- whitespace_ending(node),
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, b: 1 }
90
- # ^^
91
- def whitespace_ending(node)
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, b: 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]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sevencop
4
- VERSION = '0.6.0'
4
+ VERSION = '0.6.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sevencop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura