rubocop_auto_corrector 0.1.0.beta1 → 0.1.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.travis.yml +30 -3
- data/README.md +5 -0
- data/lib/rubocop_auto_corrector.rb +1 -0
- data/lib/rubocop_auto_corrector/cli.rb +7 -14
- data/lib/rubocop_auto_corrector/cop_finder.rb +56 -0
- data/lib/rubocop_auto_corrector/version.rb +1 -1
- data/rubocop_auto_corrector.gemspec +2 -0
- metadata +32 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 327090c9bbd094d7a6dd418e76bf9821122dc5227919cefc4b2d891ad11e233c
|
4
|
+
data.tar.gz: 7fc67732f6da3c4af91ab25c493b252368ac8370c91952b09cac1d97c7066dea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6777932b5de6f3495f5dc03e7b171d0578fdbec59c8136571d0f836306ed58a471628b420dcc1ed5015ff6f6b48fab5368c8646a5be69332545009abe337b2c
|
7
|
+
data.tar.gz: a2201469cab50eb566860d9a4efaa41ed8bf514c15069f7a2ad8975645a656bf71a75008bf30e53ba9c8bed2eefbca94a37bbf20185cfea406938225e851ea2a
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
repo_token: Qeqfezb3pV4exGsEupqPmLm4jYYZYVciw
|
data/.travis.yml
CHANGED
@@ -1,7 +1,34 @@
|
|
1
|
-
---
|
2
1
|
sudo: false
|
3
2
|
language: ruby
|
4
3
|
cache: bundler
|
5
4
|
rvm:
|
6
|
-
- 2.
|
7
|
-
|
5
|
+
- 2.2
|
6
|
+
- 2.3
|
7
|
+
- 2.4
|
8
|
+
- 2.5
|
9
|
+
- ruby-head
|
10
|
+
bundler_args: "--jobs=4"
|
11
|
+
before_install:
|
12
|
+
- gem update --system --no-document
|
13
|
+
- gem install bundler --no-document
|
14
|
+
before_script:
|
15
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
16
|
+
- chmod +x ./cc-test-reporter
|
17
|
+
- ./cc-test-reporter before-build
|
18
|
+
script:
|
19
|
+
- bundle exec rspec
|
20
|
+
after_script:
|
21
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
22
|
+
branches:
|
23
|
+
only:
|
24
|
+
- master
|
25
|
+
notifications:
|
26
|
+
email: false
|
27
|
+
slack:
|
28
|
+
secure: StdMcwf2erVzwfR45Rsw8hKmzaCdg7xl6UzEyPkyrNi1eKS/qeys8Ga1Q5I4HFlmybpBuOTk8dwiya0svGIJtABPUeIe7UjkmGDhS6Q+K+Gk8tNayrvOXgS71JJlqPdTVoWCPqNeqs/a+G9xa/T/TcQgZhh+57Jl9fH4hz/UaXhO0uVuL5LwHvKW6UX35xbAnIdPqMXF7finqF8nxU8nzaGvZ+UrUmnLDIRBeeW1eSopWQP7O+89BM+Nr7vC0oC/fJDcszTnZwYk6b38z9kD8Rvb3H0BktERmeR4QROdokq8BeXKj7uNluHZcr7KQc8qhJA7jAhx326A2oi8C+Yyl4Mz75WsQ+a+JFnVwYgpTXjd4/DnTEA5JUokO2DzsDmcPgnvOgOzAVWdtx3Q96GIcs9vU4X1HuIlctye05ylwVUbOE6up4m47NYLkVmjfYgUq3YVGrqprrlv5gqDqTPb8Il7l+plEobvZhM2cjGx+A/HkpVDgiqfE2IwP3BBeZp5Nkn2P4XUAoFtHkVuTVly55b/Jtnvo83UTv6qJWvTKjM7EorQT9+NlsWe64z5T6VVM6Z5FYHIofFpyRdqSTxcP2AHVpHFckw19px3tC4WiwZzgj4PuMvwcHsgK80wErYOJxlkVAUKuw1nh7g8KZpHjHXp1bCwM6pIK4F9PGMFY/g=
|
29
|
+
matrix:
|
30
|
+
allow_failures:
|
31
|
+
- rvm: ruby-head
|
32
|
+
env:
|
33
|
+
global:
|
34
|
+
- CC_TEST_REPORTER_ID=ae386af24f1ca076680045ecadf328fc77fd71bf6c014b5503d406d8bd87c42a
|
data/README.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
Run `rubocop --auto-correct && git commit` with each cop.
|
4
4
|
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/rubocop_auto_corrector.svg)](https://badge.fury.io/rb/rubocop_auto_corrector)
|
6
|
+
[![Build Status](https://travis-ci.org/sue445/rubocop_auto_corrector.svg?branch=master)](https://travis-ci.org/sue445/rubocop_auto_corrector)
|
7
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/384834e50f94e344c439/maintainability)](https://codeclimate.com/github/sue445/rubocop_auto_corrector/maintainability)
|
8
|
+
[![Coverage Status](https://coveralls.io/repos/github/sue445/rubocop_auto_corrector/badge.svg?branch=master)](https://coveralls.io/github/sue445/rubocop_auto_corrector?branch=master)
|
9
|
+
|
5
10
|
# Example
|
6
11
|
See https://github.com/sue445/rubocop_auto_corrector/pull/3/commits
|
7
12
|
|
@@ -2,6 +2,7 @@ module RubocopAutoCorrector
|
|
2
2
|
require 'json'
|
3
3
|
require 'yaml'
|
4
4
|
require 'rubocop'
|
5
|
+
require 'rubocop_auto_corrector'
|
5
6
|
|
6
7
|
class CLI
|
7
8
|
DEFAULT_ORDER = 100
|
@@ -38,21 +39,13 @@ module RubocopAutoCorrector
|
|
38
39
|
cop_names.uniq
|
39
40
|
end
|
40
41
|
|
42
|
+
# Whether this cop is auto correctable
|
43
|
+
#
|
44
|
+
# @param cop_name [String]
|
45
|
+
#
|
46
|
+
# @return [Boolean]
|
41
47
|
def auto_correctable?(cop_name)
|
42
|
-
|
43
|
-
plugin_name = "rubocop-#{cop_name.split('/').first.downcase}"
|
44
|
-
|
45
|
-
begin
|
46
|
-
Object.new.instance_eval <<-RUBY
|
47
|
-
begin
|
48
|
-
require '#{plugin_name}'
|
49
|
-
rescue LoadError
|
50
|
-
end
|
51
|
-
#{cop_class_name}.new.respond_to?(:autocorrect)
|
52
|
-
RUBY
|
53
|
-
rescue NameError
|
54
|
-
false
|
55
|
-
end
|
48
|
+
RubocopAutoCorrector::CopFinder.new(cop_name).auto_correctable?
|
56
49
|
end
|
57
50
|
|
58
51
|
private
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module RubocopAutoCorrector
|
2
|
+
class CopFinder
|
3
|
+
attr_reader :cop_name
|
4
|
+
|
5
|
+
# @param cop_name [String] e.g. Metrics/AbcSize
|
6
|
+
def initialize(cop_name)
|
7
|
+
@cop_name = cop_name
|
8
|
+
end
|
9
|
+
|
10
|
+
# Whether this cop is auto correctable
|
11
|
+
# @return [Boolean]
|
12
|
+
def auto_correctable?
|
13
|
+
Object.new.instance_eval <<-RUBY
|
14
|
+
begin
|
15
|
+
require '#{gem_name}'
|
16
|
+
rescue LoadError
|
17
|
+
end
|
18
|
+
#{cop_class_name}.new.respond_to?(:autocorrect)
|
19
|
+
RUBY
|
20
|
+
rescue NameError
|
21
|
+
false
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [String]
|
25
|
+
def gem_name
|
26
|
+
gem_name, = rubocop_cop_info
|
27
|
+
gem_name
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [String]
|
31
|
+
def cop_class_name
|
32
|
+
_, cop_class = rubocop_cop_info
|
33
|
+
cop_class
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def rubocop_cop_info
|
39
|
+
cop_class_suffix = cop_name.gsub('/', '::')
|
40
|
+
|
41
|
+
case cop_name
|
42
|
+
when %r{^RSpec/}
|
43
|
+
['rubocop-rspec', "::RuboCop::Cop::#{cop_class_suffix}"]
|
44
|
+
when %r{^(FactoryBot|Capybara)/}, 'Rails/HttpStatus'
|
45
|
+
['rubocop-rspec', "::RuboCop::Cop::RSpec::#{cop_class_suffix}"]
|
46
|
+
when %r{^(Layout|Lint|Metrics|Naming|Performance|Rails|Security|Style|Bundler|Gemspec)/}
|
47
|
+
# Official cops
|
48
|
+
['rubocop', "::RuboCop::Cop::#{cop_class_suffix}"]
|
49
|
+
else
|
50
|
+
# Unknown cops
|
51
|
+
department = cop_name.split('/').first.downcase
|
52
|
+
["rubocop-#{department}", "::RuboCop::Cop::#{cop_class_suffix}"]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -36,9 +36,11 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_dependency 'rubocop', '>= 0.49.0'
|
37
37
|
|
38
38
|
spec.add_development_dependency 'bundler', '~> 1.17'
|
39
|
+
spec.add_development_dependency 'coveralls'
|
39
40
|
spec.add_development_dependency 'rake', '~> 10.0'
|
40
41
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
41
42
|
spec.add_development_dependency 'rspec-parameterized'
|
42
43
|
spec.add_development_dependency 'rspec-temp_dir', '>= 1.1.0'
|
43
44
|
spec.add_development_dependency 'rubocop-rspec'
|
45
|
+
spec.add_development_dependency 'simplecov'
|
44
46
|
end
|
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.1.0.
|
4
|
+
version: 0.1.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sue445
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.17'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: coveralls
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +122,20 @@ dependencies:
|
|
108
122
|
- - ">="
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
111
139
|
description: Run `rubocop --auto-correct && git commit` with each cop.
|
112
140
|
email:
|
113
141
|
- sue445@sue445.net
|
@@ -116,6 +144,7 @@ executables:
|
|
116
144
|
extensions: []
|
117
145
|
extra_rdoc_files: []
|
118
146
|
files:
|
147
|
+
- ".coveralls.yml"
|
119
148
|
- ".gitignore"
|
120
149
|
- ".rspec"
|
121
150
|
- ".rubocop.yml"
|
@@ -130,6 +159,7 @@ files:
|
|
130
159
|
- exe/rubocop_auto_corrector
|
131
160
|
- lib/rubocop_auto_corrector.rb
|
132
161
|
- lib/rubocop_auto_corrector/cli.rb
|
162
|
+
- lib/rubocop_auto_corrector/cop_finder.rb
|
133
163
|
- lib/rubocop_auto_corrector/data.yml
|
134
164
|
- lib/rubocop_auto_corrector/version.rb
|
135
165
|
- rubocop_auto_corrector.gemspec
|