rfix 1.0.5 → 1.0.7.pre.66

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 868bfaa86ad3d23783d477797cfcf3e3f385aa07e99d58eef7ffc6b7627cee70
4
- data.tar.gz: ad027badc525a3dc9c132a769f887cf6b6dfaae2f67b5fa54860b141701913d1
3
+ metadata.gz: 3ba09b69185ab60b9f686736e5c9e7fb31f304076e34da632c680d086cc2b2ad
4
+ data.tar.gz: 0cec0d7801f62c92660cfada322c883aded3ea5a5a2912fafcc8b25d106847ce
5
5
  SHA512:
6
- metadata.gz: 03bd3ad38f44c7d255d3b7833dd971c1871a694f3817f00f4e09182012e9f4d37462e7006cc71eb7cdc5d45b4bdf04525a23ef1032d1eef7b7263c6d36c8cf98
7
- data.tar.gz: 768876291035c8296f24307f2290b0c08d1a26ad3c1d9299c3f3ad3c67192988c3b841e8e2acb72d2f361a4dddee552cc899bd6483145706faafdf07cdb9a497
6
+ metadata.gz: 774c1bef50501190800a11c878d887071c3a531b32605d05eb1d92e6f7d3b5ba7a757801dfb2d6cf90e11c223766f24a80ec6d1ce4a33a6785e5064893a8096a
7
+ data.tar.gz: 46872dec584d09199205210c3a13f3f278164702407acfe7833f58280307b2f27888a8d705d31901be73cb280689ee7c8c87f74a0f213ec5c2c30c53b0b5bca1
@@ -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 uninstall bundler
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
@@ -27,4 +33,15 @@ install:
27
33
  script:
28
34
  - bundle exec rake spec
29
35
  - bundle exec rake install
30
- - rfix --help
36
+ - rfix info
37
+ jobs:
38
+ include:
39
+ deploy:
40
+ provider: rubygems
41
+ api_key:
42
+ secure: SJ5rZtQxDnY7aeWIb+gZ1OEV2rDHz8jvMBStHtzPDVtpQeUoo6DJB4FN4Vt5i7VaVk1otkAdOgyANzOQDSB0/1mMBUcy902zKrrUISALeIXp2FpsvjijRdKD0hLJaeX00n/MEJpw671NbzCNboEdiMnCrxSgd775qeQibcv72iRGIY07xv/BLUCtLTmqtjQFQAvcYEFpMQsRE6XEnkRSEOigSsYvNKZrygG4AgUaNY4rcOPqP+Yl26BFHw833GBQeuGgD5a310k3xYwpPc+9I+pTVHcpc4qh2m9kPcNuyDE3OjAMqE3XVn9WXeciZnQR6AQ94n6+5CJyTD3NEv5n58i4kyCLB71YfmPJjO+04+EiCUSZjeECkwACNguzOisdV8Z/vDzfNhI5tvNL7lv3jU05F/lw8LXKR30GBte5BquPY4DjjjXKgKoKl0tbo1bBT0u8LItEaFYoGqRmUiXiHFQNaH02pjBFkjUsyyEgnscWTDtoPxEjyP4aLnW+ESxnJxpwMHHiHPmplrPmK+3hYrTYz9saZyIajLIfcxcGcSSWEHXt2gV5i80pHJFQCc1qV/9d3g8s8sy3N9eKzV6SMYspFTtdKe2Pf7m/nwFt235/ibx0Z4Gyb1TZKze7phv9yAzvAaIb28I3Ye6S2S/ALemlKiu1A/XWtNtOxo8xMNE=
43
+ gem: rfix
44
+ on:
45
+ repo: oleander/rfix-rb
46
+ tags: false
47
+ cleanup: 'false'
@@ -21,7 +21,7 @@ GIT
21
21
  PATH
22
22
  remote: .
23
23
  specs:
24
- rfix (1.0.5)
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.1)
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 [![Build Status](https://travis-ci.org/oleander/rfix-rb.svg?branch=master)](https://travis-ci.org/oleander/rfix-rb)
1
+ # Rfix [![Build Status](https://travis-ci.org/oleander/rfix-rb.svg?branch=master)](https://travis-ci.org/oleander/rfix-rb) [![Gem](https://img.shields.io/gem/dt/rfix)](https://rubygems.org/gems/rfix)
2
2
 
3
3
  RuboCop CLI that only complains about your latest changes
4
4
 
@@ -18,6 +18,17 @@ $ rfix [--dry] [--help]
18
18
  - `bundle exec rake local`
19
19
  - `bundle exec rake spec`
20
20
 
21
+ ## Overcommit
22
+
23
+ ``` yaml
24
+ PreCommit:
25
+ RFix:
26
+ enabled: true
27
+ command: ["rfix", "local", "--untracked", "--dry"]
28
+ description: "Lint changes since last push using RuboCop"
29
+ parallelize: true
30
+ ```
31
+
21
32
  ## Contributing
22
33
 
23
34
  Bug reports and pull requests are welcome on GitHub at https://github.com/oleander/rfix.
@@ -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
@@ -16,7 +16,7 @@ module Rfix::Cmd
16
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
+
20
20
  exit status.exitstatus
21
21
  end
22
22
 
@@ -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
@@ -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("#{clickable_path} » {{italic:#{clickable_code}}}", color: :reset)
40
+ CLI::UI::Frame.close("#{offense.clickable_severity} » #{offense.clickable_path}", color: :reset)
64
41
  end
65
42
  end
66
43
 
@@ -9,8 +9,8 @@ module Rfix::GitHelper
9
9
  include Rfix::Log
10
10
  include Rfix::Cmd
11
11
 
12
- def git(*args)
13
- cmd("git", *args)
12
+ def git(*args, &block)
13
+ cmd("git", *args, &block)
14
14
  end
15
15
 
16
16
  def params
@@ -19,7 +19,9 @@ module Rfix::GitHelper
19
19
  "--no-renames",
20
20
  "--no-merges",
21
21
  "--first-parent",
22
- "--diff-filter=AM",
22
+ "--find-renames",
23
+ "--find-copies",
24
+ "--diff-filter=AMCR",
23
25
  "-U0",
24
26
  "--no-color",
25
27
  "-p"
@@ -88,7 +88,9 @@ module Rfix
88
88
 
89
89
  # Ref since last push
90
90
  def ref_since_push
91
- git("rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}").first
91
+ git("rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}") do
92
+ [ref_since_origin]
93
+ end.first
92
94
  end
93
95
 
94
96
  # Original branch, usually master
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rfix
4
- VERSION = "1.0.5"
4
+ VERSION = "1.0.7"
5
5
  end
@@ -5,12 +5,31 @@ require_relative "lib/rfix/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "rfix"
8
- spec.version = Rfix::VERSION
8
+
9
+ if ENV["TRAVIS"]
10
+ spec.version = "#{Rfix::VERSION}-#{ENV.fetch('TRAVIS_BUILD_NUMBER')}"
11
+ else
12
+ # rubocop:disable Gemspec/DuplicatedAssignment
13
+ spec.version = Rfix::VERSION
14
+ # rubocop:enable Gemspec/DuplicatedAssignment
15
+ end
16
+
9
17
  spec.authors = ["Linus Oleander"]
10
18
  spec.email = ["linus@oleander.nu"]
11
19
 
12
20
  spec.summary = "RuboCop CLI that only complains about your latest changes"
13
- spec.description = "$ rfix local|branch|origin|info|all [--dry] [--help]"
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
14
33
  spec.homepage = "https://github.com/oleander/rfix-rb"
15
34
  spec.license = "MIT"
16
35
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
@@ -29,6 +48,8 @@ Gem::Specification.new do |spec|
29
48
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
49
  spec.require_paths = ["lib", "vendor/cli-ui/lib"]
31
50
 
51
+ spec.requirements << "git, v2.0+"
52
+
32
53
  spec.add_runtime_dependency "rainbow", "~> 3.0"
33
54
  spec.add_runtime_dependency "rouge", "~> 3.20"
34
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.5
4
+ version: 1.0.7.pre.66
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-17 00:00:00.000000000 Z
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: "$ rfix local|branch|origin|info|all [--dry] [--help]"
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
@@ -129,7 +137,7 @@ licenses:
129
137
  - MIT
130
138
  metadata:
131
139
  homepage_uri: https://github.com/oleander/rfix-rb
132
- post_install_message:
140
+ post_install_message:
133
141
  rdoc_options: []
134
142
  require_paths:
135
143
  - lib
@@ -141,12 +149,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
141
149
  version: 2.5.0
142
150
  required_rubygems_version: !ruby/object:Gem::Requirement
143
151
  requirements:
144
- - - ">="
152
+ - - ">"
145
153
  - !ruby/object:Gem::Version
146
- version: '0'
147
- requirements: []
148
- rubygems_version: 3.1.4
149
- signing_key:
154
+ version: 1.3.1
155
+ requirements:
156
+ - git, v2.0+
157
+ rubygems_version: 3.0.3
158
+ signing_key:
150
159
  specification_version: 4
151
160
  summary: RuboCop CLI that only complains about your latest changes
152
161
  test_files: []
@@ -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)