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
9ad342eb
Commit
9ad342eb
authored
4 years ago
by
Rylan Polster
Browse files
Options
Downloads
Patches
Plain Diff
style: don't concatenate in string interpolation
parent
63b81d84
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Library/Homebrew/dev-cmd/audit.rb
+0
-6
0 additions, 6 deletions
Library/Homebrew/dev-cmd/audit.rb
Library/Homebrew/rubocops/text.rb
+9
-0
9 additions, 0 deletions
Library/Homebrew/rubocops/text.rb
Library/Homebrew/test/rubocops/text_spec.rb
+11
-0
11 additions, 0 deletions
Library/Homebrew/test/rubocops/text_spec.rb
with
20 additions
and
6 deletions
Library/Homebrew/dev-cmd/audit.rb
+
0
−
6
View file @
9ad342eb
...
...
@@ -843,12 +843,6 @@ module Homebrew
problem
"Don't need to interpolate
\"
#{
Regexp
.
last_match
(
2
)
}
\"
with
#{
Regexp
.
last_match
(
1
)
}
"
end
# Check for string concatenation; prefer interpolation
if
line
=~
/(#\{\w+\s*\+\s*['"][^}]+\})/
# TODO: check could be in RuboCop
problem
"Try not to concatenate paths in string interpolation:
\n
#{
Regexp
.
last_match
(
1
)
}
"
end
# Prefer formula path shortcuts in Pathname+
if
line
=~
%r{
\(\s
*(prefix
\s
*
\+\s
*(['"])(bin|include|libexec|lib|sbin|share|Frameworks)[/'"])}
# TODO: check could be in RuboCop
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/rubocops/text.rb
+
9
−
0
View file @
9ad342eb
...
...
@@ -69,6 +69,15 @@ module RuboCop
offending_node
(
m
)
problem
"Use separate `make` calls"
end
body_node
.
each_descendant
(
:dstr
)
do
|
dstr_node
|
dstr_node
.
each_descendant
(
:begin
)
do
|
interpolation_node
|
next
unless
interpolation_node
.
source
.
match?
(
/#\{\w+\s*\+\s*['"][^}]+\}/
)
offending_node
(
interpolation_node
)
problem
"Do not concatenate paths in string interpolation"
end
end
end
end
end
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/test/rubocops/text_spec.rb
+
11
−
0
View file @
9ad342eb
...
...
@@ -226,6 +226,17 @@ describe RuboCop::Cop::FormulaAudit::Text do
end
RUBY
end
it
"When concatenating in string interpolation"
do
expect_offense
(
<<~
RUBY
)
class Foo < Formula
def install
ohai "foo
\#
{bar + "baz"}"
^^^^^^^^^^^^^^ Do not concatenate paths in string interpolation
end
end
RUBY
end
end
end
...
...
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