Merge pull request #16364 from cho-m/pybuild-rubocopy
rubocops/lines: consistency with single non-runtime Python
This commit is contained in:
commit
4d93a50ad6
@ -375,9 +375,17 @@ module RuboCop
|
|||||||
string_content(parameters(dep).first).start_with? "python@"
|
string_content(parameters(dep).first).start_with? "python@"
|
||||||
end
|
end
|
||||||
|
|
||||||
return if python_formula_node.blank?
|
python_version = if python_formula_node.blank?
|
||||||
|
other_python_nodes = find_every_method_call_by_name(body_node, :depends_on).select do |dep|
|
||||||
|
parameters(dep).first.instance_of?(RuboCop::AST::HashNode) &&
|
||||||
|
string_content(parameters(dep).first.keys.first).start_with?("python@")
|
||||||
|
end
|
||||||
|
return if other_python_nodes.size != 1
|
||||||
|
|
||||||
python_version = string_content(parameters(python_formula_node).first).split("@").last
|
string_content(parameters(other_python_nodes.first).first.keys.first).split("@").last
|
||||||
|
else
|
||||||
|
string_content(parameters(python_formula_node).first).split("@").last
|
||||||
|
end
|
||||||
|
|
||||||
find_strings(body_node).each do |str|
|
find_strings(body_node).each do |str|
|
||||||
content = string_content(str)
|
content = string_content(str)
|
||||||
|
|||||||
@ -179,5 +179,45 @@ describe RuboCop::Cop::FormulaAudit::PythonVersions do
|
|||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "reports no offenses for multiple non-runtime Python dependencies" do
|
||||||
|
expect_no_offenses(<<~RUBY)
|
||||||
|
class Foo < Formula
|
||||||
|
depends_on "python@3.9" => :build
|
||||||
|
depends_on "python@3.10" => :test
|
||||||
|
|
||||||
|
def install
|
||||||
|
puts "python3.9"
|
||||||
|
end
|
||||||
|
|
||||||
|
test do
|
||||||
|
puts "python3.10"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
end
|
||||||
|
|
||||||
|
it "reports and corrects Python references that mismatch single non-runtime Python dependency" do
|
||||||
|
expect_offense(<<~RUBY)
|
||||||
|
class Foo < Formula
|
||||||
|
depends_on "python@3.9" => :build
|
||||||
|
|
||||||
|
def install
|
||||||
|
puts "python@3.8"
|
||||||
|
^^^^^^^^^^^^ FormulaAudit/PythonVersions: References to `python@3.8` should match the specified python dependency (`python@3.9`)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
|
||||||
|
expect_correction(<<~RUBY)
|
||||||
|
class Foo < Formula
|
||||||
|
depends_on "python@3.9" => :build
|
||||||
|
|
||||||
|
def install
|
||||||
|
puts "python@3.9"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user