rubocop_challenger 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +5 -33
- data/Gemfile.lock +1 -1
- data/README.md +80 -18
- data/lib/rubocop_challenger.rb +1 -0
- data/lib/rubocop_challenger/cli.rb +8 -1
- data/lib/rubocop_challenger/rubocop/challenge.rb +11 -10
- data/lib/rubocop_challenger/rubocop/command.rb +11 -0
- data/lib/rubocop_challenger/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c793807b7c62bf1aa08436ec4d4de3630a00825e239d8c5d6122f94651b7dd1
|
4
|
+
data.tar.gz: 50d56cc0b7da03c6f66d6aa93b6e5e814f0b6061997f727b8393bbc85487cc02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39ac6e8bb72d0b7a0e941a33dd09a0dd1701c9d59fb3557a7096e0f383c76ee042a29da225bbc80fbc505d2cbfd1e3eced511ef68b90c3a555153ab2f3a85ff1
|
7
|
+
data.tar.gz: 49f651edd5fd9601ecac5f3fca3914c2f373efd8fab4dcd9df5fdb40328f811b3851644efdc1487a30134427dc2fc029f1904e52a892057007f5c18baece123a
|
data/.rubocop_todo.yml
CHANGED
@@ -1,17 +1,11 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2018-10-
|
3
|
+
# on 2018-10-21 01:10:29 +0900 using RuboCop version 0.59.2.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count: 1
|
10
|
-
# Cop supports --auto-correct.
|
11
|
-
Layout/LeadingBlankLines:
|
12
|
-
Exclude:
|
13
|
-
- 'rubocop_challenger.gemspec'
|
14
|
-
|
15
9
|
# Offense count: 1
|
16
10
|
# Cop supports --auto-correct.
|
17
11
|
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
|
@@ -21,24 +15,19 @@ Layout/SpaceInsideBlockBraces:
|
|
21
15
|
Exclude:
|
22
16
|
- 'Gemfile'
|
23
17
|
|
24
|
-
# Offense count:
|
18
|
+
# Offense count: 5
|
25
19
|
# Configuration parameters: CountComments, ExcludedMethods.
|
26
20
|
# ExcludedMethods: refine
|
27
21
|
Metrics/BlockLength:
|
28
22
|
Max: 132
|
29
23
|
|
30
|
-
# Offense count: 1
|
31
|
-
# Configuration parameters: CountComments, ExcludedMethods.
|
32
|
-
Metrics/MethodLength:
|
33
|
-
Max: 13
|
34
|
-
|
35
24
|
# Offense count: 2
|
36
25
|
# Configuration parameters: Max.
|
37
26
|
RSpec/ExampleLength:
|
38
27
|
Exclude:
|
39
28
|
- 'spec/rubocop_challenger/rubocop/todo_reader_spec.rb'
|
40
29
|
|
41
|
-
# Offense count:
|
30
|
+
# Offense count: 7
|
42
31
|
Style/Documentation:
|
43
32
|
Exclude:
|
44
33
|
- 'spec/**/*'
|
@@ -46,19 +35,11 @@ Style/Documentation:
|
|
46
35
|
- 'lib/rubocop_challenger.rb'
|
47
36
|
- 'lib/rubocop_challenger/cli.rb'
|
48
37
|
- 'lib/rubocop_challenger/rubocop/challenge.rb'
|
38
|
+
- 'lib/rubocop_challenger/rubocop/command.rb'
|
49
39
|
- 'lib/rubocop_challenger/rubocop/rule.rb'
|
50
40
|
- 'lib/rubocop_challenger/rubocop/todo_reader.rb'
|
51
41
|
- 'lib/rubocop_challenger/rubocop/todo_writer.rb'
|
52
42
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
# Offense count: 1
|
57
|
-
# Cop supports --auto-correct.
|
58
|
-
Style/MutableConstant:
|
59
|
-
Exclude:
|
60
|
-
- 'lib/rubocop_challenger/version.rb'
|
61
|
-
|
62
43
|
# Offense count: 1
|
63
44
|
# Cop supports --auto-correct.
|
64
45
|
Style/RedundantSelf:
|
@@ -71,16 +52,7 @@ Style/RescueModifier:
|
|
71
52
|
Exclude:
|
72
53
|
- 'lib/rubocop_challenger/rubocop/rule.rb'
|
73
54
|
|
74
|
-
|
75
|
-
# Offense count: 2
|
76
|
-
# Cop supports --auto-correct.
|
77
|
-
# Configuration parameters: EnforcedStyleForMultiline.
|
78
|
-
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
|
79
|
-
Style/TrailingCommaInArrayLiteral:
|
80
|
-
Exclude:
|
81
|
-
- 'spec/rubocop_challenger/rubocop/todo_reader_spec.rb'
|
82
|
-
|
83
|
-
# Offense count: 4
|
55
|
+
# Offense count: 6
|
84
56
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
85
57
|
# URISchemes: http, https
|
86
58
|
Metrics/LineLength:
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,31 +1,93 @@
|
|
1
1
|
# Rubocop Challenger
|
2
2
|
|
3
|
-
[![CircleCI](https://circleci.com/gh/ryz310/rubocop_challenger/tree/master.svg?style=svg&circle-token=cdf0ffce5b4c0c7804b50dde00ca5ef09cbadb67)](https://circleci.com/gh/ryz310/rubocop_challenger/tree/master) [![Gem Version](https://badge.fury.io/rb/rubocop_challenger.svg)](https://badge.fury.io/rb/rubocop_challenger)
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
[![CircleCI](https://circleci.com/gh/ryz310/rubocop_challenger/tree/master.svg?style=svg&circle-token=cdf0ffce5b4c0c7804b50dde00ca5ef09cbadb67)](https://circleci.com/gh/ryz310/rubocop_challenger/tree/master) [![Gem Version](https://badge.fury.io/rb/rubocop_challenger.svg)](https://badge.fury.io/rb/rubocop_challenger) [![Waffle.io - Columns and their card count](https://badge.waffle.io/ryz310/rubocop_challenger.svg?columns=all)](https://waffle.io/ryz310/rubocop_challenger)
|
4
|
+
|
5
|
+
If you introduce [`rubocop`](https://github.com/rubocop-hq/rubocop) to an existing Rails project later, you will use [`$ rubocop --auto-gen-config`](https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md#automatically-generated-configuration). But it will make a huge `.rubocop_todo.yml` and make you despair.
|
6
|
+
On the other hand, `rubocop` has [`--auto-correct`](https://github.com/rubocop-hq/rubocop/blob/master/manual/basic_usage.md#other-useful-command-line-flags) option, it is possible to automatically repair the writing which does not conform to the rule. But since it occasionally destroys your code, it is quite dangerous to apply all at once.
|
7
|
+
It is ideal that to remove a disabled rule from `.rubocop_todo.yml` every day, to check whether it passes test, and can be obtained consent from the team. But it requires strong persistence and time.
|
8
|
+
I call such work *Rubocop Challenge*. And the *RubocopChallenger* is a gem to support this challenge!
|
9
|
+
|
10
|
+
## Rubocop Challenge Flow
|
11
|
+
|
12
|
+
1. Run *RubocopChallenger* periodically from CI tool etc.
|
13
|
+
2. When *RubocopChallenger* starts, delete a disabled rule from `.rubocop_todo.yml` existing in your project, execute `$ rubocop --auto-correct` and create a PR which include modified results
|
14
|
+
3. You confirm the PR passes testing and then merge it if there is no problem
|
15
|
+
|
16
|
+
## Example
|
17
|
+
|
18
|
+
### Using [CircleCI 2.0](https://circleci.com)
|
19
|
+
|
20
|
+
```yml
|
21
|
+
# .circleci/config.yml
|
22
|
+
version: 2
|
23
|
+
|
24
|
+
jobs:
|
25
|
+
rubocop_challenge:
|
26
|
+
docker:
|
27
|
+
- image: circleci/ruby:2.5-node-browsers
|
28
|
+
working_directory: ~/repo
|
29
|
+
steps:
|
30
|
+
- checkout
|
31
|
+
- run:
|
32
|
+
name: Rubocop Challenge
|
33
|
+
command: |
|
34
|
+
gem install rubocop_challenger
|
35
|
+
rubocop_challenger go \
|
36
|
+
--email=rubocop-challenge@example.com \
|
37
|
+
--name="'Rubocop Challenge'"
|
38
|
+
|
39
|
+
workflows:
|
40
|
+
version: 2
|
41
|
+
|
42
|
+
nightly:
|
43
|
+
triggers:
|
44
|
+
- schedule:
|
45
|
+
cron: "30 23 * * 1,2,3" # 8:30am every Tuesday, Wednsday and Thursday (JST)
|
46
|
+
filters:
|
47
|
+
branches:
|
48
|
+
only:
|
49
|
+
- master
|
50
|
+
jobs:
|
51
|
+
- rubocop_challenge
|
52
|
+
```
|
9
53
|
|
10
|
-
##
|
54
|
+
## Usage
|
11
55
|
|
12
|
-
|
56
|
+
```sh
|
57
|
+
$ rubocop_challenger help
|
13
58
|
|
14
|
-
|
15
|
-
|
59
|
+
Commands:
|
60
|
+
rubocop_challenger go --email=EMAIL --name=NAME # Run `$ rubocop --auto-correct` and create PR to your GitHub repository
|
61
|
+
rubocop_challenger help [COMMAND] # Describe available commands or one specific command
|
62
|
+
rubocop_challenger version # Show current version
|
16
63
|
```
|
17
64
|
|
18
|
-
|
65
|
+
### Command-line Flags
|
19
66
|
|
20
|
-
|
67
|
+
```sh
|
68
|
+
$ rubocop_challenger help go
|
21
69
|
|
22
|
-
|
70
|
+
Usage:
|
71
|
+
rubocop_challenger go --email=EMAIL --name=NAME
|
23
72
|
|
24
|
-
|
73
|
+
Options:
|
74
|
+
--email=EMAIL # Pull Request committer email
|
75
|
+
--name=NAME # Pull Request committer name
|
76
|
+
f, [--file-path=FILE_PATH] # Set your ".rubocop_todo.yml" path
|
77
|
+
# Default: .rubocop_todo.yml
|
78
|
+
[--mode=MODE] # Mode to select deletion target. You can choice "most_occurrence", "least_occurrence", or "random"
|
79
|
+
# Default: most_occurrence
|
80
|
+
[--base=BASE] # Base branch of Pull Request
|
81
|
+
# Default: master
|
82
|
+
l, [--labels=one two three] # Label to give to Pull Request
|
83
|
+
# Default: ["rubocop challenge"]
|
25
84
|
|
26
|
-
|
85
|
+
Run `$ rubocop --auto-correct` and create PR to your GitHub repository
|
86
|
+
```
|
87
|
+
|
88
|
+
## Requirement
|
27
89
|
|
28
|
-
|
90
|
+
* Ruby 2.3 or higher
|
29
91
|
|
30
92
|
## Development
|
31
93
|
|
@@ -35,7 +97,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
35
97
|
|
36
98
|
## Contributing
|
37
99
|
|
38
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
100
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ryz310/rubocop_challenger. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
39
101
|
|
40
102
|
## License
|
41
103
|
|
@@ -43,4 +105,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
43
105
|
|
44
106
|
## Code of Conduct
|
45
107
|
|
46
|
-
Everyone interacting in the RubocopChallenger project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
108
|
+
Everyone interacting in the RubocopChallenger project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ryz310/rubocop_challenger/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/rubocop_challenger.rb
CHANGED
@@ -5,6 +5,7 @@ require 'rubocop-rspec'
|
|
5
5
|
require 'rubocop_challenger/rubocop/rule'
|
6
6
|
require 'rubocop_challenger/rubocop/todo_reader'
|
7
7
|
require 'rubocop_challenger/rubocop/todo_writer'
|
8
|
+
require 'rubocop_challenger/rubocop/command'
|
8
9
|
require 'rubocop_challenger/rubocop/challenge'
|
9
10
|
require 'rubocop_challenger/cli'
|
10
11
|
require 'rubocop_challenger/version'
|
@@ -4,7 +4,7 @@ require 'thor'
|
|
4
4
|
|
5
5
|
module RubocopChallenger
|
6
6
|
class CLI < Thor
|
7
|
-
desc 'go', 'Run `$ rubocop -
|
7
|
+
desc 'go', 'Run `$ rubocop --auto-correct` and create PR to your GitHub repository'
|
8
8
|
option :email,
|
9
9
|
required: true,
|
10
10
|
type: :string,
|
@@ -35,6 +35,13 @@ module RubocopChallenger
|
|
35
35
|
def go
|
36
36
|
target_rule = Rubocop::Challenge.exec(options[:file_path], options[:mode])
|
37
37
|
PRDaikou.exec(pr_daikou_options(target_rule), nil)
|
38
|
+
rescue StandardError => e
|
39
|
+
puts e.message
|
40
|
+
end
|
41
|
+
|
42
|
+
desc 'version', 'Show current version'
|
43
|
+
def version
|
44
|
+
puts RubocopChallenger::VERSION
|
38
45
|
end
|
39
46
|
|
40
47
|
private
|
@@ -9,10 +9,11 @@ module RubocopChallenger
|
|
9
9
|
|
10
10
|
private
|
11
11
|
|
12
|
-
attr_reader :mode, :todo_reader, :todo_writer
|
12
|
+
attr_reader :mode, :command, :todo_reader, :todo_writer
|
13
13
|
|
14
14
|
def initialize(file_path, mode)
|
15
15
|
@mode = mode
|
16
|
+
@command = Rubocop::Command.new
|
16
17
|
@todo_reader = Rubocop::TodoReader.new(file_path)
|
17
18
|
@todo_writer = Rubocop::TodoWriter.new(file_path)
|
18
19
|
end
|
@@ -20,24 +21,24 @@ module RubocopChallenger
|
|
20
21
|
def exec
|
21
22
|
verify_target_rule
|
22
23
|
todo_writer.delete_rule(target_rule)
|
23
|
-
|
24
|
+
command.auto_correct
|
24
25
|
target_rule
|
25
26
|
end
|
26
27
|
|
27
28
|
def verify_target_rule
|
28
29
|
return unless target_rule.nil?
|
29
30
|
|
30
|
-
|
31
|
-
exit
|
31
|
+
raise 'There is no auto-correctable rule'
|
32
32
|
end
|
33
33
|
|
34
34
|
def target_rule
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
35
|
+
@target_rule ||=
|
36
|
+
case mode
|
37
|
+
when 'least_occurrence' then todo_reader.least_occurrence_rule
|
38
|
+
when 'random' then todo_reader.any_rule
|
39
|
+
when 'most_occurrence' then todo_reader.most_occurrence_rule
|
40
|
+
else raise "`#{mode}` is not supported mode"
|
41
|
+
end
|
41
42
|
end
|
42
43
|
end
|
43
44
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop_challenger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ryosuke_sato
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pr-daikou
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- lib/rubocop_challenger.rb
|
151
151
|
- lib/rubocop_challenger/cli.rb
|
152
152
|
- lib/rubocop_challenger/rubocop/challenge.rb
|
153
|
+
- lib/rubocop_challenger/rubocop/command.rb
|
153
154
|
- lib/rubocop_challenger/rubocop/rule.rb
|
154
155
|
- lib/rubocop_challenger/rubocop/todo_reader.rb
|
155
156
|
- lib/rubocop_challenger/rubocop/todo_writer.rb
|