Update docs and manpages to include --fix option
This commit is contained in:
parent
0b3d9031e2
commit
1f5cf4fd40
@ -5,9 +5,9 @@
|
|||||||
#: If no <formulae> are provided, all of them are checked.
|
#: If no <formulae> are provided, all of them are checked.
|
||||||
#:
|
#:
|
||||||
#: If `--strict` is passed, additional checks are run, including RuboCop
|
#: If `--strict` is passed, additional checks are run, including RuboCop
|
||||||
#: style checks and custom cop checks.
|
#: style checks.
|
||||||
#:
|
#:
|
||||||
#: If `--fix` is passed, style violations and custom cop violations will be
|
#: If `--fix` is passed, style violations will be
|
||||||
#: automatically fixed using RuboCop's `--auto-correct` feature.
|
#: automatically fixed using RuboCop's `--auto-correct` feature.
|
||||||
#:
|
#:
|
||||||
#: If `--online` is passed, additional slower checks that require a network
|
#: If `--online` is passed, additional slower checks that require a network
|
||||||
|
@ -9,44 +9,28 @@ module RuboCop
|
|||||||
method, _args, body = *node
|
method, _args, body = *node
|
||||||
_keyword, method_name = *method
|
_keyword, method_name = *method
|
||||||
|
|
||||||
return unless method_name.equal?(:bottle) && revision?(body)
|
return unless method_name == :bottle
|
||||||
add_offense(node, :expression)
|
check_revision?(body)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def autocorrect(node)
|
def autocorrect(node)
|
||||||
lambda do |corrector|
|
lambda do |corrector|
|
||||||
# Check for revision
|
correction = node.source.sub("revision", "rebuild")
|
||||||
_method, _args, body = *node
|
corrector.insert_before(node.source_range, correction)
|
||||||
if revision?(body)
|
|
||||||
replace_revision(corrector, node)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def revision?(body)
|
|
||||||
body.children.each do |method_call_node|
|
|
||||||
_receiver, method_name, _args = *method_call_node
|
|
||||||
if method_name == :revision
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
def replace_revision(corrector, node)
|
|
||||||
new_source = ""
|
|
||||||
node.source.each_line do |line|
|
|
||||||
if line =~ /\A\s*revision/
|
|
||||||
line = line.sub("revision", "rebuild")
|
|
||||||
end
|
|
||||||
new_source << line
|
|
||||||
end
|
|
||||||
corrector.insert_before(node.source_range, new_source)
|
|
||||||
corrector.remove(node.source_range)
|
corrector.remove(node.source_range)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_revision?(body)
|
||||||
|
body.children.each do |method_call_node|
|
||||||
|
_receiver, method_name, _args = *method_call_node
|
||||||
|
next unless method_name == :revision
|
||||||
|
add_offense(method_call_node, :expression)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -453,7 +453,7 @@ the <code>prefix</code> and <code>repository</code> are the same directory.</p><
|
|||||||
<h2 id="DEVELOPER-COMMANDS">DEVELOPER COMMANDS</h2>
|
<h2 id="DEVELOPER-COMMANDS">DEVELOPER COMMANDS</h2>
|
||||||
|
|
||||||
<dl>
|
<dl>
|
||||||
<dt><code>audit</code> [<code>--strict</code>] [<code>--online</code>] [<code>--new-formula</code>] [<code>--display-cop-names</code>] [<code>--display-filename</code>] [<var>formulae</var>]</dt><dd><p>Check <var>formulae</var> for Homebrew coding style violations. This should be
|
<dt><code>audit</code> [<code>--strict</code>] [<code>--fix</code>] [<code>--online</code>] [<code>--new-formula</code>] [<code>--display-cop-names</code>] [<code>--display-filename</code>] [<var>formulae</var>]</dt><dd><p>Check <var>formulae</var> for Homebrew coding style violations. This should be
|
||||||
run before submitting a new formula.</p>
|
run before submitting a new formula.</p>
|
||||||
|
|
||||||
<p>If no <var>formulae</var> are provided, all of them are checked.</p>
|
<p>If no <var>formulae</var> are provided, all of them are checked.</p>
|
||||||
@ -461,6 +461,9 @@ run before submitting a new formula.</p>
|
|||||||
<p>If <code>--strict</code> is passed, additional checks are run, including RuboCop
|
<p>If <code>--strict</code> is passed, additional checks are run, including RuboCop
|
||||||
style checks.</p>
|
style checks.</p>
|
||||||
|
|
||||||
|
<p>If <code>--fix</code> is passed, style violations will be
|
||||||
|
automatically fixed using RuboCop's <code>--auto-correct</code> feature.</p>
|
||||||
|
|
||||||
<p>If <code>--online</code> is passed, additional slower checks that require a network
|
<p>If <code>--online</code> is passed, additional slower checks that require a network
|
||||||
connection are run.</p>
|
connection are run.</p>
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
.\" generated with Ronn/v0.7.3
|
.\" generated with Ronn/v0.7.3
|
||||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||||
.
|
.
|
||||||
.TH "BREW\-CASK" "1" "January 2017" "Homebrew" "brew-cask"
|
.TH "BREW\-CASK" "1" "February 2017" "Homebrew" "brew-cask"
|
||||||
.
|
.
|
||||||
.SH "NAME"
|
.SH "NAME"
|
||||||
\fBbrew\-cask\fR \- a friendly binary installer for macOS
|
\fBbrew\-cask\fR \- a friendly binary installer for macOS
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
.\" generated with Ronn/v0.7.3
|
.\" generated with Ronn/v0.7.3
|
||||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||||
.
|
.
|
||||||
.TH "BREW" "1" "January 2017" "Homebrew" "brew"
|
.TH "BREW" "1" "February 2017" "Homebrew" "brew"
|
||||||
.
|
.
|
||||||
.SH "NAME"
|
.SH "NAME"
|
||||||
\fBbrew\fR \- The missing package manager for macOS
|
\fBbrew\fR \- The missing package manager for macOS
|
||||||
@ -625,7 +625,7 @@ Print the version number of Homebrew to standard output and exit\.
|
|||||||
.SH "DEVELOPER COMMANDS"
|
.SH "DEVELOPER COMMANDS"
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fBaudit\fR [\fB\-\-strict\fR] [\fB\-\-online\fR] [\fB\-\-new\-formula\fR] [\fB\-\-display\-cop\-names\fR] [\fB\-\-display\-filename\fR] [\fIformulae\fR]
|
\fBaudit\fR [\fB\-\-strict\fR] [\fB\-\-fix\fR] [\fB\-\-online\fR] [\fB\-\-new\-formula\fR] [\fB\-\-display\-cop\-names\fR] [\fB\-\-display\-filename\fR] [\fIformulae\fR]
|
||||||
Check \fIformulae\fR for Homebrew coding style violations\. This should be run before submitting a new formula\.
|
Check \fIformulae\fR for Homebrew coding style violations\. This should be run before submitting a new formula\.
|
||||||
.
|
.
|
||||||
.IP
|
.IP
|
||||||
@ -635,6 +635,9 @@ If no \fIformulae\fR are provided, all of them are checked\.
|
|||||||
If \fB\-\-strict\fR is passed, additional checks are run, including RuboCop style checks\.
|
If \fB\-\-strict\fR is passed, additional checks are run, including RuboCop style checks\.
|
||||||
.
|
.
|
||||||
.IP
|
.IP
|
||||||
|
If \fB\-\-fix\fR is passed, style violations will be automatically fixed using RuboCop\'s \fB\-\-auto\-correct\fR feature\.
|
||||||
|
.
|
||||||
|
.IP
|
||||||
If \fB\-\-online\fR is passed, additional slower checks that require a network connection are run\.
|
If \fB\-\-online\fR is passed, additional slower checks that require a network connection are run\.
|
||||||
.
|
.
|
||||||
.IP
|
.IP
|
||||||
|
Loading…
x
Reference in New Issue
Block a user