rfix 1.0.7.pre.66 → 1.0.7.pre.67
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/rfix +10 -31
- data/lib/rfix/rfix.rb +49 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18adac7bf6bfb125c3cac54933353fb5c52a6a60854f0001afa0c5bdc69ece87
|
4
|
+
data.tar.gz: 1f1656bec3253bb8d609fa35fd157d60c45510e2fc787cf44139ae39dda756f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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/rfix.rb
CHANGED
@@ -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)
|