Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Library/Homebrew/rubocops/lines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,10 @@ def audit_formula(formula_nodes)
methods.each do |method|
next unless method.source.include?("shells:")

shells << method.source.match(/shells: \[(:bash|:zsh|:fish)\]/).captures.first
shell = method.source[/shells: \[(:bash|:zsh|:fish)\]/, 1]
next if shell.nil?

shells << shell
offenses << method
end

Expand Down
18 changes: 18 additions & 0 deletions Library/Homebrew/test/rubocops/lines/generate_completions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,23 @@ def install
end
RUBY
end

it "does not report an offense when shells are generated dynamically" do
expect_no_offenses(<<~RUBY)
class Foo < Formula
name "foo"

def install
generate_completions_from_executable(bin/"foo", "completions")
[:zsh, :bash].each do |shell|
generate_completions_from_executable(
bin/"foo", "completions", shell.to_s, "bar", shells: [shell], base_name: "bar",
shell_parameter_format: :none
)
end
end
end
RUBY
end
end
end
Loading