diff options
| author | Gautham Goli | 2017-08-15 00:29:58 +0530 |
|---|---|---|
| committer | Gautham Goli | 2017-08-15 00:29:58 +0530 |
| commit | 5744cd9066bbdfc4db5332a202ddb962d5359ee5 (patch) | |
| tree | be0cea0c1d23e0d8a01daff0684a5f4dfaa1a63c /Library/Homebrew | |
| parent | cfc423e1839442f605072db14aac42f6f5fa6174 (diff) | |
| download | brew-5744cd9066bbdfc4db5332a202ddb962d5359ee5.tar.bz2 | |
add test for inspecting version
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/rubocops/lines_cop.rb | 10 | ||||
| -rw-r--r-- | Library/Homebrew/test/rubocops/lines_cop_spec.rb | 24 |
2 files changed, 29 insertions, 5 deletions
diff --git a/Library/Homebrew/rubocops/lines_cop.rb b/Library/Homebrew/rubocops/lines_cop.rb index 0c465f9f5..324fe487a 100644 --- a/Library/Homebrew/rubocops/lines_cop.rb +++ b/Library/Homebrew/rubocops/lines_cop.rb @@ -157,11 +157,11 @@ module RuboCop problem "Dependency #{string_content(dep)} should not use option #{string_content(option)}" end - # find_instance_method_call(body_node, :version, :==) do |m| - # next unless parameters_passed?(m, "HEAD") - # problem "Use 'build.head?' instead of inspecting 'version'" - # end - # + find_instance_method_call(body_node, :version, :==) do |m| + next unless parameters_passed?(m, "HEAD") + problem "Use 'build.head?' instead of inspecting 'version'" + end + # find_instance_method_call(body_node, :ENV, :fortran) do # next if depends_on?(:fortran) # problem "Use `depends_on :fortran` instead of `ENV.fortran`" diff --git a/Library/Homebrew/test/rubocops/lines_cop_spec.rb b/Library/Homebrew/test/rubocops/lines_cop_spec.rb index 1273ef9c9..f24a6b09d 100644 --- a/Library/Homebrew/test/rubocops/lines_cop_spec.rb +++ b/Library/Homebrew/test/rubocops/lines_cop_spec.rb @@ -1117,6 +1117,30 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end + it "with inspecting version" do + source = <<-EOS.undent + class Foo < Formula + desc "foo" + url 'http://example.com/foo-1.0.tgz' + if version == "HEAD" + foo() + end + end + EOS + + expected_offenses = [{ message: "Use 'build.head?' instead of inspecting 'version'", + severity: :convention, + line: 4, + column: 5, + source: source }] + + inspect_source(cop, source) + + expected_offenses.zip(cop.offenses).each do |expected, actual| + expect_offense(expected, actual) + end + end + end def expect_offense(expected, actual) expect(actual.message).to eq(expected[:message]) |
