rfix 1.0.7 → 1.0.8.pre.108

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,2 @@
1
- eval_gemfile("../Gemfile")
1
+ eval_gemfile(File.join(__dir__, "../Gemfile.base"))
2
2
  gem "rubocop", "0.85.0"
@@ -1,2 +1,2 @@
1
- eval_gemfile("../Gemfile")
1
+ eval_gemfile(File.join(__dir__, "../Gemfile.base"))
2
2
  gem "rubocop", "0.85.1"
@@ -1,42 +1,22 @@
1
- GIT
2
- remote: https://github.com/Shopify/cli-ui.git
3
- revision: ef976df676f43a80b47249ac2390d5f12b2293d1
4
- ref: ef976df676f4
5
- specs:
6
- cli-ui (1.3.0)
7
-
8
- GIT
9
- remote: https://github.com/oleander/git-fame-rb.git
10
- revision: a9b9c25bbab197feaee00f9a5c970998e76f636c
11
- ref: a9b9c25bbab1
12
- specs:
13
- git_fame (2.5.3)
14
- hirb (~> 0.7.3)
15
- memoist (~> 0.14.0)
16
- method_profiler (~> 2.0.1)
17
- progressbar (~> 0.21.0)
18
- scrub_rb (~> 1.0.1)
19
- trollop (~> 2.1.2)
20
-
21
1
  PATH
22
- remote: ..
2
+ remote: .
23
3
  specs:
24
- rfix (0.2.0)
4
+ rfix (1.0.8)
25
5
  rainbow (~> 3.0)
26
6
  rouge (~> 3.20)
27
- rubocop (~> 0.80)
7
+ rubocop (>= 0.80)
28
8
 
29
9
  GEM
30
10
  remote: https://rubygems.org/
31
11
  specs:
32
- activesupport (6.0.3.1)
12
+ activesupport (6.0.3.2)
33
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
34
14
  i18n (>= 0.7, < 2)
35
15
  minitest (~> 5.1)
36
16
  tzinfo (~> 1.1)
37
17
  zeitwerk (~> 2.2, >= 2.2.2)
38
- aruba (1.0.1)
39
- childprocess (~> 3.0)
18
+ aruba (1.0.2)
19
+ childprocess (>= 2.0, < 5.0)
40
20
  contracts (~> 0.16.0)
41
21
  cucumber (>= 2.4, < 5.0)
42
22
  ffi (~> 1.9)
@@ -44,7 +24,7 @@ GEM
44
24
  thor (~> 1.0)
45
25
  ast (2.4.1)
46
26
  builder (3.2.4)
47
- childprocess (3.0.0)
27
+ childprocess (4.0.0)
48
28
  coderay (1.1.3)
49
29
  concurrent-ruby (1.1.6)
50
30
  contracts (0.16.0)
@@ -78,6 +58,7 @@ GEM
78
58
  diff-lcs (1.3)
79
59
  ffi (1.13.1)
80
60
  formatador (0.2.5)
61
+ gem-release (2.1.1)
81
62
  guard (2.16.2)
82
63
  formatador (>= 0.2.4)
83
64
  listen (>= 2.7, < 4.0)
@@ -92,16 +73,12 @@ GEM
92
73
  guard (~> 2.1)
93
74
  guard-compat (~> 1.1)
94
75
  rspec (>= 2.99.0, < 4.0)
95
- hirb (0.7.3)
96
76
  i18n (1.8.3)
97
77
  concurrent-ruby (~> 1.0)
98
78
  listen (3.2.1)
99
79
  rb-fsevent (~> 0.10, >= 0.10.3)
100
80
  rb-inotify (~> 0.9, >= 0.9.10)
101
- lumberjack (1.2.5)
102
- memoist (0.14.0)
103
- method_profiler (2.0.1)
104
- hirb (>= 0.6.0)
81
+ lumberjack (1.2.6)
105
82
  method_source (1.0.0)
106
83
  middleware (0.1.0)
107
84
  minitest (5.14.1)
@@ -110,10 +87,9 @@ GEM
110
87
  notiffany (0.1.3)
111
88
  nenv (~> 0.1)
112
89
  shellany (~> 0.0)
113
- parallel (1.19.1)
114
- parser (2.7.1.3)
115
- ast (~> 2.4.0)
116
- progressbar (0.21.0)
90
+ parallel (1.19.2)
91
+ parser (2.7.1.4)
92
+ ast (~> 2.4.1)
117
93
  protobuf-cucumber (3.10.8)
118
94
  activesupport (>= 3.2)
119
95
  middleware
@@ -155,13 +131,11 @@ GEM
155
131
  rubocop-ast (0.0.3)
156
132
  parser (>= 2.7.0.1)
157
133
  ruby-progressbar (1.10.1)
158
- scrub_rb (1.0.1)
159
134
  shellany (0.0.1)
160
135
  sys-uname (1.2.1)
161
136
  ffi (>= 1.0.0)
162
137
  thor (1.0.1)
163
138
  thread_safe (0.3.6)
164
- trollop (2.1.3)
165
139
  tzinfo (1.2.7)
166
140
  thread_safe (~> 0.1)
167
141
  unicode-display_width (1.7.0)
@@ -171,19 +145,14 @@ PLATFORMS
171
145
  ruby
172
146
 
173
147
  DEPENDENCIES
174
- aruba
175
- cli-ui!
176
- git_fame!
148
+ aruba (~> 1.0)
149
+ gem-release
177
150
  guard
178
151
  guard-rspec
179
- pry
180
- rake (~> 12.0)
152
+ rake (~> 12.3)
181
153
  rfix!
182
154
  rspec (~> 3.0)
183
155
  rubocop (= 0.85.1)
184
156
 
185
- RUBY VERSION
186
- ruby 2.5.0p0
187
-
188
157
  BUNDLED WITH
189
158
  2.1.4
@@ -1,42 +1,22 @@
1
- GIT
2
- remote: https://github.com/Shopify/cli-ui.git
3
- revision: ef976df676f43a80b47249ac2390d5f12b2293d1
4
- ref: ef976df676f4
5
- specs:
6
- cli-ui (1.3.0)
7
-
8
- GIT
9
- remote: https://github.com/oleander/git-fame-rb.git
10
- revision: a9b9c25bbab197feaee00f9a5c970998e76f636c
11
- ref: a9b9c25bbab1
12
- specs:
13
- git_fame (2.5.3)
14
- hirb (~> 0.7.3)
15
- memoist (~> 0.14.0)
16
- method_profiler (~> 2.0.1)
17
- progressbar (~> 0.21.0)
18
- scrub_rb (~> 1.0.1)
19
- trollop (~> 2.1.2)
20
-
21
1
  PATH
22
- remote: ..
2
+ remote: .
23
3
  specs:
24
- rfix (0.2.0)
4
+ rfix (1.0.8)
25
5
  rainbow (~> 3.0)
26
6
  rouge (~> 3.20)
27
- rubocop (~> 0.80)
7
+ rubocop (>= 0.80)
28
8
 
29
9
  GEM
30
10
  remote: https://rubygems.org/
31
11
  specs:
32
- activesupport (6.0.3.1)
12
+ activesupport (6.0.3.2)
33
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
34
14
  i18n (>= 0.7, < 2)
35
15
  minitest (~> 5.1)
36
16
  tzinfo (~> 1.1)
37
17
  zeitwerk (~> 2.2, >= 2.2.2)
38
- aruba (1.0.1)
39
- childprocess (~> 3.0)
18
+ aruba (1.0.2)
19
+ childprocess (>= 2.0, < 5.0)
40
20
  contracts (~> 0.16.0)
41
21
  cucumber (>= 2.4, < 5.0)
42
22
  ffi (~> 1.9)
@@ -44,7 +24,7 @@ GEM
44
24
  thor (~> 1.0)
45
25
  ast (2.4.1)
46
26
  builder (3.2.4)
47
- childprocess (3.0.0)
27
+ childprocess (4.0.0)
48
28
  coderay (1.1.3)
49
29
  concurrent-ruby (1.1.6)
50
30
  contracts (0.16.0)
@@ -78,6 +58,7 @@ GEM
78
58
  diff-lcs (1.3)
79
59
  ffi (1.13.1)
80
60
  formatador (0.2.5)
61
+ gem-release (2.1.1)
81
62
  guard (2.16.2)
82
63
  formatador (>= 0.2.4)
83
64
  listen (>= 2.7, < 4.0)
@@ -92,16 +73,12 @@ GEM
92
73
  guard (~> 2.1)
93
74
  guard-compat (~> 1.1)
94
75
  rspec (>= 2.99.0, < 4.0)
95
- hirb (0.7.3)
96
76
  i18n (1.8.3)
97
77
  concurrent-ruby (~> 1.0)
98
78
  listen (3.2.1)
99
79
  rb-fsevent (~> 0.10, >= 0.10.3)
100
80
  rb-inotify (~> 0.9, >= 0.9.10)
101
- lumberjack (1.2.5)
102
- memoist (0.14.0)
103
- method_profiler (2.0.1)
104
- hirb (>= 0.6.0)
81
+ lumberjack (1.2.6)
105
82
  method_source (1.0.0)
106
83
  middleware (0.1.0)
107
84
  minitest (5.14.1)
@@ -110,10 +87,9 @@ GEM
110
87
  notiffany (0.1.3)
111
88
  nenv (~> 0.1)
112
89
  shellany (~> 0.0)
113
- parallel (1.19.1)
114
- parser (2.7.1.3)
115
- ast (~> 2.4.0)
116
- progressbar (0.21.0)
90
+ parallel (1.19.2)
91
+ parser (2.7.1.4)
92
+ ast (~> 2.4.1)
117
93
  protobuf-cucumber (3.10.8)
118
94
  activesupport (>= 3.2)
119
95
  middleware
@@ -155,13 +131,11 @@ GEM
155
131
  rubocop-ast (0.0.3)
156
132
  parser (>= 2.7.0.1)
157
133
  ruby-progressbar (1.10.1)
158
- scrub_rb (1.0.1)
159
134
  shellany (0.0.1)
160
135
  sys-uname (1.2.1)
161
136
  ffi (>= 1.0.0)
162
137
  thor (1.0.1)
163
138
  thread_safe (0.3.6)
164
- trollop (2.1.3)
165
139
  tzinfo (1.2.7)
166
140
  thread_safe (~> 0.1)
167
141
  unicode-display_width (1.7.0)
@@ -171,19 +145,14 @@ PLATFORMS
171
145
  ruby
172
146
 
173
147
  DEPENDENCIES
174
- aruba
175
- cli-ui!
176
- git_fame!
148
+ aruba (~> 1.0)
149
+ gem-release
177
150
  guard
178
151
  guard-rspec
179
- pry
180
- rake (~> 12.0)
152
+ rake (~> 12.3)
181
153
  rfix!
182
154
  rspec (~> 3.0)
183
155
  rubocop (= 0.85.0)
184
156
 
185
- RUBY VERSION
186
- ruby 2.5.0p0
187
-
188
157
  BUNDLED WITH
189
158
  2.1.4
data/exe/rfix CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+
2
3
  # frozen_string_literal: true
3
4
 
4
5
  require "rfix"
@@ -9,55 +10,37 @@ require "cli/ui"
9
10
  should_list_files = false
10
11
  limit_files = false
11
12
  options = RuboCop::Options.new
12
- config = RuboCop::ConfigStore.new
13
+
13
14
  display_help = ARGV.include?("--help")
14
15
  is_dry = ARGV.include?("--dry")
15
16
  config_path = false
17
+ clear_cache = false
16
18
 
17
19
  extend Rfix::Log
18
20
  Rfix.init!
19
21
  CLI::UI::StdoutRouter.enable
20
22
 
21
23
  say "Using RuboCop {{yellow:#{RuboCop::Version.version}}}"
24
+ say_debug "Current directory {{italic:#{Dir.pwd}}}"
25
+ say_debug "[Ruby] {{italic:#{RbConfig.ruby}}}"
22
26
 
23
- base_config = {
24
- color: true,
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}"
27
+ options.on("--untracked", "Include untracked files") do
28
+ Rfix.load_untracked!
46
29
  end
47
30
 
48
31
  options.on("--dry", "No auto correct") do
49
32
  say "Will run rfix in {{red:read-only}} mode"
50
- base_config.merge!({ auto_correct: false })
51
- end
52
-
53
- options.on("--untracked", "Include untracked files") do
54
- Rfix.load_untracked!
33
+ Rfix.no_auto_correct!
55
34
  end
56
35
 
57
36
  options.on("--list-files", "List files found by git") do
58
37
  should_list_files = true
59
38
  end
60
39
 
40
+ options.on("--clear-cache", "Clear RuboCop cache") do
41
+ clear_cache = true
42
+ end
43
+
61
44
  options.on("--limit-files NUM", Integer, "Limit number of files") do |limit|
62
45
  limit_files = limit
63
46
  end
@@ -73,6 +56,9 @@ when "info"
73
56
  say "Using Git {{yellow:#{Rfix.git_version}}}"
74
57
  say "Using Ruby {{yellow:#{Rfix.ruby_version}}}"
75
58
  exit 0
59
+ when "lint"
60
+ Rfix.lint_mode!
61
+ reference = Rfix.ref_since_push
76
62
  when "local"
77
63
  reference = Rfix.ref_since_push
78
64
  when "origin"
@@ -96,14 +82,7 @@ when "branch"
96
82
  else
97
83
  unless display_help
98
84
  say_error "Valid rfix commands are:"
99
- say_error_sub "\n"
100
- say_error_sub "\t{{bold:rfix branch <branch>}} -- {{italic:Fix changes made between HEAD and <branch>}}"
101
- say_error_sub "\t{{bold:rfix origin}} -- {{italic:Fix changes made between HEAD and origin branch}}"
102
- say_error_sub "\t{{bold:rfix local}} -- {{italic:Fix changes not yet pushed to upstream branch}}"
103
- say_error_sub "\t{{bold:rfix info}} -- {{italic:Display runtime dependencies and their versions}}"
104
- say_error_sub "\t{{bold:rfix all}} -- {{italic:Fix all files in this repository}} {{warning:(not recommended)}}"
105
- say_error_sub "\n"
106
- say_error_sub "\t{{italic:Optional args: --dry --help --list-files --limit-files --config --untracked}}"
85
+ say_error Rfix.help
107
86
  exit 1
108
87
  end
109
88
 
@@ -117,15 +96,22 @@ rescue OptionParser::MissingArgument => e
117
96
  end
118
97
 
119
98
  if path = config_path
120
- load_config do
99
+ Rfix.load_config do |config|
100
+ say_debug "[Config:Option] Load from #{path}"
121
101
  config.options_config = path
122
102
  end
123
103
  else
124
- load_config do
104
+ Rfix.load_config do |config|
105
+ say_debug "[Config:PWD] Load from #{Dir.pwd}"
125
106
  config.for(Dir.pwd)
126
107
  end
127
108
  end
128
109
 
110
+ if clear_cache
111
+ say "Clearing cache"
112
+ Rfix.clear_cache!
113
+ end
114
+
129
115
  if ref = reference
130
116
  say "Compare against {{yellow:#{ref}}}"
131
117
 
@@ -148,9 +134,11 @@ if should_list_files
148
134
  end
149
135
  end
150
136
 
137
+ say_debug "[Config:Dump] #{Rfix.store}"
138
+
151
139
  env = RuboCop::CLI::Environment.new(
152
- base_config.merge(options),
153
- config,
140
+ Rfix.config.merge(options),
141
+ Rfix.store,
154
142
  paths
155
143
  )
156
144
 
@@ -4,10 +4,23 @@
4
4
  # https://gist.github.com/skanev/9d4bec97d5a6825eaaf6
5
5
 
6
6
  require "rfix/version"
7
- require "rfix/log"
8
- require "rfix/extensions"
7
+ require "cli/ui"
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
@@ -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
 
@@ -23,6 +23,10 @@ module Rfix::Cmd
23
23
  out.lines.map(&:chomp)
24
24
  end
25
25
 
26
+ def cmd_succeeded?(*cmd)
27
+ Open3.capture2e(*cmd).last.success?
28
+ end
29
+
26
30
  def params
27
31
  [
28
32
  "--word-diff-regex=[^[:space:]]",