-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add autocorrection for the interpolated bin audit
- I got bored doing them manually. - Also now more people can help with letters of the alphabet using `brew style --only=FormulaAuditStrict/Text --fix homebrew/core`.
- Loading branch information
Showing
2 changed files
with
19 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,6 +115,8 @@ def audit_formula(formula_nodes) | |
module FormulaAuditStrict | ||
# This cop contains stricter checks for various problems in a formula's source code. | ||
class Text < FormulaCop | ||
extend AutoCorrector | ||
|
||
sig { override.params(formula_nodes: FormulaNodes).void } | ||
def audit_formula(formula_nodes) | ||
return if (body_node = formula_nodes.body_node).nil? | ||
|
@@ -140,7 +142,9 @@ def audit_formula(formula_nodes) | |
interpolated_bin_path_starts_with(body_node, "/#{@formula_name}") do |bin_node| | ||
offending_node(bin_node) | ||
cmd = bin_node.source.match(%r{\#{bin}/(\S+)})[1]&.delete_suffix('"') || @formula_name | ||
problem "Use `bin/\"#{cmd}\"` instead of `\"\#{bin}/#{cmd}\"`" | ||
problem "Use `bin/\"#{cmd}\"` instead of `\"\#{bin}/#{cmd}\"`" do |corrector| | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ReenigneArcher
|
||
corrector.replace(bin_node.loc.expression, "bin/\"#{cmd}\"") | ||
end | ||
end | ||
|
||
return if formula_tap != "homebrew-core" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Following this suggestion makes it unable to execute.
I get the following error:
Failed to execute: bin/sunshine
Am I misunderstand what change to make? LizardByte/Sunshine#2953