rubocop_challenger 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +163 -0
- data/.envrc.skeleton +1 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.rubocop.yml +6 -0
- data/.rubocop_todo.yml +87 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +63 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +45 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/challenger.gemspec +36 -0
- data/exe/rubocop_challenger +6 -0
- data/lib/rubocop_challenger.rb +14 -0
- data/lib/rubocop_challenger/cli.rb +62 -0
- data/lib/rubocop_challenger/rubocop/challenge.rb +44 -0
- data/lib/rubocop_challenger/rubocop/rule.rb +50 -0
- data/lib/rubocop_challenger/rubocop/todo_reader.rb +44 -0
- data/lib/rubocop_challenger/rubocop/todo_writer.rb +21 -0
- data/lib/rubocop_challenger/version.rb +5 -0
- metadata +181 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: aedf49ae1e6304151bde6c130683708b716e4ec97d70802ce2d6d3e97609af4a
|
4
|
+
data.tar.gz: dee3f2c13e8eac68ebbcf3e42d75e741fc9218b764db95f2037300573834edc9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7a4d70e67bc8db71f5dc2f78585b4849f84831c6b1bb2cc4552e2ba65ccf64110359c330d383b25a5878dff584b1271ed6a51e4b25d016d2fb804ece062c34fe
|
7
|
+
data.tar.gz: c8b498a006f498c385678848c502b21d91ec05a769ae66e500079c3a9066172db2339c57218b213d217175e294f99d14354c2f2506565fd7df13b6265d3127d4
|
@@ -0,0 +1,163 @@
|
|
1
|
+
# Ruby CircleCI 2.0 configuration file
|
2
|
+
#
|
3
|
+
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
4
|
+
#
|
5
|
+
version: 2
|
6
|
+
|
7
|
+
references:
|
8
|
+
- &restore_bundle_install_cache
|
9
|
+
restore_cache:
|
10
|
+
keys:
|
11
|
+
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
12
|
+
- v1-dependencies-
|
13
|
+
- &bundle_install
|
14
|
+
run:
|
15
|
+
name: Bundle Install
|
16
|
+
command: |
|
17
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
18
|
+
- &save_bundle_install_cache
|
19
|
+
save_cache:
|
20
|
+
paths:
|
21
|
+
- ./vendor/bundle
|
22
|
+
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
23
|
+
|
24
|
+
- &build
|
25
|
+
working_directory: ~/repo
|
26
|
+
steps:
|
27
|
+
- checkout
|
28
|
+
- *restore_bundle_install_cache
|
29
|
+
- *bundle_install
|
30
|
+
- *save_bundle_install_cache
|
31
|
+
- run:
|
32
|
+
name: Run Rspec
|
33
|
+
command: |
|
34
|
+
mkdir /tmp/test-results
|
35
|
+
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
|
36
|
+
bundle exec rspec --format documentation \
|
37
|
+
--color \
|
38
|
+
--format RspecJunitFormatter \
|
39
|
+
--out /tmp/test-results/rspec.xml \
|
40
|
+
$TEST_FILES
|
41
|
+
- store_test_results:
|
42
|
+
path: /tmp/test-results
|
43
|
+
- store_artifacts:
|
44
|
+
path: /tmp/test-results
|
45
|
+
destination: test-results
|
46
|
+
- run:
|
47
|
+
name: Rake Build
|
48
|
+
command: |
|
49
|
+
bundle exec rake build
|
50
|
+
|
51
|
+
- &rubocop
|
52
|
+
working_directory: ~/repo
|
53
|
+
steps:
|
54
|
+
- checkout
|
55
|
+
- *restore_bundle_install_cache
|
56
|
+
- *bundle_install
|
57
|
+
- *save_bundle_install_cache
|
58
|
+
- run: bundle exec rubocop
|
59
|
+
|
60
|
+
jobs:
|
61
|
+
build_on_ruby_2.3:
|
62
|
+
docker:
|
63
|
+
- image: circleci/ruby:2.3-node-browsers
|
64
|
+
<<: *build
|
65
|
+
build_on_ruby_2.4:
|
66
|
+
docker:
|
67
|
+
- image: circleci/ruby:2.4-node-browsers
|
68
|
+
<<: *build
|
69
|
+
build_on_ruby_2.5:
|
70
|
+
docker:
|
71
|
+
- image: circleci/ruby:2.5-node-browsers
|
72
|
+
<<: *build
|
73
|
+
build_on_ruby_latest:
|
74
|
+
docker:
|
75
|
+
- image: circleci/ruby:latest-node-browsers-legacy
|
76
|
+
<<: *build
|
77
|
+
rubocop:
|
78
|
+
docker:
|
79
|
+
- image: circleci/ruby:2.3-node-browsers
|
80
|
+
<<: *rubocop
|
81
|
+
|
82
|
+
rubocop_challenge:
|
83
|
+
docker:
|
84
|
+
- image: circleci/ruby:2.3-node-browsers
|
85
|
+
working_directory: ~/repo
|
86
|
+
steps:
|
87
|
+
- checkout
|
88
|
+
- *restore_bundle_install_cache
|
89
|
+
- *bundle_install
|
90
|
+
- *save_bundle_install_cache
|
91
|
+
- run: bundle exec rake install
|
92
|
+
- run:
|
93
|
+
name: Rubocop Challenge
|
94
|
+
command: |
|
95
|
+
bundle exec exe/rubocop_challenger go \
|
96
|
+
--email=ryz310@gmail.com \
|
97
|
+
--name=ryz310 \
|
98
|
+
--mode=random
|
99
|
+
release:
|
100
|
+
docker:
|
101
|
+
- image: circleci/ruby:2.3-node-browsers
|
102
|
+
working_directory: ~/repo
|
103
|
+
steps:
|
104
|
+
- checkout
|
105
|
+
- *restore_bundle_install_cache
|
106
|
+
- *bundle_install
|
107
|
+
- *save_bundle_install_cache
|
108
|
+
- run:
|
109
|
+
name: Create Rubygems Credentials
|
110
|
+
command: |
|
111
|
+
mkdir ~/.gem
|
112
|
+
echo -e "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}" > ~/.gem/credentials
|
113
|
+
chmod 0600 ~/.gem/credentials
|
114
|
+
- run:
|
115
|
+
name: Release Gem
|
116
|
+
command: |
|
117
|
+
git push --set-upstream origin ${CIRCLE_BRANCH}
|
118
|
+
bundle exec rake release --trace
|
119
|
+
|
120
|
+
workflows:
|
121
|
+
version: 2
|
122
|
+
|
123
|
+
commit:
|
124
|
+
jobs:
|
125
|
+
- build_on_ruby_2.3
|
126
|
+
- build_on_ruby_2.4
|
127
|
+
- build_on_ruby_2.5
|
128
|
+
- build_on_ruby_latest
|
129
|
+
- rubocop
|
130
|
+
- rubocop_challenge:
|
131
|
+
requires:
|
132
|
+
- build_on_ruby_2.3
|
133
|
+
- build_on_ruby_2.4
|
134
|
+
- build_on_ruby_2.5
|
135
|
+
- build_on_ruby_latest
|
136
|
+
- rubocop
|
137
|
+
filters:
|
138
|
+
branches:
|
139
|
+
only:
|
140
|
+
- master
|
141
|
+
- release:
|
142
|
+
context: RubyGems API Key
|
143
|
+
requires:
|
144
|
+
- build_on_ruby_2.3
|
145
|
+
- build_on_ruby_2.4
|
146
|
+
- build_on_ruby_2.5
|
147
|
+
- build_on_ruby_latest
|
148
|
+
- rubocop
|
149
|
+
filters:
|
150
|
+
branches:
|
151
|
+
only:
|
152
|
+
- production
|
153
|
+
|
154
|
+
challenge:
|
155
|
+
triggers:
|
156
|
+
- schedule:
|
157
|
+
cron: "30 23 * * 5" # 8:30am every Saturday (JST)
|
158
|
+
filters:
|
159
|
+
branches:
|
160
|
+
only:
|
161
|
+
- master
|
162
|
+
jobs:
|
163
|
+
- rubocop_challenge
|
data/.envrc.skeleton
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export GITHUB_ACCESS_TOKEN={GITHUB_ACCESS_TOKEN}
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2018-10-15 12:27:50 +0900 using RuboCop version 0.59.2.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
Layout/LeadingBlankLines:
|
12
|
+
Exclude:
|
13
|
+
- 'rubocop_challenger.gemspec'
|
14
|
+
|
15
|
+
# Offense count: 1
|
16
|
+
# Cop supports --auto-correct.
|
17
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
|
18
|
+
# SupportedStyles: space, no_space
|
19
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
20
|
+
Layout/SpaceInsideBlockBraces:
|
21
|
+
Exclude:
|
22
|
+
- 'Gemfile'
|
23
|
+
|
24
|
+
# Offense count: 3
|
25
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
26
|
+
# ExcludedMethods: refine
|
27
|
+
Metrics/BlockLength:
|
28
|
+
Max: 132
|
29
|
+
|
30
|
+
# Offense count: 1
|
31
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
32
|
+
Metrics/MethodLength:
|
33
|
+
Max: 13
|
34
|
+
|
35
|
+
# Offense count: 2
|
36
|
+
# Configuration parameters: Max.
|
37
|
+
RSpec/ExampleLength:
|
38
|
+
Exclude:
|
39
|
+
- 'spec/rubocop_challenger/rubocop/todo_reader_spec.rb'
|
40
|
+
|
41
|
+
# Offense count: 6
|
42
|
+
Style/Documentation:
|
43
|
+
Exclude:
|
44
|
+
- 'spec/**/*'
|
45
|
+
- 'test/**/*'
|
46
|
+
- 'lib/rubocop_challenger.rb'
|
47
|
+
- 'lib/rubocop_challenger/cli.rb'
|
48
|
+
- 'lib/rubocop_challenger/rubocop/challenge.rb'
|
49
|
+
- 'lib/rubocop_challenger/rubocop/rule.rb'
|
50
|
+
- 'lib/rubocop_challenger/rubocop/todo_reader.rb'
|
51
|
+
- 'lib/rubocop_challenger/rubocop/todo_writer.rb'
|
52
|
+
|
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
|
+
# Offense count: 1
|
63
|
+
# Cop supports --auto-correct.
|
64
|
+
Style/RedundantSelf:
|
65
|
+
Exclude:
|
66
|
+
- 'lib/rubocop_challenger/rubocop/rule.rb'
|
67
|
+
|
68
|
+
# Offense count: 1
|
69
|
+
# Cop supports --auto-correct.
|
70
|
+
Style/RescueModifier:
|
71
|
+
Exclude:
|
72
|
+
- 'lib/rubocop_challenger/rubocop/rule.rb'
|
73
|
+
|
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
|
84
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
85
|
+
# URISchemes: http, https
|
86
|
+
Metrics/LineLength:
|
87
|
+
Max: 87
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at r-sato@feedforce.jp. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rubocop_challenger (0.1.0)
|
5
|
+
pr-daikou (~> 0.2.0)
|
6
|
+
rubocop
|
7
|
+
rubocop-rspec
|
8
|
+
thor
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
ast (2.4.0)
|
14
|
+
diff-lcs (1.3)
|
15
|
+
jaro_winkler (1.5.1)
|
16
|
+
parallel (1.12.1)
|
17
|
+
parser (2.5.1.2)
|
18
|
+
ast (~> 2.4.0)
|
19
|
+
powerpack (0.1.2)
|
20
|
+
pr-daikou (0.2.0)
|
21
|
+
rainbow (3.0.0)
|
22
|
+
rake (10.5.0)
|
23
|
+
rspec (3.8.0)
|
24
|
+
rspec-core (~> 3.8.0)
|
25
|
+
rspec-expectations (~> 3.8.0)
|
26
|
+
rspec-mocks (~> 3.8.0)
|
27
|
+
rspec-core (3.8.0)
|
28
|
+
rspec-support (~> 3.8.0)
|
29
|
+
rspec-expectations (3.8.2)
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
+
rspec-support (~> 3.8.0)
|
32
|
+
rspec-mocks (3.8.0)
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
+
rspec-support (~> 3.8.0)
|
35
|
+
rspec-support (3.8.0)
|
36
|
+
rspec_junit_formatter (0.4.1)
|
37
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
38
|
+
rubocop (0.59.2)
|
39
|
+
jaro_winkler (~> 1.5.1)
|
40
|
+
parallel (~> 1.10)
|
41
|
+
parser (>= 2.5, != 2.5.1.1)
|
42
|
+
powerpack (~> 0.1)
|
43
|
+
rainbow (>= 2.2.2, < 4.0)
|
44
|
+
ruby-progressbar (~> 1.7)
|
45
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
46
|
+
rubocop-rspec (1.30.0)
|
47
|
+
rubocop (>= 0.58.0)
|
48
|
+
ruby-progressbar (1.10.0)
|
49
|
+
thor (0.20.0)
|
50
|
+
unicode-display_width (1.4.0)
|
51
|
+
|
52
|
+
PLATFORMS
|
53
|
+
ruby
|
54
|
+
|
55
|
+
DEPENDENCIES
|
56
|
+
bundler (~> 1.16)
|
57
|
+
rake (~> 10.0)
|
58
|
+
rspec
|
59
|
+
rspec_junit_formatter
|
60
|
+
rubocop_challenger!
|
61
|
+
|
62
|
+
BUNDLED WITH
|
63
|
+
1.16.6
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Ryosuke Sato
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 ryosuke_sato
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
[![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)
|
2
|
+
|
3
|
+
# RubocopChallenger
|
4
|
+
|
5
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rubocop_challenger`. To experiment with that code, run `bin/console` for an interactive prompt.
|
6
|
+
|
7
|
+
TODO: Delete this and the text above, and describe your gem
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'rubocop_challenger'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install rubocop_challenger
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
$ rubocop_challenger rubocop_challenge --email=EMAIL --name=NAME
|
28
|
+
|
29
|
+
## Development
|
30
|
+
|
31
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
32
|
+
|
33
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/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.
|
38
|
+
|
39
|
+
## License
|
40
|
+
|
41
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
42
|
+
|
43
|
+
## Code of Conduct
|
44
|
+
|
45
|
+
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/[USERNAME]/rubocop_challenger/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'rubocop_challenger'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/challenger.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'rubocop_challenger/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'rubocop_challenger'
|
9
|
+
spec.version = RubocopChallenger::VERSION
|
10
|
+
spec.authors = ['ryosuke_sato']
|
11
|
+
spec.email = ['r-sato@feedforce.jp']
|
12
|
+
|
13
|
+
spec.summary = 'Help to run `$ rubocop -a` on your CI'
|
14
|
+
spec.description = spec.summary
|
15
|
+
spec.homepage = 'https://github.com/ryz310/rubocop_challenger'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
# Specify which files should be added to the gem when it is released.
|
19
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
end
|
23
|
+
spec.bindir = 'exe'
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ['lib']
|
26
|
+
|
27
|
+
spec.add_runtime_dependency 'pr-daikou', '~> 0.2.0'
|
28
|
+
spec.add_runtime_dependency 'rubocop'
|
29
|
+
spec.add_runtime_dependency 'rubocop-rspec'
|
30
|
+
spec.add_runtime_dependency 'thor'
|
31
|
+
|
32
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
33
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
34
|
+
spec.add_development_dependency 'rspec'
|
35
|
+
spec.add_development_dependency 'rspec_junit_formatter'
|
36
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubocop'
|
4
|
+
require 'rubocop-rspec'
|
5
|
+
require 'rubocop_challenger/rubocop/rule'
|
6
|
+
require 'rubocop_challenger/rubocop/todo_reader'
|
7
|
+
require 'rubocop_challenger/rubocop/todo_writer'
|
8
|
+
require 'rubocop_challenger/rubocop/challenge'
|
9
|
+
require 'rubocop_challenger/cli'
|
10
|
+
require 'rubocop_challenger/version'
|
11
|
+
require 'pr-daikou'
|
12
|
+
|
13
|
+
module RubocopChallenger
|
14
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
|
5
|
+
module RubocopChallenger
|
6
|
+
class CLI < Thor
|
7
|
+
desc 'go', 'Run `$ rubocop -a` and create PR to GitHub'
|
8
|
+
option :email,
|
9
|
+
required: true,
|
10
|
+
type: :string,
|
11
|
+
desc: 'Pull Request committer email'
|
12
|
+
option :name,
|
13
|
+
required: true,
|
14
|
+
type: :string,
|
15
|
+
desc: 'Pull Request committer name'
|
16
|
+
option :file_path,
|
17
|
+
type: :string,
|
18
|
+
default: '.rubocop_todo.yml',
|
19
|
+
aliases: :f,
|
20
|
+
desc: 'Set your ".rubocop_todo.yml" path'
|
21
|
+
option :mode,
|
22
|
+
type: :string,
|
23
|
+
default: 'most_occurrence',
|
24
|
+
desc: 'Mode to select deletion target. ' \
|
25
|
+
'You can choice "most_occurrence", "least_occurrence", or "random"'
|
26
|
+
option :base,
|
27
|
+
type: :string,
|
28
|
+
default: 'master',
|
29
|
+
desc: 'Base branch of Pull Request'
|
30
|
+
option :labels,
|
31
|
+
type: :array,
|
32
|
+
default: ['rubocop challenge'],
|
33
|
+
aliases: :l,
|
34
|
+
desc: 'Label to give to Pull Request'
|
35
|
+
def go
|
36
|
+
target_rule = Rubocop::Challenge.exec(options[:file_path], options[:mode])
|
37
|
+
PRDaikou.exec(pr_daikou_options(target_rule), nil)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def pr_daikou_options(target_rule)
|
43
|
+
{
|
44
|
+
email: options[:email],
|
45
|
+
name: options[:name],
|
46
|
+
base: options[:base],
|
47
|
+
title: target_rule.title,
|
48
|
+
labels: options[:labels].join(','),
|
49
|
+
topic: topic(target_rule),
|
50
|
+
commit: ":robot: #{target_rule.title}"
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def topic(rule)
|
55
|
+
"rubocop-challenge/#{rule.title.tr('/', '-')}-#{timestamp}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def timestamp
|
59
|
+
Time.now.strftime('%Y%m%d%H%M%S')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubocopChallenger
|
4
|
+
module Rubocop
|
5
|
+
class Challenge
|
6
|
+
def self.exec(file_path, mode)
|
7
|
+
new(file_path, mode).send(:exec)
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
attr_reader :mode, :todo_reader, :todo_writer
|
13
|
+
|
14
|
+
def initialize(file_path, mode)
|
15
|
+
@mode = mode
|
16
|
+
@todo_reader = Rubocop::TodoReader.new(file_path)
|
17
|
+
@todo_writer = Rubocop::TodoWriter.new(file_path)
|
18
|
+
end
|
19
|
+
|
20
|
+
def exec
|
21
|
+
verify_target_rule
|
22
|
+
todo_writer.delete_rule(target_rule)
|
23
|
+
`rubocop --auto-correct || true`
|
24
|
+
target_rule
|
25
|
+
end
|
26
|
+
|
27
|
+
def verify_target_rule
|
28
|
+
return unless target_rule.nil?
|
29
|
+
|
30
|
+
puts 'There is no auto-correctable rule'
|
31
|
+
exit
|
32
|
+
end
|
33
|
+
|
34
|
+
def target_rule
|
35
|
+
case mode
|
36
|
+
when 'least_occurrence' then todo_reader.least_occurrence_rule
|
37
|
+
when 'random' then todo_reader.any_rule
|
38
|
+
when 'most_occurrence' then todo_reader.most_occurrence_rule
|
39
|
+
else raise "`#{mode}` is not supported mode"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubocopChallenger
|
4
|
+
module Rubocop
|
5
|
+
class Rule
|
6
|
+
include Comparable
|
7
|
+
|
8
|
+
attr_reader :title, :offense_count, :contents
|
9
|
+
|
10
|
+
def initialize(contents)
|
11
|
+
@contents = contents.dup
|
12
|
+
@title = extract_title
|
13
|
+
@offense_count = extract_offense_count
|
14
|
+
end
|
15
|
+
|
16
|
+
def <=>(other)
|
17
|
+
self.offense_count <=> other.offense_count
|
18
|
+
end
|
19
|
+
|
20
|
+
def auto_correctable?
|
21
|
+
contents =~ /# Cop supports --auto-correct/
|
22
|
+
end
|
23
|
+
|
24
|
+
def rubydoc_url
|
25
|
+
if title.start_with?('RSpec')
|
26
|
+
"https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/#{title}"
|
27
|
+
else
|
28
|
+
"https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/#{title}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def description
|
33
|
+
message_const = "RuboCop::Cop::#{title.sub('/', '::')}::MSG"
|
34
|
+
Object.const_get(message_const) rescue '**NO DESCRIPTION**'
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def extract_title
|
40
|
+
contents =~ /^([^# ].+):$/
|
41
|
+
Regexp.last_match(1)
|
42
|
+
end
|
43
|
+
|
44
|
+
def extract_offense_count
|
45
|
+
contents =~ /# Offense count: (\d+)/
|
46
|
+
Regexp.last_match(1).to_i
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubocopChallenger
|
4
|
+
module Rubocop
|
5
|
+
class TodoReader
|
6
|
+
def initialize(rubocop_todo_file_path)
|
7
|
+
@rubocop_todo_file_path = rubocop_todo_file_path
|
8
|
+
end
|
9
|
+
|
10
|
+
def all_rules
|
11
|
+
@all_rules ||= extract_rubocop_rules
|
12
|
+
end
|
13
|
+
|
14
|
+
def auto_correctable_rules
|
15
|
+
all_rules.select(&:auto_correctable?)
|
16
|
+
end
|
17
|
+
|
18
|
+
def least_occurrence_rule
|
19
|
+
auto_correctable_rules.first
|
20
|
+
end
|
21
|
+
|
22
|
+
def most_occurrence_rule
|
23
|
+
auto_correctable_rules.last
|
24
|
+
end
|
25
|
+
|
26
|
+
def any_rule
|
27
|
+
auto_correctable_rules.sample
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
attr_reader :rubocop_todo_file_path
|
33
|
+
|
34
|
+
def extract_rubocop_rules
|
35
|
+
File
|
36
|
+
.read(rubocop_todo_file_path)
|
37
|
+
.split(/\n{2,}/)
|
38
|
+
.map! { |content| Rule.new(content) }
|
39
|
+
.reject! { |rule| rule.offense_count.zero? }
|
40
|
+
.sort!
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubocopChallenger
|
4
|
+
module Rubocop
|
5
|
+
class TodoWriter
|
6
|
+
def initialize(source, destination = source)
|
7
|
+
@source = source
|
8
|
+
@destination = destination
|
9
|
+
end
|
10
|
+
|
11
|
+
def delete_rule(rubocop_rule)
|
12
|
+
current_data = File.read(source)
|
13
|
+
File.write(destination, current_data.sub("\n#{rubocop_rule.contents}", ''))
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_reader :source, :destination
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubocop_challenger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ryosuke_sato
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pr-daikou
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubocop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop-rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.16'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.16'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec_junit_formatter
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Help to run `$ rubocop -a` on your CI
|
126
|
+
email:
|
127
|
+
- r-sato@feedforce.jp
|
128
|
+
executables:
|
129
|
+
- rubocop_challenger
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".circleci/config.yml"
|
134
|
+
- ".envrc.skeleton"
|
135
|
+
- ".gitignore"
|
136
|
+
- ".rspec"
|
137
|
+
- ".rubocop.yml"
|
138
|
+
- ".rubocop_todo.yml"
|
139
|
+
- CODE_OF_CONDUCT.md
|
140
|
+
- Gemfile
|
141
|
+
- Gemfile.lock
|
142
|
+
- LICENSE
|
143
|
+
- LICENSE.txt
|
144
|
+
- README.md
|
145
|
+
- Rakefile
|
146
|
+
- bin/console
|
147
|
+
- bin/setup
|
148
|
+
- challenger.gemspec
|
149
|
+
- exe/rubocop_challenger
|
150
|
+
- lib/rubocop_challenger.rb
|
151
|
+
- lib/rubocop_challenger/cli.rb
|
152
|
+
- lib/rubocop_challenger/rubocop/challenge.rb
|
153
|
+
- lib/rubocop_challenger/rubocop/rule.rb
|
154
|
+
- lib/rubocop_challenger/rubocop/todo_reader.rb
|
155
|
+
- lib/rubocop_challenger/rubocop/todo_writer.rb
|
156
|
+
- lib/rubocop_challenger/version.rb
|
157
|
+
homepage: https://github.com/ryz310/rubocop_challenger
|
158
|
+
licenses:
|
159
|
+
- MIT
|
160
|
+
metadata: {}
|
161
|
+
post_install_message:
|
162
|
+
rdoc_options: []
|
163
|
+
require_paths:
|
164
|
+
- lib
|
165
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
requirements: []
|
176
|
+
rubyforge_project:
|
177
|
+
rubygems_version: 2.7.3
|
178
|
+
signing_key:
|
179
|
+
specification_version: 4
|
180
|
+
summary: Help to run `$ rubocop -a` on your CI
|
181
|
+
test_files: []
|