rfix 1.0.6 → 1.0.7.pre.68
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -2
- data/Gemfile.lock +1 -1
- data/README.md +59 -13
- data/exe/rfix +10 -31
- data/lib/rfix.rb +14 -1
- data/lib/rfix/cmd.rb +1 -1
- data/lib/rfix/extensions/extensions.rb +40 -0
- data/lib/rfix/extensions/offense.rb +77 -0
- data/lib/rfix/formatter.rb +1 -24
- data/lib/rfix/git_helper.rb +3 -1
- data/lib/rfix/log.rb +1 -1
- data/lib/rfix/rfix.rb +44 -0
- data/lib/rfix/version.rb +1 -1
- data/resources/ps.png +0 -0
- data/rfix.gemspec +14 -1
- metadata +24 -11
- data/lib/rfix/extensions.rb +0 -92
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a26f95a0567bf3581515e5f7b7acc0b020ffad71f610e64cec9314b1a128573d
|
4
|
+
data.tar.gz: f70e41c32e3fe733fda2349d83c02e77705461337da6c0b5313e763c0950a46c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 325fa9f8df215013e37cb0ee1b05d969cc3c66933a52b52605bbff6a5a4061445d7bb143b05bdca7ba624a5d9aa722582df782ea211110e83fd4cecd35d3b965
|
7
|
+
data.tar.gz: 255ffb2025dd390cb83939ffa90479cdb7dcd395b9f0511f9afdda54aad56c9975662c20080b575d31d4e9b9c1a35ce3f96b02629921a39684f669210f09cae3
|
data/.travis.yml
CHANGED
@@ -1,4 +1,11 @@
|
|
1
1
|
language: ruby
|
2
|
+
cache:
|
3
|
+
bundler: true
|
4
|
+
directories:
|
5
|
+
- $HOME/.rvm
|
6
|
+
- $HOME/Library/Caches/Homebrew
|
7
|
+
before_cache:
|
8
|
+
- brew cleanup
|
2
9
|
rvm:
|
3
10
|
- 2.5.0
|
4
11
|
- 2.6.2
|
@@ -17,8 +24,7 @@ gemfile:
|
|
17
24
|
- ci/Gemfile.rubocop-0.85.1
|
18
25
|
before_install:
|
19
26
|
- yes | gem update --system --force
|
20
|
-
- gem
|
21
|
-
- gem install bundler -v 2.1.4
|
27
|
+
- gem install bundler
|
22
28
|
- bundle config git.allow_insecure true
|
23
29
|
install:
|
24
30
|
- bundle install
|
@@ -37,4 +43,5 @@ jobs:
|
|
37
43
|
gem: rfix
|
38
44
|
on:
|
39
45
|
repo: oleander/rfix-rb
|
46
|
+
tags: false
|
40
47
|
cleanup: 'false'
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,39 +1,85 @@
|
|
1
|
-
# Rfix [](https://travis-ci.org/oleander/rfix-rb)
|
1
|
+
# Rfix [](https://travis-ci.org/oleander/rfix-rb) [](https://rubygems.org/gems/rfix)
|
2
2
|
|
3
|
-
RuboCop CLI that only complains about your latest changes
|
3
|
+
RuboCop CLI that only complains about your latest changes. Includes a RuboCop formatter with syntax highlighting and build in hyperlinks for offense documentation. Supports both linting (`rfix lint`) and the RuboCops autofix feature (`rfix local|origin|branch`) for the changes you made.
|
4
|
+
|
5
|
+
Supports the same CLI arguments as RuboCop. Run `rfix --help` for the complete list.
|
6
|
+
|
7
|
+

|
4
8
|
|
5
9
|
## Installation
|
6
10
|
|
7
11
|
``` shell
|
8
|
-
$ gem install rfix
|
9
|
-
|
12
|
+
$ gem install rfix --pre
|
13
|
+
```
|
14
|
+
|
15
|
+
## Help
|
16
|
+
|
17
|
+
``` shell
|
18
|
+
$ rfix branch <branch> # Fix changes made between HEAD and <branch>
|
19
|
+
$ rfix origin # Fix changes made between HEAD and origin branch
|
20
|
+
$ rfix local # Fix changes not yet pushed to upstream branch
|
21
|
+
$ rfix info # Display runtime dependencies and their versions
|
22
|
+
$ rfix all # Fix all files in this repository (not recommended)
|
23
|
+
$ rfix lint # Shortcut for 'rfix local --dry --untracked'
|
24
|
+
$ rfix # Displays this list of supported commands
|
10
25
|
```
|
11
26
|
|
27
|
+
### Arguments
|
28
|
+
|
29
|
+
- `--dry` Turns off RuboCops autofix feature (read-only mode)
|
30
|
+
- `--help` Displays RubyCops and Rfix supported arguments
|
31
|
+
- `--list-files` List all files being passed to RubyCop
|
32
|
+
- `--untracked` Include files not tracked by git
|
33
|
+
- `--config` Configuration file, defaults to `.rubocop.yml`
|
34
|
+
|
12
35
|
## Development
|
13
36
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
37
|
+
### Setup
|
38
|
+
|
39
|
+
1. Download repository
|
40
|
+
1. `$ git clone https://github.com/oleander/rfix-rb`
|
41
|
+
2. `$ cd rfix-rb`
|
42
|
+
2. Downloads fixtures and run time dependencies
|
43
|
+
- `$ bundle exec rake setup`
|
44
|
+
|
45
|
+
### Install from repository
|
46
|
+
|
47
|
+
``` shell
|
48
|
+
$ bundle exec rake local
|
49
|
+
```
|
50
|
+
|
51
|
+
### Run tests
|
52
|
+
|
53
|
+
``` shell
|
54
|
+
$ bundle exec rake spec
|
55
|
+
```
|
20
56
|
|
21
57
|
## Overcommit
|
22
58
|
|
59
|
+
Add the following to your `.overcommit.yml`, then run `overcommit --install` and `overcommit --sign pre-commit`. It will lint commits not yet pushed to upstream branch everytime `git commit` is ran.
|
60
|
+
|
23
61
|
``` yaml
|
24
62
|
PreCommit:
|
25
63
|
RFix:
|
26
64
|
enabled: true
|
27
|
-
command: ["rfix", "
|
28
|
-
description: "Lint
|
65
|
+
command: ["rfix", "lint"]
|
66
|
+
description: "Lint unchanged commits using RuboCop"
|
29
67
|
parallelize: true
|
30
68
|
```
|
31
69
|
|
70
|
+
### From scratch
|
71
|
+
|
72
|
+
1. `gem install overcommit rfix`
|
73
|
+
2. `curl https://raw.githubusercontent.com/oleander/rfix-rb/master/resouces/overcommit.yml > .overcommit.yml`
|
74
|
+
3. `overcommit --install`
|
75
|
+
4. `overcommit --sign pre-commit`
|
76
|
+
|
77
|
+
Run `overcommit --run` to test the new hook.
|
78
|
+
|
32
79
|
## Contributing
|
33
80
|
|
34
81
|
Bug reports and pull requests are welcome on GitHub at https://github.com/oleander/rfix.
|
35
82
|
|
36
|
-
|
37
83
|
## License
|
38
84
|
|
39
85
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/exe/rfix
CHANGED
@@ -20,38 +20,13 @@ CLI::UI::StdoutRouter.enable
|
|
20
20
|
|
21
21
|
say "Using RuboCop {{yellow:#{RuboCop::Version.version}}}"
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
force_exclusion: true,
|
26
|
-
auto_correct: true,
|
27
|
-
formatters: ["Rfix::Formatter"]
|
28
|
-
}
|
29
|
-
|
30
|
-
# For version 0.80.x .. 0.83.x:
|
31
|
-
# Otherwise it will exit with status code = 1
|
32
|
-
if (0.80..0.83).include?(RuboCop::Version::STRING.to_f)
|
33
|
-
if is_dry
|
34
|
-
base_config[:fail_level] = :autocorrect
|
35
|
-
else
|
36
|
-
base_config[:fail_level] = :warning
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def load_config
|
41
|
-
yield
|
42
|
-
rescue RuboCop::Error => e
|
43
|
-
say_abort "[Config] #{e}"
|
44
|
-
rescue TypeError => e
|
45
|
-
say_abort "[Config] #{e}"
|
23
|
+
options.on("--untracked", "Include untracked files") do
|
24
|
+
Rfix.load_untracked!
|
46
25
|
end
|
47
26
|
|
48
27
|
options.on("--dry", "No auto correct") do
|
49
28
|
say "Will run rfix in {{red:read-only}} mode"
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
options.on("--untracked", "Include untracked files") do
|
54
|
-
Rfix.load_untracked!
|
29
|
+
Rfix.no_auto_correct!
|
55
30
|
end
|
56
31
|
|
57
32
|
options.on("--list-files", "List files found by git") do
|
@@ -73,6 +48,9 @@ when "info"
|
|
73
48
|
say "Using Git {{yellow:#{Rfix.git_version}}}"
|
74
49
|
say "Using Ruby {{yellow:#{Rfix.ruby_version}}}"
|
75
50
|
exit 0
|
51
|
+
when "lint"
|
52
|
+
Rfix.lint_mode!
|
53
|
+
reference = Rfix.ref_since_push
|
76
54
|
when "local"
|
77
55
|
reference = Rfix.ref_since_push
|
78
56
|
when "origin"
|
@@ -102,6 +80,7 @@ else
|
|
102
80
|
say_error_sub "\t{{bold:rfix local}} -- {{italic:Fix changes not yet pushed to upstream branch}}"
|
103
81
|
say_error_sub "\t{{bold:rfix info}} -- {{italic:Display runtime dependencies and their versions}}"
|
104
82
|
say_error_sub "\t{{bold:rfix all}} -- {{italic:Fix all files in this repository}} {{warning:(not recommended)}}"
|
83
|
+
say_error_sub "\t{{bold:rfix lint}} -- {{italic:Shortcut for 'local --dry --untracked'}}"
|
105
84
|
say_error_sub "\n"
|
106
85
|
say_error_sub "\t{{italic:Optional args: --dry --help --list-files --limit-files --config --untracked}}"
|
107
86
|
exit 1
|
@@ -117,11 +96,11 @@ rescue OptionParser::MissingArgument => e
|
|
117
96
|
end
|
118
97
|
|
119
98
|
if path = config_path
|
120
|
-
load_config do
|
99
|
+
Rfix.load_config do
|
121
100
|
config.options_config = path
|
122
101
|
end
|
123
102
|
else
|
124
|
-
load_config do
|
103
|
+
Rfix.load_config do
|
125
104
|
config.for(Dir.pwd)
|
126
105
|
end
|
127
106
|
end
|
@@ -149,7 +128,7 @@ if should_list_files
|
|
149
128
|
end
|
150
129
|
|
151
130
|
env = RuboCop::CLI::Environment.new(
|
152
|
-
|
131
|
+
Rfix.config.merge(options),
|
153
132
|
config,
|
154
133
|
paths
|
155
134
|
)
|
data/lib/rfix.rb
CHANGED
@@ -5,9 +5,22 @@
|
|
5
5
|
|
6
6
|
require "rfix/version"
|
7
7
|
require "rfix/log"
|
8
|
-
require "rfix/extensions"
|
8
|
+
require "rfix/extensions/extensions"
|
9
|
+
require "rfix/extensions/offense"
|
9
10
|
require "rfix/rfix"
|
10
11
|
|
11
12
|
module Rfix
|
13
|
+
module Ext; end
|
12
14
|
extend self
|
13
15
|
end
|
16
|
+
|
17
|
+
RuboCop::Options.prepend(Rfix::Ext::Options)
|
18
|
+
RuboCop::Runner.prepend(Rfix::Ext::Runner)
|
19
|
+
RuboCop::CommentConfig.prepend(Rfix::Ext::CommentConfig)
|
20
|
+
RuboCop::Cop::Offense.prepend(Rfix::Ext::Offense)
|
21
|
+
|
22
|
+
# TODO: Handle cases where color can't be resolved by CLI::UI
|
23
|
+
RuboCop::Formatter::SimpleTextFormatter::COLOR_FOR_SEVERITY.each do |severity, color|
|
24
|
+
id = RuboCop::Cop::Severity::CODE_TABLE.invert.fetch(severity)
|
25
|
+
CLI::UI::Glyph.new(id.to_s, 0x25cf, CLI::UI.resolve_color(color))
|
26
|
+
end
|
data/lib/rfix/cmd.rb
CHANGED
@@ -13,7 +13,7 @@ module Rfix::Cmd
|
|
13
13
|
unless status.success?
|
14
14
|
return yield if block_given?
|
15
15
|
|
16
|
-
say_error "[Cmd] {{italic:#{args.join(
|
16
|
+
say_error "[Cmd] {{italic:#{args.join(' ')}}}"
|
17
17
|
say_error "[Pwd] {{italic:#{Dir.pwd}}}"
|
18
18
|
say_error "[Err] {{error:#{err.strip}}}"
|
19
19
|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rubocop"
|
4
|
+
require "rainbow"
|
5
|
+
|
6
|
+
module Rfix::Ext
|
7
|
+
module CommentConfig
|
8
|
+
# Called by RuboCop on every line to see
|
9
|
+
# if its suppose to run against it or not
|
10
|
+
def cop_enabled_at_line?(_cop, line)
|
11
|
+
Rfix.enabled?(processed_source.file_path, line) && super
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module Runner
|
16
|
+
# Called _after_ @source has been 'auto fixed' by Rubocop
|
17
|
+
def check_for_infinite_loop(source, offences)
|
18
|
+
# rubocop:disable Style/Semicolon
|
19
|
+
Rfix.refresh!(source); super
|
20
|
+
# rubocop:enable Style/Semicolon
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module Options
|
25
|
+
# Appends custom --args to RuboCop CLI
|
26
|
+
def define_options
|
27
|
+
super.tap do |options|
|
28
|
+
@ons.each do |args, block|
|
29
|
+
option(options, *args, &block)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Helper method used by rfix to append cli --args to Rubocop
|
35
|
+
def on(*args, &block)
|
36
|
+
@ons ||= []
|
37
|
+
@ons += [[args, block]]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Rfix::Ext
|
2
|
+
module Offense
|
3
|
+
def where
|
4
|
+
line.to_s + ":" + real_column.to_s
|
5
|
+
end
|
6
|
+
|
7
|
+
def info
|
8
|
+
message.split(": ", 2).last.delete("\n")
|
9
|
+
end
|
10
|
+
|
11
|
+
def msg
|
12
|
+
CLI::UI.resolve_text("{{italic:#{info}}}", truncate_to: CLI::UI::Terminal.width - 10)
|
13
|
+
end
|
14
|
+
|
15
|
+
def code
|
16
|
+
message.split(": ", 2).first
|
17
|
+
end
|
18
|
+
|
19
|
+
def star
|
20
|
+
Rainbow("⭑")
|
21
|
+
end
|
22
|
+
|
23
|
+
def cross
|
24
|
+
Rainbow("✗").red
|
25
|
+
end
|
26
|
+
|
27
|
+
def check
|
28
|
+
Rainbow("✓").green
|
29
|
+
end
|
30
|
+
|
31
|
+
def circle
|
32
|
+
Rainbow("⍟")
|
33
|
+
end
|
34
|
+
|
35
|
+
def relative_path
|
36
|
+
Rfix.to_relative(path: location.source_buffer.name)
|
37
|
+
end
|
38
|
+
|
39
|
+
def clickable_path
|
40
|
+
"{{italic:#{relative_path}:#{where}}}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def clickable_plain_severity
|
44
|
+
to_url("https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/#{code}", code)
|
45
|
+
end
|
46
|
+
|
47
|
+
def clickable_severity
|
48
|
+
"{{#{severity.code}}} {{italic:#{clickable_plain_severity}}}"
|
49
|
+
end
|
50
|
+
|
51
|
+
def icon
|
52
|
+
return check.green if corrected?
|
53
|
+
return star.yellow if correctable?
|
54
|
+
|
55
|
+
cross.red
|
56
|
+
end
|
57
|
+
|
58
|
+
def to_clickable(url, title)
|
59
|
+
esc = CLI::UI::ANSI::ESC
|
60
|
+
cmd = esc + "]8;;"
|
61
|
+
slash = "\x07"
|
62
|
+
cmd + "#{escape(url)}#{slash}#{escape(title)}" + cmd + slash
|
63
|
+
end
|
64
|
+
|
65
|
+
def to_path(path, title)
|
66
|
+
to_clickable("file://#{path}", title)
|
67
|
+
end
|
68
|
+
|
69
|
+
def to_url(url, title)
|
70
|
+
to_clickable(url, title)
|
71
|
+
end
|
72
|
+
|
73
|
+
def escape(str)
|
74
|
+
Shellwords.escape(str)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/lib/rfix/formatter.rb
CHANGED
@@ -30,37 +30,14 @@ module Rfix
|
|
30
30
|
report_summary(files.size, offenses.count, corrected.count)
|
31
31
|
end
|
32
32
|
|
33
|
-
def to_clickable(url, title)
|
34
|
-
esc = CLI::UI::ANSI::ESC
|
35
|
-
cmd = esc + "]8;;"
|
36
|
-
slash = "\x07"
|
37
|
-
cmd + "#{escape(url)}#{slash}#{escape(title)}" + cmd + slash
|
38
|
-
end
|
39
|
-
|
40
|
-
def to_path(path, title)
|
41
|
-
to_clickable("file://#{path}", title)
|
42
|
-
end
|
43
|
-
|
44
|
-
def to_url(url, title)
|
45
|
-
to_clickable(url, title)
|
46
|
-
end
|
47
|
-
|
48
|
-
def escape(str)
|
49
|
-
Shellwords.escape(str)
|
50
|
-
end
|
51
|
-
|
52
33
|
def render_file(file, offenses)
|
53
34
|
return if offenses.empty?
|
54
35
|
|
55
|
-
path = Rfix.to_relative(path: file)
|
56
|
-
url = to_url(file, path)
|
57
36
|
offenses.each do |offense|
|
58
37
|
out("\n\n")
|
59
|
-
clickable_path = "{{italic:#{path}:#{offense.where}}}"
|
60
|
-
clickable_code = to_url("https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/#{offense.code}", offense.code)
|
61
38
|
CLI::UI::Frame.open("#{offense.icon} #{offense.msg}", color: :reset)
|
62
39
|
report_line(file, offense, offense.location, offense.highlighted_area)
|
63
|
-
CLI::UI::Frame.close("#{
|
40
|
+
CLI::UI::Frame.close("#{offense.clickable_severity} » #{offense.clickable_path}", color: :reset)
|
64
41
|
end
|
65
42
|
end
|
66
43
|
|
data/lib/rfix/git_helper.rb
CHANGED
data/lib/rfix/log.rb
CHANGED
data/lib/rfix/rfix.rb
CHANGED
@@ -13,6 +13,36 @@ module Rfix
|
|
13
13
|
include GitHelper
|
14
14
|
include Log
|
15
15
|
|
16
|
+
def config
|
17
|
+
@config
|
18
|
+
end
|
19
|
+
|
20
|
+
def set_fail_level(lint)
|
21
|
+
if if lint
|
22
|
+
else
|
23
|
+
@config[:fail_level] = :warning
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def no_auto_correct!
|
29
|
+
@config[:auto_correct] = false
|
30
|
+
end
|
31
|
+
|
32
|
+
def load_config
|
33
|
+
yield
|
34
|
+
rescue RuboCop::Error => e
|
35
|
+
say_abort "[Config] #{e}"
|
36
|
+
rescue TypeError => e
|
37
|
+
say_abort "[Config] #{e}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def lint_mode!
|
41
|
+
@config[:auto_correct] = false
|
42
|
+
@config[:fail_level] = :warning if old?
|
43
|
+
load_untracked!
|
44
|
+
end
|
45
|
+
|
16
46
|
def git_version
|
17
47
|
cmd("git --version").last.split(/\s+/, 3).last
|
18
48
|
end
|
@@ -36,6 +66,14 @@ module Rfix
|
|
36
66
|
def init!
|
37
67
|
@files ||= {}
|
38
68
|
@global_enable = false
|
69
|
+
@config = {
|
70
|
+
color: true,
|
71
|
+
force_exclusion: true,
|
72
|
+
auto_correct: true,
|
73
|
+
formatters: ["Rfix::Formatter"]
|
74
|
+
}
|
75
|
+
|
76
|
+
@config[:fail_level] = :autocorrect if old?
|
39
77
|
end
|
40
78
|
|
41
79
|
def files
|
@@ -100,6 +138,12 @@ module Rfix
|
|
100
138
|
|
101
139
|
private
|
102
140
|
|
141
|
+
def old?
|
142
|
+
# For version 0.80.x .. 0.83.x:
|
143
|
+
# Otherwise it will exit with status code = 1
|
144
|
+
(0.80..0.83).include?(RuboCop::Version::STRING.to_f)
|
145
|
+
end
|
146
|
+
|
103
147
|
def get_file(path, &block)
|
104
148
|
if file = @files[path]
|
105
149
|
block.call(file)
|
data/lib/rfix/version.rb
CHANGED
data/resources/ps.png
ADDED
Binary file
|
data/rfix.gemspec
CHANGED
@@ -18,7 +18,18 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.email = ["linus@oleander.nu"]
|
19
19
|
|
20
20
|
spec.summary = "RuboCop CLI that only complains about your latest changes"
|
21
|
-
spec.description =
|
21
|
+
spec.description = <<~TEXT
|
22
|
+
#{spec.summary}
|
23
|
+
Uses 'git diff' to determine what changes were made then runs RuboCop against them
|
24
|
+
|
25
|
+
$ rfix branch <branch> -- Fix changes made between HEAD and <branch>
|
26
|
+
$ rfix origin -- Fix changes made between HEAD and origin branch
|
27
|
+
$ rfix local -- Fix changes not yet pushed to upstream branch
|
28
|
+
$ rfix info -- Display runtime dependencies and their versions
|
29
|
+
$ rfix all -- Fix all files in this repository (not recommended)
|
30
|
+
|
31
|
+
Optional args: --dry --help --list-files --limit-files --config --untracked
|
32
|
+
TEXT
|
22
33
|
spec.homepage = "https://github.com/oleander/rfix-rb"
|
23
34
|
spec.license = "MIT"
|
24
35
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
@@ -37,6 +48,8 @@ Gem::Specification.new do |spec|
|
|
37
48
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
38
49
|
spec.require_paths = ["lib", "vendor/cli-ui/lib"]
|
39
50
|
|
51
|
+
spec.requirements << "git, v2.0+"
|
52
|
+
|
40
53
|
spec.add_runtime_dependency "rainbow", "~> 3.0"
|
41
54
|
spec.add_runtime_dependency "rouge", "~> 3.20"
|
42
55
|
spec.add_runtime_dependency "rubocop", "~> 0.80"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rfix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7.pre.68
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Linus Oleander
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rainbow
|
@@ -52,7 +52,17 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.80'
|
55
|
-
description:
|
55
|
+
description: |2
|
56
|
+
RuboCop CLI that only complains about your latest changes
|
57
|
+
Uses 'git diff' to determine what changes were made then runs RuboCop against them
|
58
|
+
|
59
|
+
$ rfix branch <branch> -- Fix changes made between HEAD and <branch>
|
60
|
+
$ rfix origin -- Fix changes made between HEAD and origin branch
|
61
|
+
$ rfix local -- Fix changes not yet pushed to upstream branch
|
62
|
+
$ rfix info -- Display runtime dependencies and their versions
|
63
|
+
$ rfix all -- Fix all files in this repository (not recommended)
|
64
|
+
|
65
|
+
Optional args: --dry --help --list-files --limit-files --config --untracked
|
56
66
|
email:
|
57
67
|
- linus@oleander.nu
|
58
68
|
executables:
|
@@ -89,7 +99,8 @@ files:
|
|
89
99
|
- exe/rfix
|
90
100
|
- lib/rfix.rb
|
91
101
|
- lib/rfix/cmd.rb
|
92
|
-
- lib/rfix/extensions.rb
|
102
|
+
- lib/rfix/extensions/extensions.rb
|
103
|
+
- lib/rfix/extensions/offense.rb
|
93
104
|
- lib/rfix/formatter.rb
|
94
105
|
- lib/rfix/git_file.rb
|
95
106
|
- lib/rfix/git_helper.rb
|
@@ -98,6 +109,7 @@ files:
|
|
98
109
|
- lib/rfix/tracked_file.rb
|
99
110
|
- lib/rfix/untracked_file.rb
|
100
111
|
- lib/rfix/version.rb
|
112
|
+
- resources/ps.png
|
101
113
|
- rfix.gemspec
|
102
114
|
- vendor/cli-ui/lib/cli/ui.rb
|
103
115
|
- vendor/cli-ui/lib/cli/ui/ansi.rb
|
@@ -129,7 +141,7 @@ licenses:
|
|
129
141
|
- MIT
|
130
142
|
metadata:
|
131
143
|
homepage_uri: https://github.com/oleander/rfix-rb
|
132
|
-
post_install_message:
|
144
|
+
post_install_message:
|
133
145
|
rdoc_options: []
|
134
146
|
require_paths:
|
135
147
|
- lib
|
@@ -141,12 +153,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
141
153
|
version: 2.5.0
|
142
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
155
|
requirements:
|
144
|
-
- - "
|
156
|
+
- - ">"
|
145
157
|
- !ruby/object:Gem::Version
|
146
|
-
version:
|
147
|
-
requirements:
|
148
|
-
|
149
|
-
|
158
|
+
version: 1.3.1
|
159
|
+
requirements:
|
160
|
+
- git, v2.0+
|
161
|
+
rubygems_version: 3.0.3
|
162
|
+
signing_key:
|
150
163
|
specification_version: 4
|
151
164
|
summary: RuboCop CLI that only complains about your latest changes
|
152
165
|
test_files: []
|
data/lib/rfix/extensions.rb
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rubocop"
|
4
|
-
require "rainbow"
|
5
|
-
|
6
|
-
module Rfix::Ext
|
7
|
-
module CommentConfig
|
8
|
-
# Called by RuboCop on every line to see
|
9
|
-
# if its suppose to run against it or not
|
10
|
-
def cop_enabled_at_line?(_cop, line)
|
11
|
-
Rfix.enabled?(processed_source.file_path, line) && super
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
module Runner
|
16
|
-
# Called _after_ @source has been 'auto fixed' by Rubocop
|
17
|
-
def check_for_infinite_loop(source, offences)
|
18
|
-
Rfix.refresh!(source); super # TODO: Before or after?
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
module Options
|
23
|
-
# Appends custom --args to RuboCop CLI
|
24
|
-
def define_options
|
25
|
-
super.tap do |options|
|
26
|
-
@ons.each do |args, block|
|
27
|
-
option(options, *args, &block)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# Helper method used by rfix to append cli --args to Rubocop
|
33
|
-
def on(*args, &block)
|
34
|
-
@ons ||= []
|
35
|
-
@ons += [[args, block]]
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
module Offense
|
40
|
-
def where
|
41
|
-
line.to_s + ":" + real_column.to_s
|
42
|
-
end
|
43
|
-
|
44
|
-
def info
|
45
|
-
message.split(": ", 2).last.delete("\n")
|
46
|
-
end
|
47
|
-
|
48
|
-
def msg
|
49
|
-
CLI::UI.resolve_text("{{italic:#{info}}}", truncate_to: CLI::UI::Terminal.width - 10)
|
50
|
-
end
|
51
|
-
|
52
|
-
def code
|
53
|
-
message.split(": ", 2).first
|
54
|
-
end
|
55
|
-
|
56
|
-
def star
|
57
|
-
Rainbow("⭑")
|
58
|
-
end
|
59
|
-
|
60
|
-
def cross
|
61
|
-
Rainbow("✗")
|
62
|
-
end
|
63
|
-
|
64
|
-
def check
|
65
|
-
Rainbow("✓")
|
66
|
-
end
|
67
|
-
|
68
|
-
def level
|
69
|
-
colors = {
|
70
|
-
refactor: star.lightcyan,
|
71
|
-
convention: star.lightblue,
|
72
|
-
warning: star.lightyellow,
|
73
|
-
error: cross.indianred,
|
74
|
-
fatal: cross.lightsalmon
|
75
|
-
}
|
76
|
-
|
77
|
-
colors[severity.name]
|
78
|
-
end
|
79
|
-
|
80
|
-
def icon
|
81
|
-
return check.green if corrected?
|
82
|
-
return check.lightgreen if correctable?
|
83
|
-
|
84
|
-
cross.indianred
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
RuboCop::Options.prepend(Rfix::Ext::Options)
|
90
|
-
RuboCop::Runner.prepend(Rfix::Ext::Runner)
|
91
|
-
RuboCop::CommentConfig.prepend(Rfix::Ext::CommentConfig)
|
92
|
-
RuboCop::Cop::Offense.prepend(Rfix::Ext::Offense)
|