rubocop_auto_corrector 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +21 -0
- data/.travis.yml +4 -4
- data/CHANGELOG.md +7 -1
- data/Gemfile +2 -5
- data/Rakefile +2 -0
- data/bin/console +1 -0
- data/exe/rubocop_auto_corrector +8 -1
- data/lib/rubocop_auto_corrector.rb +2 -0
- data/lib/rubocop_auto_corrector/cli.rb +4 -4
- data/lib/rubocop_auto_corrector/cop_finder.rb +6 -2
- data/lib/rubocop_auto_corrector/version.rb +3 -1
- data/rubocop_auto_corrector.gemspec +5 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fcacd6c245988923e7e9f5a44f02e20226369b433e9ca1aad691cf1636c1fac
|
4
|
+
data.tar.gz: 1fab84587b05f21efc81891a0c1f02bf8020e8b2ab11f6cf87422434e838b3d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43b4bed17887468a0a4ba30e5f8192e2dc7eec0f75f2097eae8b766260d4738e19ae592e5f2a642cf4165e8795da8e7825f5880abe62bf23bdb84e05d658710d
|
7
|
+
data.tar.gz: fc22e5c34695d74fb16b9252a2e304a13f4c87cf72e0ba44e197ed75e628671d0cf3259ba19f04913c4d7fc959d954c6c59cd73d0655c18510b1cab5675f082a
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.3
|
3
|
+
|
4
|
+
Exclude:
|
5
|
+
- 'spec/dummy/**/*'
|
6
|
+
|
7
|
+
# c.f. https://github.com/rubocop-hq/rubocop/blob/v0.72.0/config/default.yml#L60-L63
|
8
|
+
- 'node_modules/**/*'
|
9
|
+
- 'vendor/**/*'
|
10
|
+
- '.git/**/*'
|
11
|
+
|
12
|
+
Metrics/BlockLength:
|
13
|
+
Exclude:
|
14
|
+
- '*.gemspec'
|
15
|
+
- 'spec/**/*_spec.rb'
|
16
|
+
|
17
|
+
Metrics/LineLength:
|
18
|
+
Max: 110
|
19
|
+
|
20
|
+
Style/Documentation:
|
21
|
+
Enabled: false
|
data/.travis.yml
CHANGED
@@ -2,7 +2,6 @@ sudo: false
|
|
2
2
|
language: ruby
|
3
3
|
cache: bundler
|
4
4
|
rvm:
|
5
|
-
- 2.2
|
6
5
|
- 2.3
|
7
6
|
- 2.4
|
8
7
|
- 2.5
|
@@ -17,7 +16,8 @@ before_script:
|
|
17
16
|
- chmod +x ./cc-test-reporter
|
18
17
|
- ./cc-test-reporter before-build
|
19
18
|
script:
|
20
|
-
- bundle exec rspec
|
19
|
+
- RUBYOPT=$RSPEC_RUBYOPT bundle exec rspec
|
20
|
+
- bundle exec rubocop -P
|
21
21
|
after_script:
|
22
22
|
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
23
23
|
branches:
|
@@ -32,9 +32,9 @@ matrix:
|
|
32
32
|
- rvm: ruby-head
|
33
33
|
include:
|
34
34
|
- rvm: 2.6
|
35
|
-
env:
|
35
|
+
env: RSPEC_RUBYOPT="--jit"
|
36
36
|
- rvm: ruby-head
|
37
|
-
env:
|
37
|
+
env: RSPEC_RUBYOPT="--jit"
|
38
38
|
env:
|
39
39
|
global:
|
40
40
|
- CC_TEST_REPORTER_ID=ae386af24f1ca076680045ecadf328fc77fd71bf6c014b5503d406d8bd87c42a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
## master
|
2
|
-
[full changelog](http://github.com/sue445/rubocop_auto_corrector/compare/v0.
|
2
|
+
[full changelog](http://github.com/sue445/rubocop_auto_corrector/compare/v0.3.0...master)
|
3
|
+
|
4
|
+
## v0.3.0
|
5
|
+
[full changelog](http://github.com/sue445/rubocop_auto_corrector/compare/v0.2.0...v0.3.0)
|
6
|
+
|
7
|
+
* Support `rubocop-rails` gem (requires rubocop 0.72.0+ and ruby 2.3.0+)
|
8
|
+
* https://github.com/sue445/rubocop_auto_corrector/pull/18
|
3
9
|
|
4
10
|
## v0.2.0
|
5
11
|
[full changelog](http://github.com/sue445/rubocop_auto_corrector/compare/v0.1.0...v0.2.0)
|
data/Gemfile
CHANGED
@@ -1,11 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
6
|
|
5
7
|
# Specify your gem's dependencies in rubocop_auto_corrector.gemspec
|
6
8
|
gemspec
|
7
|
-
|
8
|
-
if Gem::Version.create(RUBY_VERSION) < Gem::Version.create("2.3.0")
|
9
|
-
# rubocop 0.69.0+ requires ruby 2.3+
|
10
|
-
gem 'rubocop', '< 0.69.0'
|
11
|
-
end
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/exe/rubocop_auto_corrector
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'rubocop_auto_corrector/cli'
|
4
5
|
require 'rubocop_auto_corrector/version'
|
@@ -10,7 +11,13 @@ params = {
|
|
10
11
|
}
|
11
12
|
|
12
13
|
Version = RubocopAutoCorrector::VERSION
|
13
|
-
|
14
|
+
|
15
|
+
opt.on(
|
16
|
+
'--auto-correct-count COUNT',
|
17
|
+
'Run `rubocop --auto-correct` and `git commit` for this number of times. (default. 2)'
|
18
|
+
) do |v|
|
19
|
+
params[:auto_correct_count] = v.to_i
|
20
|
+
end
|
14
21
|
|
15
22
|
opt.parse!(ARGV)
|
16
23
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RubocopAutoCorrector
|
2
4
|
require 'json'
|
3
5
|
require 'yaml'
|
@@ -14,10 +16,8 @@ module RubocopAutoCorrector
|
|
14
16
|
end
|
15
17
|
|
16
18
|
def perform
|
17
|
-
cop_names =
|
18
|
-
|
19
|
-
.select { |cop_name| auto_correctable?(cop_name) }
|
20
|
-
.sort_by { |cop_name| [cop_order(cop_name), cop_name] }
|
19
|
+
cop_names = collect_offense_cop_names.select { |cop_name| auto_correctable?(cop_name) }
|
20
|
+
.sort_by { |cop_name| [cop_order(cop_name), cop_name] }
|
21
21
|
|
22
22
|
cop_names.each do |cop_name|
|
23
23
|
if (reason = exclude_reason(cop_name))
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RubocopAutoCorrector
|
2
4
|
class CopFinder
|
3
5
|
attr_reader :cop_name
|
@@ -10,7 +12,7 @@ module RubocopAutoCorrector
|
|
10
12
|
# Whether this cop is auto correctable
|
11
13
|
# @return [Boolean]
|
12
14
|
def auto_correctable?
|
13
|
-
Object.new.instance_eval <<-RUBY
|
15
|
+
Object.new.instance_eval <<-RUBY, __FILE__, __LINE__ + 1
|
14
16
|
begin
|
15
17
|
require '#{gem_name}'
|
16
18
|
rescue LoadError
|
@@ -35,6 +37,7 @@ module RubocopAutoCorrector
|
|
35
37
|
|
36
38
|
private
|
37
39
|
|
40
|
+
# rubocop:disable Metrics/MethodLength
|
38
41
|
def rubocop_cop_info
|
39
42
|
cop_class_suffix = cop_name.gsub('/', '::')
|
40
43
|
|
@@ -43,7 +46,7 @@ module RubocopAutoCorrector
|
|
43
46
|
['rubocop-rspec', "::RuboCop::Cop::#{cop_class_suffix}"]
|
44
47
|
when %r{^(FactoryBot|Capybara)/}, 'Rails/HttpStatus'
|
45
48
|
['rubocop-rspec', "::RuboCop::Cop::RSpec::#{cop_class_suffix}"]
|
46
|
-
when %r{^(Layout|Lint|Metrics|Naming|
|
49
|
+
when %r{^(Layout|Lint|Metrics|Naming|Security|Style|Bundler|Gemspec)/}
|
47
50
|
# Official cops
|
48
51
|
['rubocop', "::RuboCop::Cop::#{cop_class_suffix}"]
|
49
52
|
else
|
@@ -53,5 +56,6 @@ module RubocopAutoCorrector
|
|
53
56
|
["rubocop-#{department_snake}", "::RuboCop::Cop::#{cop_class_suffix}"]
|
54
57
|
end
|
55
58
|
end
|
59
|
+
# rubocop:enable Metrics/MethodLength
|
56
60
|
end
|
57
61
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'rubocop_auto_corrector/version'
|
@@ -33,7 +35,9 @@ Gem::Specification.new do |spec|
|
|
33
35
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
36
|
spec.require_paths = ['lib']
|
35
37
|
|
36
|
-
spec.
|
38
|
+
spec.required_ruby_version = '>= 2.3.0'
|
39
|
+
|
40
|
+
spec.add_dependency 'rubocop', '>= 0.72.0'
|
37
41
|
|
38
42
|
spec.add_development_dependency 'bundler', '>= 1.17'
|
39
43
|
spec.add_development_dependency 'coveralls'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop_auto_corrector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sue445
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.72.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.72.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- ".coveralls.yml"
|
148
148
|
- ".gitignore"
|
149
149
|
- ".rspec"
|
150
|
+
- ".rubocop.yml"
|
150
151
|
- ".travis.yml"
|
151
152
|
- CHANGELOG.md
|
152
153
|
- Gemfile
|
@@ -177,7 +178,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
177
178
|
requirements:
|
178
179
|
- - ">="
|
179
180
|
- !ruby/object:Gem::Version
|
180
|
-
version:
|
181
|
+
version: 2.3.0
|
181
182
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
183
|
requirements:
|
183
184
|
- - ">="
|