rubomop 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/.rspec +3 -0
- data/.ruby-version +1 -0
- data/.standard.yml +3 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +82 -0
- data/LICENSE.txt +21 -0
- data/README.md +73 -0
- data/Rakefile +10 -0
- data/exe/rubomop +5 -0
- data/lib/rubomop/cop.rb +69 -0
- data/lib/rubomop/runner.rb +83 -0
- data/lib/rubomop/todo_file.rb +41 -0
- data/lib/rubomop/version.rb +5 -0
- data/lib/rubomop.rb +15 -0
- data/sig/rubomop.rbs +4 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3e23279657fd3a3f2172cbbcdd14d3f7c6067c8721a1e18b50eaf45ed7602149
|
4
|
+
data.tar.gz: 85f85b5809d827705ee7c0e77978c6efb24be669f3d50c013394373b82f7fe45
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 64d68023ebb7185bd24096b7377ec04f2968047c2dcee244873f56bcaa3cd569c917979d32db8a4cd95ce32ca342652f2569a9feac2f10b1dde2f1617f75b5f4
|
7
|
+
data.tar.gz: 5c1c1bb6adfe50f915dc1d2607ea2039bf0b6f8070ce89885dcdba72900f723b78b869c5b9221638ccc5b8c53e937c67c9ed0b84736fee9f14def7ae964780ed
|
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.1.2
|
data/.standard.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at noel.rappin@chime.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in rubomop.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem "awesome_print"
|
9
|
+
gem "rake", "~> 13.0"
|
10
|
+
gem "rspec", "~> 3.0"
|
11
|
+
gem "standard", "~> 1.3"
|
12
|
+
gem "rspec-collection_matchers"
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rubomop (0.1.0)
|
5
|
+
activesupport (> 5.0)
|
6
|
+
date_by_example (> 0.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (7.0.3.1)
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
+
i18n (>= 1.6, < 2)
|
14
|
+
minitest (>= 5.1)
|
15
|
+
tzinfo (~> 2.0)
|
16
|
+
ast (2.4.2)
|
17
|
+
awesome_print (1.9.2)
|
18
|
+
concurrent-ruby (1.1.10)
|
19
|
+
date_by_example (0.1.1)
|
20
|
+
diff-lcs (1.5.0)
|
21
|
+
i18n (1.12.0)
|
22
|
+
concurrent-ruby (~> 1.0)
|
23
|
+
minitest (5.16.2)
|
24
|
+
parallel (1.22.1)
|
25
|
+
parser (3.1.2.0)
|
26
|
+
ast (~> 2.4.1)
|
27
|
+
rainbow (3.1.1)
|
28
|
+
rake (13.0.6)
|
29
|
+
regexp_parser (2.5.0)
|
30
|
+
rexml (3.2.5)
|
31
|
+
rspec (3.11.0)
|
32
|
+
rspec-core (~> 3.11.0)
|
33
|
+
rspec-expectations (~> 3.11.0)
|
34
|
+
rspec-mocks (~> 3.11.0)
|
35
|
+
rspec-collection_matchers (1.2.0)
|
36
|
+
rspec-expectations (>= 2.99.0.beta1)
|
37
|
+
rspec-core (3.11.0)
|
38
|
+
rspec-support (~> 3.11.0)
|
39
|
+
rspec-expectations (3.11.0)
|
40
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
+
rspec-support (~> 3.11.0)
|
42
|
+
rspec-mocks (3.11.1)
|
43
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
+
rspec-support (~> 3.11.0)
|
45
|
+
rspec-support (3.11.0)
|
46
|
+
rubocop (1.29.1)
|
47
|
+
parallel (~> 1.10)
|
48
|
+
parser (>= 3.1.0.0)
|
49
|
+
rainbow (>= 2.2.2, < 4.0)
|
50
|
+
regexp_parser (>= 1.8, < 3.0)
|
51
|
+
rexml (>= 3.2.5, < 4.0)
|
52
|
+
rubocop-ast (>= 1.17.0, < 2.0)
|
53
|
+
ruby-progressbar (~> 1.7)
|
54
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
55
|
+
rubocop-ast (1.19.1)
|
56
|
+
parser (>= 3.1.1.0)
|
57
|
+
rubocop-performance (1.13.3)
|
58
|
+
rubocop (>= 1.7.0, < 2.0)
|
59
|
+
rubocop-ast (>= 0.4.0)
|
60
|
+
ruby-progressbar (1.11.0)
|
61
|
+
standard (1.12.1)
|
62
|
+
rubocop (= 1.29.1)
|
63
|
+
rubocop-performance (= 1.13.3)
|
64
|
+
tzinfo (2.0.4)
|
65
|
+
concurrent-ruby (~> 1.0)
|
66
|
+
unicode-display_width (2.2.0)
|
67
|
+
|
68
|
+
PLATFORMS
|
69
|
+
arm64-darwin-21
|
70
|
+
x86_64-darwin-21
|
71
|
+
x86_64-linux
|
72
|
+
|
73
|
+
DEPENDENCIES
|
74
|
+
awesome_print
|
75
|
+
rake (~> 13.0)
|
76
|
+
rspec (~> 3.0)
|
77
|
+
rspec-collection_matchers
|
78
|
+
rubomop!
|
79
|
+
standard (~> 1.3)
|
80
|
+
|
81
|
+
BUNDLED WITH
|
82
|
+
2.3.7
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 Noel Rappin
|
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,73 @@
|
|
1
|
+
# Rubomop
|
2
|
+
|
3
|
+
Rubomop cleans up after your Rubocop.
|
4
|
+
|
5
|
+
It allows you to randomly delete items from your `rubocop_todo.yml` file and
|
6
|
+
then rerun Rubocop.
|
7
|
+
|
8
|
+
Please note -- this is probably something you should do with caution, if you
|
9
|
+
run this, make sure you inspect the changes before you acutally commit them
|
10
|
+
back to your repo. Run your tests.
|
11
|
+
|
12
|
+
This could definitely mess things up if the Rubocop autocorrects change the
|
13
|
+
meaning of your code
|
14
|
+
|
15
|
+
Use at your own risk
|
16
|
+
|
17
|
+
Options include
|
18
|
+
|
19
|
+
* The number of items to delete (default: 10)
|
20
|
+
* Whether to limit to autocorrectable cops (default: true)
|
21
|
+
* Whether to automatically run `rubocop -a` after deletion
|
22
|
+
|
23
|
+
## Installation
|
24
|
+
|
25
|
+
Add this line to your application's Gemfile:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
gem "rubomop"
|
29
|
+
```
|
30
|
+
|
31
|
+
(Well, until I actually submit it, it's)
|
32
|
+
|
33
|
+
```
|
34
|
+
gem "rubocop", github: "noelrappin/rubomop"
|
35
|
+
```
|
36
|
+
|
37
|
+
|
38
|
+
And then execute:
|
39
|
+
|
40
|
+
$ bundle install
|
41
|
+
|
42
|
+
Or install it yourself as:
|
43
|
+
|
44
|
+
$ gem install rubomop
|
45
|
+
|
46
|
+
## Usage
|
47
|
+
|
48
|
+
```
|
49
|
+
$ rubomop --help
|
50
|
+
Usage: rubomop [options]
|
51
|
+
-n, --number NUMBER Number of cleanups to perform (default: 10)
|
52
|
+
-a, --autocorrect_only Only clean autocorrectable cops (default)
|
53
|
+
--no_autocorrect_only Clean all cops (not default)
|
54
|
+
-r, --run_rubocop Run rubocop -aD after (default)
|
55
|
+
-f, --filename FILENAME Name of todo file (default: ./.rubocop_todo.yml)
|
56
|
+
--no_run_rubocop Don't run rubocop -aD after (not default)
|
57
|
+
-h, --help Prints this help
|
58
|
+
```
|
59
|
+
|
60
|
+
## Development
|
61
|
+
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rubomop. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/rubomop/blob/main/CODE_OF_CONDUCT.md).
|
66
|
+
|
67
|
+
## License
|
68
|
+
|
69
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
70
|
+
|
71
|
+
## Code of Conduct
|
72
|
+
|
73
|
+
Everyone interacting in the Rubomop project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/rubomop/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/exe/rubomop
ADDED
data/lib/rubomop/cop.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
module Rubomop
|
2
|
+
class Cop
|
3
|
+
attr_accessor :offense_count, :name, :files, :autocorrect, :comments
|
4
|
+
attr_reader :raw_lines
|
5
|
+
|
6
|
+
def self.create_and_parse(raw_lines)
|
7
|
+
result = new(raw_lines)
|
8
|
+
result.parse
|
9
|
+
result
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(raw_lines)
|
13
|
+
@raw_lines = raw_lines
|
14
|
+
@files = []
|
15
|
+
@autocorrect = false
|
16
|
+
@comments = []
|
17
|
+
end
|
18
|
+
|
19
|
+
def parse
|
20
|
+
raw_lines.each { parse_one_line(_1) }
|
21
|
+
end
|
22
|
+
|
23
|
+
OFFENSE_COUNT_REGEX = /\A# Offense count: (\d*)/
|
24
|
+
COP_NAME_REGEX = /\A(.*):/
|
25
|
+
FILE_NAME_REGEX = /- '(.*)'/
|
26
|
+
AUTOCORRECT_REGEX = /\A# Cop supports --auto-correct./
|
27
|
+
GENERAL_COMMENT_REGEX = /\A#/
|
28
|
+
EXCLUDE_REGEX = /Exclude:/
|
29
|
+
|
30
|
+
def parse_one_line(line)
|
31
|
+
case line
|
32
|
+
when OFFENSE_COUNT_REGEX
|
33
|
+
self.offense_count = line.match(OFFENSE_COUNT_REGEX)[1].to_i
|
34
|
+
when AUTOCORRECT_REGEX
|
35
|
+
self.autocorrect = true
|
36
|
+
when GENERAL_COMMENT_REGEX
|
37
|
+
comments << line.chomp
|
38
|
+
when EXCLUDE_REGEX
|
39
|
+
# no-op
|
40
|
+
when COP_NAME_REGEX
|
41
|
+
self.name = line.match(COP_NAME_REGEX)[1]
|
42
|
+
when FILE_NAME_REGEX
|
43
|
+
files << line.match(FILE_NAME_REGEX)[1]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def output
|
48
|
+
output_lines.join("\n")
|
49
|
+
end
|
50
|
+
|
51
|
+
def output_lines
|
52
|
+
result = ["# Offense count: #{offense_count}"]
|
53
|
+
result << "# Cop supports --auto-correct." if autocorrect
|
54
|
+
result += comments
|
55
|
+
result << "#{name}:"
|
56
|
+
result << " Exclude:"
|
57
|
+
result + files.map { " - '#{_1}'"}
|
58
|
+
end
|
59
|
+
|
60
|
+
def delete_options
|
61
|
+
files.map { {cop: self, file: _1} }
|
62
|
+
end
|
63
|
+
|
64
|
+
def delete!(filename)
|
65
|
+
files.delete(filename)
|
66
|
+
self.offense_count -= 1
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Rubomop
|
2
|
+
class Runner
|
3
|
+
attr_accessor :number, :autocorrect_only, :run_rubocop, :filename, :todo
|
4
|
+
NUM_STRING = "Number of cleanups to perform (default: 10)"
|
5
|
+
AUTOCORRECT_STRING = "Only clean autocorrectable cops (default)"
|
6
|
+
NO_AUTOCORRECT_STRING = "Clean all cops (not default)"
|
7
|
+
RUBOCOP_STRING = "Run rubocop -aD after (default)"
|
8
|
+
NO_RUBOCOP_STRING = "Don't run rubocop -aD after (not default)"
|
9
|
+
FILENAME_STRING = "Name of todo file (default: ./.rubocop_todo.yml)"
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@number = 10
|
13
|
+
@autocorrect_only = true
|
14
|
+
@run_rubocop = true
|
15
|
+
@filename = ".rubocop_todo.yml"
|
16
|
+
@todo = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def execute(args)
|
20
|
+
parse(args)
|
21
|
+
run
|
22
|
+
end
|
23
|
+
|
24
|
+
def parse(args)
|
25
|
+
option_parser = OptionParser.new do |opts|
|
26
|
+
opts.banner = "Usage: rubomop [options]"
|
27
|
+
opts.on("-nNUMBER", "--number NUMBER", Integer, NUM_STRING) do |value|
|
28
|
+
self.number = value
|
29
|
+
end
|
30
|
+
opts.on("-a", "--autocorrect-only", AUTOCORRECT_STRING) do
|
31
|
+
self.autocorrect_only = true
|
32
|
+
end
|
33
|
+
opts.on("--no_autocorrect-only", NO_AUTOCORRECT_STRING) do
|
34
|
+
self.autocorrect_only = false
|
35
|
+
end
|
36
|
+
opts.on("-r", "--run-rubocop", RUBOCOP_STRING) do
|
37
|
+
self.run_rubocop = true
|
38
|
+
end
|
39
|
+
opts.on("-fFILENAME", "--filename FILENAME", FILENAME_STRING) do |value|
|
40
|
+
self.filename = value
|
41
|
+
end
|
42
|
+
opts.on("--no-run-rubocop", NO_RUBOCOP_STRING) do
|
43
|
+
self.run_rubocop = false
|
44
|
+
end
|
45
|
+
opts.on("-h", "--help", "Prints this help") do
|
46
|
+
puts opts
|
47
|
+
exit
|
48
|
+
end
|
49
|
+
end
|
50
|
+
option_parser.parse(args)
|
51
|
+
end
|
52
|
+
|
53
|
+
def run
|
54
|
+
self.todo = TodoFile.new(filename: filename)&.parse
|
55
|
+
return if todo.nil?
|
56
|
+
number.times do |i|
|
57
|
+
delete_options = todo&.delete_options(autocorrect_only: autocorrect_only)
|
58
|
+
next if delete_options.empty?
|
59
|
+
object_to_delete = delete_options.sample
|
60
|
+
print "#{i + 1}: Deleting #{object_to_delete[:file]} from #{object_to_delete[:cop].name}\n"
|
61
|
+
todo&.delete!(object_to_delete)
|
62
|
+
end
|
63
|
+
backup_existing_file
|
64
|
+
save_new_file
|
65
|
+
rubocop_runner
|
66
|
+
end
|
67
|
+
|
68
|
+
def backup_existing_file
|
69
|
+
FileUtils.rm("#{filename}.bak") if File.exist?("#{filename}.bak")
|
70
|
+
FileUtils.mv(filename, "#{filename}.bak")
|
71
|
+
end
|
72
|
+
|
73
|
+
def save_new_file
|
74
|
+
File.write(filename, todo&.output || "")
|
75
|
+
end
|
76
|
+
|
77
|
+
def rubocop_runner
|
78
|
+
return unless run_rubocop
|
79
|
+
print "Running bundle exec rubocop -aD"
|
80
|
+
system("bundle exec rubocop -aD")
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Rubomop
|
2
|
+
class TodoFile
|
3
|
+
attr_reader :filename
|
4
|
+
attr_accessor :raw_lines, :header, :cops
|
5
|
+
|
6
|
+
def initialize(filename:)
|
7
|
+
@filename = filename
|
8
|
+
end
|
9
|
+
|
10
|
+
def parse
|
11
|
+
self.raw_lines = File.readlines(filename)
|
12
|
+
self.header, *raw_tasks = raw_lines.split("\n")
|
13
|
+
self.cops = raw_tasks.map { Cop.create_and_parse(_1) }
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def output_lines
|
18
|
+
result = header.map(&:chomp)
|
19
|
+
result << ""
|
20
|
+
cops.each do |cop|
|
21
|
+
result += cop.output_lines
|
22
|
+
result << ""
|
23
|
+
end
|
24
|
+
result[0..-2]
|
25
|
+
end
|
26
|
+
|
27
|
+
def output
|
28
|
+
output_lines.join("\n") + "\n"
|
29
|
+
end
|
30
|
+
|
31
|
+
def delete_options(autocorrect_only: true)
|
32
|
+
result = cops.flat_map(&:delete_options)
|
33
|
+
result = result.select { _1[:cop].autocorrect } if autocorrect_only
|
34
|
+
result
|
35
|
+
end
|
36
|
+
|
37
|
+
def delete!(delete_option)
|
38
|
+
delete_option[:cop].delete!(delete_option[:file])
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/rubomop.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "fileutils"
|
4
|
+
require "optparse"
|
5
|
+
require "awesome_print"
|
6
|
+
require "active_support/core_ext/array"
|
7
|
+
require_relative "rubomop/cop"
|
8
|
+
require_relative "rubomop/runner"
|
9
|
+
require_relative "rubomop/todo_file"
|
10
|
+
require_relative "rubomop/version"
|
11
|
+
|
12
|
+
module Rubomop
|
13
|
+
class Error < StandardError; end
|
14
|
+
# Your code goes here...
|
15
|
+
end
|
data/sig/rubomop.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubomop
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Noel Rappin
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-07-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: date_by_example
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.0'
|
41
|
+
description: Rubomop cleans up after your Rubocop
|
42
|
+
email:
|
43
|
+
- noel.rappin@chime.com
|
44
|
+
executables:
|
45
|
+
- rubomop
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".rspec"
|
50
|
+
- ".ruby-version"
|
51
|
+
- ".standard.yml"
|
52
|
+
- CHANGELOG.md
|
53
|
+
- CODE_OF_CONDUCT.md
|
54
|
+
- Gemfile
|
55
|
+
- Gemfile.lock
|
56
|
+
- LICENSE.txt
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- exe/rubomop
|
60
|
+
- lib/rubomop.rb
|
61
|
+
- lib/rubomop/cop.rb
|
62
|
+
- lib/rubomop/runner.rb
|
63
|
+
- lib/rubomop/todo_file.rb
|
64
|
+
- lib/rubomop/version.rb
|
65
|
+
- sig/rubomop.rbs
|
66
|
+
homepage: https://github.com/noelrappin/rubomop
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
metadata:
|
70
|
+
allowed_push_host: https://rubygems.org
|
71
|
+
homepage_uri: https://github.com/noelrappin/rubomop
|
72
|
+
source_code_uri: https://github.com/noelrappin/rubomop
|
73
|
+
changelog_uri: https://github.com/noelrappin/rubomop/CHANGELOG.md
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.7.0
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubygems_version: 3.3.7
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: Rubomop cleans up after your Rubocop
|
93
|
+
test_files: []
|