rfix 1.0.5.pre.58 → 1.0.7.pre.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +9 -2
- data/Gemfile.lock +2 -2
- data/README.md +1 -1
- data/lib/rfix.rb +14 -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/version.rb +1 -1
- data/rfix.gemspec +14 -1
- metadata +14 -5
- 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: ab51832758a2766094d61f5568dccf230cecd9ffe2527c0b90c574ac75a8243e
|
4
|
+
data.tar.gz: 0466e6aee2a5a63fdfff88038ad159c6e08b964f32576618a24574f3ded57429
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c2d60ae33674c5aa8ece23e46b69a82dc51b554cc3b11d9d4b4c597e6eab54a855851414d8f7f3dcd825fb18f4e107f8dcd60e12504bb4e8a3428e9d70c2bee
|
7
|
+
data.tar.gz: 125bd91a63181e343f0bc888f9e418ccaf125059aebcc88062e2f8f676feaf2621fa310bb98890542690d6c9cb65793764ce250a6638f760d0a0ad8386fcdb88
|
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
@@ -21,7 +21,7 @@ GIT
|
|
21
21
|
PATH
|
22
22
|
remote: .
|
23
23
|
specs:
|
24
|
-
rfix (1.0.
|
24
|
+
rfix (1.0.7)
|
25
25
|
rainbow (~> 3.0)
|
26
26
|
rouge (~> 3.20)
|
27
27
|
rubocop (~> 0.80)
|
@@ -110,7 +110,7 @@ GEM
|
|
110
110
|
notiffany (0.1.3)
|
111
111
|
nenv (~> 0.1)
|
112
112
|
shellany (~> 0.0)
|
113
|
-
parallel (1.19.
|
113
|
+
parallel (1.19.2)
|
114
114
|
parser (2.7.1.3)
|
115
115
|
ast (~> 2.4.0)
|
116
116
|
progressbar (0.21.0)
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
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
3
|
RuboCop CLI that only complains about your latest changes
|
4
4
|
|
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
|
@@ -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 # TODO: Before or after?
|
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/version.rb
CHANGED
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.65
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Linus Oleander
|
8
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,14 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.80'
|
55
|
-
description: "
|
55
|
+
description: "RuboCop CLI that only complains about your latest changes\nUses 'git
|
56
|
+
diff' to determine what changes were made then runs RuboCop against them\n\n\t$
|
57
|
+
rfix branch <branch> -- Fix changes made between HEAD and <branch>\n\t$ rfix origin
|
58
|
+
\ -- Fix changes made between HEAD and origin branch\n\t$ rfix local --
|
59
|
+
Fix changes not yet pushed to upstream branch\n\t$ rfix info -- Display
|
60
|
+
runtime dependencies and their versions\n\t$ rfix all -- Fix all files
|
61
|
+
in this repository (not recommended)\n\nOptional args: --dry --help --list-files
|
62
|
+
--limit-files --config --untracked\n"
|
56
63
|
email:
|
57
64
|
- linus@oleander.nu
|
58
65
|
executables:
|
@@ -89,7 +96,8 @@ files:
|
|
89
96
|
- exe/rfix
|
90
97
|
- lib/rfix.rb
|
91
98
|
- lib/rfix/cmd.rb
|
92
|
-
- lib/rfix/extensions.rb
|
99
|
+
- lib/rfix/extensions/extensions.rb
|
100
|
+
- lib/rfix/extensions/offense.rb
|
93
101
|
- lib/rfix/formatter.rb
|
94
102
|
- lib/rfix/git_file.rb
|
95
103
|
- lib/rfix/git_helper.rb
|
@@ -144,7 +152,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
152
|
- - ">"
|
145
153
|
- !ruby/object:Gem::Version
|
146
154
|
version: 1.3.1
|
147
|
-
requirements:
|
155
|
+
requirements:
|
156
|
+
- git, v2.0+
|
148
157
|
rubygems_version: 3.0.3
|
149
158
|
signing_key:
|
150
159
|
specification_version: 4
|
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)
|