rubocop_method_order 0.2.1 → 0.3.0
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/.gitignore +1 -0
- data/.travis.yml +13 -1
- data/CHANGELOG.md +14 -1
- data/README.md +11 -3
- data/Rakefile +4 -3
- data/bin/release +8 -0
- data/lib/rubocop/cop/style/method_order.rb +27 -8
- data/lib/rubocop_method_order/version.rb +2 -2
- data/rubocop_method_order.gemspec +2 -2
- metadata +3 -3
- metadata.gz.sig +0 -0
- data/Gemfile.lock +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87a880d6efbf8d23a8105cf4f7bbc78f0008e4db5294231840fc33f47eb9ce7a
|
4
|
+
data.tar.gz: a0333f54dcf6441ff7d23e5917092a2b700ae208e7147c4a34c5d4e61a8546f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adf8186dfbf0214f75b85dffee0502b6afc950d63b05bc000ea3875f621687499807ffe433388f274657ac6020676062b24faede60f275e0800312c19c9a69ab
|
7
|
+
data.tar.gz: 4d1fc6c2cd011597fb5488c87604c43a092f9bac8a3dae1b3d11b7cb6fbefc8705aaf2afa24a5daad59b52da0f985417bcff7cea0a6a1c543c102cadac92f7c2
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
sudo: false
|
2
2
|
language: ruby
|
3
3
|
rvm:
|
4
|
+
- jruby-head
|
5
|
+
- 2.4.3
|
4
6
|
- 2.5.0
|
5
|
-
|
7
|
+
- ruby-head
|
8
|
+
matrix:
|
9
|
+
allow_failures:
|
10
|
+
- rvm: ruby-head
|
11
|
+
- rvm: jruby-head
|
12
|
+
fast_finish: true
|
13
|
+
before_install:
|
14
|
+
- gem update --system
|
15
|
+
- gem update --remote bundler
|
16
|
+
install:
|
17
|
+
- bundle install --retry=3
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
5
5
|
|
6
6
|
## [unreleased]
|
7
7
|
|
8
|
+
## [0.3.0] - 2018-04-20
|
9
|
+
|
10
|
+
### Added
|
11
|
+
|
12
|
+
* Tie in Travis-CI for testing.
|
13
|
+
* New `bin/release` script to make sure tests are ran before release.
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
|
17
|
+
* Include comments immediately following a method definition when auto-correcting.
|
18
|
+
* Correct source range calculation if looping over start or end of file.
|
19
|
+
|
8
20
|
## [0.2.1] - 2018-03-22
|
9
21
|
|
10
22
|
### Fixed
|
@@ -25,7 +37,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
25
37
|
|
26
38
|
* Initial version of the extension.
|
27
39
|
|
28
|
-
[unreleased]: https://github.com/CoffeeAndCode/rubocop_method_order/compare/v0.
|
40
|
+
[unreleased]: https://github.com/CoffeeAndCode/rubocop_method_order/compare/v0.3.0...HEAD
|
41
|
+
[0.3.0]: https://github.com/CoffeeAndCode/rubocop_method_order/compare/v0.2.1...v0.3.0
|
29
42
|
[0.2.1]: https://github.com/CoffeeAndCode/rubocop_method_order/compare/v0.2.0...v0.2.1
|
30
43
|
[0.2.0]: https://github.com/CoffeeAndCode/rubocop_method_order/compare/v0.1.0...v0.2.0
|
31
44
|
[0.1.0]: https://github.com/CoffeeAndCode/rubocop_method_order/releases/tag/v0.1.0
|
data/README.md
CHANGED
@@ -144,9 +144,17 @@ To install this gem onto your local machine, run `bundle exec rake install`.
|
|
144
144
|
Make sure that the project has no errors when running `bundle exec rake` which
|
145
145
|
will run `rubocop` on the project source and `bundle exec rake test`.
|
146
146
|
|
147
|
-
To release a new version, update the version number in `lib/rubocop_method_order/version.rb` and run `
|
148
|
-
|
149
|
-
|
147
|
+
To release a new version, update the version number in `lib/rubocop_method_order/version.rb` and run `bin/release`, which will do
|
148
|
+
the following:
|
149
|
+
|
150
|
+
* run tests
|
151
|
+
* run linters
|
152
|
+
* create a git tag for the version
|
153
|
+
* push git commits and tags
|
154
|
+
* push the `.gem` file to [rubygems.org][2]
|
155
|
+
* create checksums of new version
|
156
|
+
|
157
|
+
New checksum will be generated for the latest gem version which should
|
150
158
|
be added to the `master` branch.
|
151
159
|
|
152
160
|
## Contributing
|
data/Rakefile
CHANGED
@@ -11,7 +11,10 @@ Rake::TestTask.new(:test) do |t|
|
|
11
11
|
end
|
12
12
|
RuboCop::RakeTask.new
|
13
13
|
|
14
|
-
|
14
|
+
task default: %i[test rubocop]
|
15
|
+
|
16
|
+
desc 'Generate checksum files for current gem version.'
|
17
|
+
task :checksum do |_task|
|
15
18
|
require 'digest/sha2'
|
16
19
|
require_relative './lib/rubocop_method_order/version'
|
17
20
|
|
@@ -25,5 +28,3 @@ Rake::Task['release'].enhance do
|
|
25
28
|
checksum_path = "checksums/rubocop_method_order-#{RuboCopMethodOrder.gem_version}.gem.sha512"
|
26
29
|
File.open(checksum_path, 'w') { |file| file.write(checksum) }
|
27
30
|
end
|
28
|
-
|
29
|
-
task default: %i[test rubocop]
|
data/bin/release
ADDED
@@ -100,7 +100,7 @@ module RuboCop
|
|
100
100
|
#
|
101
101
|
# def foo
|
102
102
|
# end
|
103
|
-
class MethodOrder < Cop
|
103
|
+
class MethodOrder < Cop # rubocop:disable Metrics/ClassLength
|
104
104
|
include RangeHelp
|
105
105
|
|
106
106
|
MSG = 'Methods should be sorted in alphabetical order within their section' \
|
@@ -172,6 +172,7 @@ module RuboCop
|
|
172
172
|
|
173
173
|
private
|
174
174
|
|
175
|
+
# rubocop:disable Metrics/MethodLength
|
175
176
|
def begin_pos_with_comments(node)
|
176
177
|
range = node.source_range
|
177
178
|
begin_of_first_line = range.begin_pos - range.column
|
@@ -179,13 +180,15 @@ module RuboCop
|
|
179
180
|
|
180
181
|
loop do
|
181
182
|
line_number -= 1
|
183
|
+
break if line_number <= 0
|
182
184
|
source_line = @processed_source.buffer.source_line(line_number)
|
183
185
|
break unless source_line.match?(/\s*#/)
|
184
186
|
|
185
|
-
begin_of_first_line -= source_line.length + 1 # account for \n char
|
187
|
+
begin_of_first_line -= (source_line.length + 1) # account for \n char
|
186
188
|
end
|
187
189
|
begin_of_first_line
|
188
190
|
end
|
191
|
+
# rubocop:enable Metrics/MethodLength
|
189
192
|
|
190
193
|
def check_nodes
|
191
194
|
@method_collector.nodes_by_scope.values.each do |method_collection|
|
@@ -202,17 +205,33 @@ module RuboCop
|
|
202
205
|
processed_source.comment_config.cop_enabled_at_line?(self, node.first_line)
|
203
206
|
end
|
204
207
|
|
205
|
-
|
208
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
209
|
+
def end_pos_with_comments(node)
|
206
210
|
range = node.source_range
|
207
211
|
last_line = @processed_source.buffer.source_line(range.last_line)
|
208
|
-
|
212
|
+
end_of_last_line = range.end_pos + last_line.length - range.last_column
|
213
|
+
line_number = node.source_range.last_line
|
209
214
|
|
210
|
-
if
|
211
|
-
|
212
|
-
else
|
213
|
-
end_position + 1
|
215
|
+
if line_number != @processed_source.lines.count
|
216
|
+
end_of_last_line += 1 # account for newline
|
214
217
|
end
|
218
|
+
|
219
|
+
loop do
|
220
|
+
line_number += 1
|
221
|
+
break if line_number > @processed_source.lines.count
|
222
|
+
source_line = @processed_source.buffer.source_line(line_number)
|
223
|
+
break unless source_line.match?(/\s*#/)
|
224
|
+
|
225
|
+
adjustment = 0
|
226
|
+
if line_number != @processed_source.lines.count
|
227
|
+
adjustment = 1 # account for newline
|
228
|
+
end
|
229
|
+
|
230
|
+
end_of_last_line += source_line.length + adjustment
|
231
|
+
end
|
232
|
+
end_of_last_line
|
215
233
|
end
|
234
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
216
235
|
|
217
236
|
def message(method_name, following_method_name)
|
218
237
|
format(MSG,
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
lib = File.expand_path('lib', __dir__)
|
5
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
-
require 'rubocop_method_order'
|
6
|
+
require 'rubocop_method_order/version'
|
7
7
|
|
8
8
|
Gem::Specification.new do |spec|
|
9
9
|
spec.name = 'rubocop_method_order'
|
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.signing_key = File.expand_path('~/.ssh/gem-private_key.pem')
|
31
31
|
end
|
32
32
|
|
33
|
-
spec.
|
33
|
+
spec.add_runtime_dependency 'rubocop', '~> 0.53'
|
34
34
|
|
35
35
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
36
36
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop_method_order
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Knapp
|
@@ -34,7 +34,7 @@ cert_chain:
|
|
34
34
|
XxvXYAfIUSbb6/CHtemZT4zsEprRuk8eADIYUTMyAt9d2roTcsRKgq20m+PZO+b+
|
35
35
|
DVnSbPSTRxaM+9Hds4CAzdoo5hIiLyvSXSqSRGgQEMT0yiFdK+6kRw==
|
36
36
|
-----END CERTIFICATE-----
|
37
|
-
date: 2018-
|
37
|
+
date: 2018-04-20 00:00:00.000000000 Z
|
38
38
|
dependencies:
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: rubocop
|
@@ -103,11 +103,11 @@ files:
|
|
103
103
|
- ".travis.yml"
|
104
104
|
- CHANGELOG.md
|
105
105
|
- Gemfile
|
106
|
-
- Gemfile.lock
|
107
106
|
- LICENSE
|
108
107
|
- README.md
|
109
108
|
- Rakefile
|
110
109
|
- bin/console
|
110
|
+
- bin/release
|
111
111
|
- bin/setup
|
112
112
|
- certs/coffeeandcode.pem
|
113
113
|
- lib/rubocop/cop/style/method_order.rb
|
metadata.gz.sig
CHANGED
Binary file
|
data/Gemfile.lock
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
rubocop_method_order (0.2.1)
|
5
|
-
rubocop (~> 0.53)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
ast (2.4.0)
|
11
|
-
minitest (5.11.3)
|
12
|
-
parallel (1.12.1)
|
13
|
-
parser (2.5.0.4)
|
14
|
-
ast (~> 2.4.0)
|
15
|
-
powerpack (0.1.1)
|
16
|
-
rainbow (3.0.0)
|
17
|
-
rake (12.3.0)
|
18
|
-
rubocop (0.54.0)
|
19
|
-
parallel (~> 1.10)
|
20
|
-
parser (>= 2.5)
|
21
|
-
powerpack (~> 0.1)
|
22
|
-
rainbow (>= 2.2.2, < 4.0)
|
23
|
-
ruby-progressbar (~> 1.7)
|
24
|
-
unicode-display_width (~> 1.0, >= 1.0.1)
|
25
|
-
ruby-progressbar (1.9.0)
|
26
|
-
unicode-display_width (1.3.0)
|
27
|
-
|
28
|
-
PLATFORMS
|
29
|
-
ruby
|
30
|
-
|
31
|
-
DEPENDENCIES
|
32
|
-
bundler (~> 1.16)
|
33
|
-
minitest (~> 5.0)
|
34
|
-
rake (~> 12.3)
|
35
|
-
rubocop_method_order!
|
36
|
-
|
37
|
-
BUNDLED WITH
|
38
|
-
1.16.1
|