Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
brew
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
brew
Commits
ca59377a
Commit
ca59377a
authored
6 years ago
by
Jonathan Chang
Browse files
Options
Downloads
Patches
Plain Diff
audit: add autocorrect and tests for test checks
parent
5f981a87
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Library/Homebrew/rubocops/class_cop.rb
+11
-0
11 additions, 0 deletions
Library/Homebrew/rubocops/class_cop.rb
Library/Homebrew/test/rubocops/class_cop_spec.rb
+25
-0
25 additions, 0 deletions
Library/Homebrew/test/rubocops/class_cop_spec.rb
with
36 additions
and
0 deletions
Library/Homebrew/rubocops/class_cop.rb
+
11
−
0
View file @
ca59377a
...
...
@@ -39,6 +39,17 @@ module RuboCop
end
end
def
autocorrect
(
node
)
lambda
do
|
corrector
|
case
node
.
type
when
:str
,
:dstr
corrector
.
replace
(
node
.
source_range
,
node
.
source
.
to_s
.
sub
(
%r{(/usr/local/(s?bin))}
,
'#{\2}'
))
when
:int
corrector
.
remove
(
range_with_surrounding_comma
(
range_with_surrounding_space
(
range:
node
.
source_range
,
side: :left
)))
end
end
end
def_node_search
:test_calls
,
<<~
EOS
(send nil? ${:system :shell_output :pipe_output} $...)
EOS
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/test/rubocops/class_cop_spec.rb
+
25
−
0
View file @
ca59377a
...
...
@@ -76,6 +76,31 @@ describe RuboCop::Cop::FormulaAudit::TestCalls do
end
RUBY
end
it
"supports auto-correcting test calls"
do
source
=
<<~
RUBY
class Foo < Formula
url 'https://example.com/foo-1.0.tgz'
test do
shell_output("/usr/local/sbin/test", 0)
end
end
RUBY
corrected_source
=
<<~
RUBY
class Foo < Formula
url 'https://example.com/foo-1.0.tgz'
test do
shell_output("
\#
{sbin}/test")
end
end
RUBY
new_source
=
autocorrect_source
(
source
)
expect
(
new_source
).
to
eq
(
corrected_source
)
end
end
describe
RuboCop
::
Cop
::
FormulaAuditStrict
::
Test
do
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment