rubocop_method_order 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +12 -2
- data/Gemfile.lock +1 -1
- data/lib/rubocop/cop/style/method_order.rb +21 -4
- data/lib/rubocop_method_order/version.rb +1 -1
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: def792f4f78a2a78d2cffad454cfd738ac29c51930fa4b7514120f43b36ca2d3
|
4
|
+
data.tar.gz: 417d5b458152c7110bd0a391f58b9637d387509e25d629ad9398a467984ead49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3aef9fedf03c3cfc070234056250960ea06f119b65a09bee868e6c894cfcd3d8d301454c4732a9f5221ff3418507e7b127a2fa56cf6bfbef1dd25837c2606d92
|
7
|
+
data.tar.gz: 678b55a3dddd9da59c469dd0de80f21fbf8d03c6ad85f9b3885a0e6782cb6aec9adcb086becbed5c731a8881d467f74c2523d0dc1ee0a5193c60c74edd578676
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -3,7 +3,16 @@ All notable changes to this project will be documented in this file.
|
|
3
3
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
4
4
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
5
5
|
|
6
|
-
## [
|
6
|
+
## [unreleased]
|
7
|
+
|
8
|
+
## [0.2.1] - 2018-03-22
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
|
12
|
+
* Fix bug when trying to work with last method in file if there is no blank
|
13
|
+
ending line in the file.
|
14
|
+
|
15
|
+
## [0.2.0] - 2018-03-22
|
7
16
|
|
8
17
|
### Fixed
|
9
18
|
|
@@ -16,6 +25,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
16
25
|
|
17
26
|
* Initial version of the extension.
|
18
27
|
|
19
|
-
[unreleased]: https://github.com/CoffeeAndCode/rubocop_method_order/compare/v0.2.
|
28
|
+
[unreleased]: https://github.com/CoffeeAndCode/rubocop_method_order/compare/v0.2.1...HEAD
|
29
|
+
[0.2.1]: https://github.com/CoffeeAndCode/rubocop_method_order/compare/v0.2.0...v0.2.1
|
20
30
|
[0.2.0]: https://github.com/CoffeeAndCode/rubocop_method_order/compare/v0.1.0...v0.2.0
|
21
31
|
[0.1.0]: https://github.com/CoffeeAndCode/rubocop_method_order/releases/tag/v0.1.0
|
data/Gemfile.lock
CHANGED
@@ -106,7 +106,9 @@ module RuboCop
|
|
106
106
|
MSG = 'Methods should be sorted in alphabetical order within their section' \
|
107
107
|
' of the code. Method `%<method>s` should come before `%<previous_method>s`.'
|
108
108
|
|
109
|
-
|
109
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity,
|
110
|
+
# rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity
|
111
|
+
def autocorrect(_node)
|
110
112
|
lambda do |corrector|
|
111
113
|
@method_collector.nodes_by_scope.values.each do |method_collection|
|
112
114
|
next if @autocorrected_method_collections.include?(method_collection)
|
@@ -119,12 +121,21 @@ module RuboCop
|
|
119
121
|
@autocorrected_nodes << node_to_move
|
120
122
|
node_source = range_with_method_comments(node_to_move).source
|
121
123
|
replacement_range = range_with_method_comments(node_to_replace)
|
122
|
-
|
124
|
+
|
125
|
+
if node_source.end_with?("\n") && !replacement_range.source.end_with?("\n")
|
126
|
+
corrector.replace(replacement_range, node_source.chomp("\n"))
|
127
|
+
elsif !node_source.end_with?("\n") && replacement_range.source.end_with?("\n")
|
128
|
+
corrector.replace(replacement_range, node_source + "\n")
|
129
|
+
else
|
130
|
+
corrector.replace(replacement_range, node_source)
|
131
|
+
end
|
123
132
|
end
|
124
133
|
end
|
125
134
|
end
|
126
135
|
end
|
127
136
|
end
|
137
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity,
|
138
|
+
# rubocop:enable Metrics/MethodLength, Metrics/PerceivedComplexity
|
128
139
|
|
129
140
|
def investigate(_processed_source)
|
130
141
|
@autocorrected_method_collections = []
|
@@ -191,10 +202,16 @@ module RuboCop
|
|
191
202
|
processed_source.comment_config.cop_enabled_at_line?(self, node.first_line)
|
192
203
|
end
|
193
204
|
|
194
|
-
def end_pos_with_comments(node)
|
205
|
+
def end_pos_with_comments(node) # rubocop:disable Metrics/AbcSize
|
195
206
|
range = node.source_range
|
196
207
|
last_line = @processed_source.buffer.source_line(range.last_line)
|
197
|
-
range.end_pos + last_line.length - range.last_column
|
208
|
+
end_position = range.end_pos + last_line.length - range.last_column
|
209
|
+
|
210
|
+
if node.source_range.last_line == @processed_source.lines.count
|
211
|
+
end_position
|
212
|
+
else
|
213
|
+
end_position + 1
|
214
|
+
end
|
198
215
|
end
|
199
216
|
|
200
217
|
def message(method_name, following_method_name)
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|