rfix 1.0.7.pre.66 → 1.0.7.pre.67

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/exe/rfix +10 -31
  3. data/lib/rfix/rfix.rb +49 -0
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ba09b69185ab60b9f686736e5c9e7fb31f304076e34da632c680d086cc2b2ad
4
- data.tar.gz: 0cec0d7801f62c92660cfada322c883aded3ea5a5a2912fafcc8b25d106847ce
3
+ metadata.gz: 18adac7bf6bfb125c3cac54933353fb5c52a6a60854f0001afa0c5bdc69ece87
4
+ data.tar.gz: 1f1656bec3253bb8d609fa35fd157d60c45510e2fc787cf44139ae39dda756f7
5
5
  SHA512:
6
- metadata.gz: 774c1bef50501190800a11c878d887071c3a531b32605d05eb1d92e6f7d3b5ba7a757801dfb2d6cf90e11c223766f24a80ec6d1ce4a33a6785e5064893a8096a
7
- data.tar.gz: 46872dec584d09199205210c3a13f3f278164702407acfe7833f58280307b2f27888a8d705d31901be73cb280689ee7c8c87f74a0f213ec5c2c30c53b0b5bca1
6
+ metadata.gz: 6dac6c467ca60c677bceb2926e3f78ee86164ecda79b50a010595d40a8a5e924fa2182fbe7d90f64b5158abd36aa5b7860b107b2c2495748abfed15154da50d6
7
+ data.tar.gz: 29c0aca1abaa4ba8b3d13169128f052324061709ca7c03b01296b395d6f00b8dae8e76f231bd59942a350811ed6cb9d5b8a425b37bfd32a8bd01e7b368ed16a1
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
- 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}"
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
- base_config.merge!({ auto_correct: false })
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
- base_config.merge(options),
131
+ Rfix.config.merge(options),
153
132
  config,
154
133
  paths
155
134
  )
@@ -13,6 +13,39 @@ 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
22
+ if lint
23
+ else
24
+ @config[:fail_level] = :warning
25
+ end
26
+ end
27
+ end
28
+
29
+ def no_auto_correct!
30
+ @config[:auto_correct] = false
31
+ end
32
+
33
+ def load_config
34
+ yield
35
+ rescue RuboCop::Error => e
36
+ say_abort "[Config] #{e}"
37
+ rescue TypeError => e
38
+ say_abort "[Config] #{e}"
39
+ end
40
+
41
+ def lint_mode!
42
+ @config[:auto_correct] = false
43
+ if old?
44
+ @config[:fail_level] = :warning
45
+ end
46
+ load_untracked!
47
+ end
48
+
16
49
  def git_version
17
50
  cmd("git --version").last.split(/\s+/, 3).last
18
51
  end
@@ -36,6 +69,16 @@ module Rfix
36
69
  def init!
37
70
  @files ||= {}
38
71
  @global_enable = false
72
+ @config = {
73
+ color: true,
74
+ force_exclusion: true,
75
+ auto_correct: true,
76
+ formatters: ["Rfix::Formatter"]
77
+ }
78
+
79
+ if old?
80
+ @config[:fail_level] = :autocorrect
81
+ end
39
82
  end
40
83
 
41
84
  def files
@@ -100,6 +143,12 @@ module Rfix
100
143
 
101
144
  private
102
145
 
146
+ def old?
147
+ # For version 0.80.x .. 0.83.x:
148
+ # Otherwise it will exit with status code = 1
149
+ (0.80..0.83).include?(RuboCop::Version::STRING.to_f)
150
+ end
151
+
103
152
  def get_file(path, &block)
104
153
  if file = @files[path]
105
154
  block.call(file)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rfix
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7.pre.66
4
+ version: 1.0.7.pre.67
5
5
  platform: ruby
6
6
  authors:
7
7
  - Linus Oleander