diff --git a/Library/Homebrew/rubocops/patches_cop.rb b/Library/Homebrew/rubocops/patches_cop.rb index fb14d8acca..b272833821 100644 --- a/Library/Homebrew/rubocops/patches_cop.rb +++ b/Library/Homebrew/rubocops/patches_cop.rb @@ -31,7 +31,10 @@ module RuboCop %r{gist\.githubusercontent\.com/.+/raw}]) if regex_match_group(patch, gh_patch_patterns) unless patch_url =~ /[a-fA-F0-9]{40}/ - problem "GitHub/Gist patches should specify a revision:\n#{patch_url}" + problem <<-EOS.undent.chomp + GitHub/Gist patches should specify a revision: + #{patch_url} + EOS end end @@ -46,15 +49,24 @@ module RuboCop end if regex_match_group(patch, %r{macports/trunk}) - problem "MacPorts patches should specify a revision instead of trunk:\n#{patch_url}" + problem <<-EOS.undent.chomp + MacPorts patches should specify a revision instead of trunk: + #{patch_url} + EOS end if regex_match_group(patch, %r{^http://trac\.macports\.org}) - problem "Patches from MacPorts Trac should be https://, not http:\n#{patch_url}" + problem <<-EOS.undent.chomp + Patches from MacPorts Trac should be https://, not http: + #{patch_url} + EOS end return unless regex_match_group(patch, %r{^http://bugs\.debian\.org}) - problem "Patches from Debian should be https://, not http:\n#{patch_url}" + problem <<-EOS.undent.chomp + Patches from Debian should be https://, not http: + #{patch_url} + EOS end end end diff --git a/Library/Homebrew/rubocops/urls_cop.rb b/Library/Homebrew/rubocops/urls_cop.rb index 676e735238..071a4c42d6 100644 --- a/Library/Homebrew/rubocops/urls_cop.rb +++ b/Library/Homebrew/rubocops/urls_cop.rb @@ -104,8 +104,10 @@ module RuboCop end if url =~ %r{^https?://prdownloads\.} - problem "Don't use prdownloads in SourceForge urls (url is #{url}).\n" \ - "\tSee: http://librelist.com/browser/homebrew/2011/1/12/prdownloads-is-bad/" + problem <<-EOS.undent.chomp + Don't use prdownloads in SourceForge urls (url is #{url}). + See: http://librelist.com/browser/homebrew/2011/1/12/prdownloads-is-bad/ + EOS end if url =~ %r{^http://\w+\.dl\.} diff --git a/Library/Homebrew/test/rubocops/patches_cop_spec.rb b/Library/Homebrew/test/rubocops/patches_cop_spec.rb index 4bd79bf357..092782bfb1 100644 --- a/Library/Homebrew/test/rubocops/patches_cop_spec.rb +++ b/Library/Homebrew/test/rubocops/patches_cop_spec.rb @@ -62,34 +62,48 @@ describe RuboCop::Cop::FormulaAudit::Patches do inspect_source(cop, source) if patch_url =~ %r{/raw\.github\.com/} - expected_offenses = [{ message: "GitHub/Gist patches should specify a revision:\n#{patch_url}", + expected_offenses = [{ message: <<-EOS.undent.chomp, + GitHub/Gist patches should specify a revision: + #{patch_url} + EOS severity: :convention, line: 5, column: 12, source: source }] elsif patch_url =~ %r{macports/trunk} - expected_offenses = [{ message: "MacPorts patches should specify a revision instead of trunk:\n#{patch_url}", + expected_offenses = [{ message: <<-EOS.undent.chomp, + MacPorts patches should specify a revision instead of trunk: + #{patch_url} + EOS severity: :convention, line: 5, column: 33, source: source }] elsif patch_url =~ %r{^http://trac\.macports\.org} - expected_offenses = [{ message: "Patches from MacPorts Trac should be https://, not http:\n#{patch_url}", + expected_offenses = [{ message: <<-EOS.undent.chomp, + Patches from MacPorts Trac should be https://, not http: + #{patch_url} + EOS severity: :convention, line: 5, column: 5, source: source }] elsif patch_url =~ %r{^http://bugs\.debian\.org} - expected_offenses = [{ message: "Patches from Debian should be https://, not http:\n#{patch_url}", + expected_offenses = [{ message: <<-EOS.undent.chomp, + Patches from Debian should be https://, not http: + #{patch_url} + EOS severity: :convention, line: 5, column: 5, source: source }] elsif patch_url =~ %r{https?://patch-diff\.githubusercontent\.com/raw/(.+)/(.+)/pull/(.+)\.(?:diff|patch)} - expected_offenses = [{ message: "use GitHub pull request URLs:\n"\ - " https://github.com/foo/foo-bar/pull/100.patch\n"\ - "Rather than patch-diff:\n"\ - " https://patch-diff.githubusercontent.com/raw/foo/foo-bar/pull/100.patch\n", + expected_offenses = [{ message: <<-EOS.undent, + use GitHub pull request URLs: + https://github.com/foo/foo-bar/pull/100.patch + Rather than patch-diff: + https://patch-diff.githubusercontent.com/raw/foo/foo-bar/pull/100.patch + EOS severity: :convention, line: 5, column: 5, @@ -121,8 +135,10 @@ describe RuboCop::Cop::FormulaAudit::Patches do line: 4, column: 2, source: source }, - { message: "Patches from MacPorts Trac should be https://, not http:\n"\ - "http://trac.macports.org/export/68507/trunk/dports/net/trafshow/files/", + { message: <<-EOS.undent.chomp, + Patches from MacPorts Trac should be https://, not http: + http://trac.macports.org/export/68507/trunk/dports/net/trafshow/files/ + EOS severity: :convention, line: 8, column: 26, @@ -159,34 +175,48 @@ describe RuboCop::Cop::FormulaAudit::Patches do inspect_source(cop, source) if patch_url =~ %r{/raw\.github\.com/} - expected_offenses = [{ message: "GitHub/Gist patches should specify a revision:\n#{patch_url}", + expected_offenses = [{ message: <<-EOS.undent.chomp, + GitHub/Gist patches should specify a revision: + #{patch_url} + EOS severity: :convention, line: 5, column: 16, source: source }] elsif patch_url =~ %r{macports/trunk} - expected_offenses = [{ message: "MacPorts patches should specify a revision instead of trunk:\n#{patch_url}", + expected_offenses = [{ message: <<-EOS.undent.chomp, + MacPorts patches should specify a revision instead of trunk: + #{patch_url} + EOS severity: :convention, line: 5, column: 37, source: source }] elsif patch_url =~ %r{^http://trac\.macports\.org} - expected_offenses = [{ message: "Patches from MacPorts Trac should be https://, not http:\n#{patch_url}", + expected_offenses = [{ message: <<-EOS.undent.chomp, + Patches from MacPorts Trac should be https://, not http: + #{patch_url} + EOS severity: :convention, line: 5, column: 9, source: source }] elsif patch_url =~ %r{^http://bugs\.debian\.org} - expected_offenses = [{ message: "Patches from Debian should be https://, not http:\n#{patch_url}", + expected_offenses = [{ message: <<-EOS.undent.chomp, + Patches from Debian should be https://, not http: + #{patch_url} + EOS severity: :convention, line: 5, column: 9, source: source }] elsif patch_url =~ %r{https?://patch-diff\.githubusercontent\.com/raw/(.+)/(.+)/pull/(.+)\.(?:diff|patch)} - expected_offenses = [{ message: "use GitHub pull request URLs:\n"\ - " https://github.com/foo/foo-bar/pull/100.patch\n"\ - "Rather than patch-diff:\n"\ - " https://patch-diff.githubusercontent.com/raw/foo/foo-bar/pull/100.patch\n", + expected_offenses = [{ message: <<-EOS.undent, + use GitHub pull request URLs: + https://github.com/foo/foo-bar/pull/100.patch + Rather than patch-diff: + https://patch-diff.githubusercontent.com/raw/foo/foo-bar/pull/100.patch + EOS severity: :convention, line: 5, column: 9, diff --git a/Library/Homebrew/test/rubocops/urls_cop_spec.rb b/Library/Homebrew/test/rubocops/urls_cop_spec.rb index 280da6314c..e51fb6be0e 100644 --- a/Library/Homebrew/test/rubocops/urls_cop_spec.rb +++ b/Library/Homebrew/test/rubocops/urls_cop_spec.rb @@ -54,8 +54,10 @@ describe RuboCop::Cop::FormulaAudit::Urls do "col" => 2, }, { "url" => "http://prdownloads.sourceforge.net/foo/foo-1.tar.gz", - "msg" => "Don't use prdownloads in SourceForge urls (url is http://prdownloads.sourceforge.net/foo/foo-1.tar.gz).\n" \ - "\tSee: http://librelist.com/browser/homebrew/2011/1/12/prdownloads-is-bad/", + "msg" => <<-EOS.undent.chomp, + Don't use prdownloads in SourceForge urls (url is http://prdownloads.sourceforge.net/foo/foo-1.tar.gz). + See: http://librelist.com/browser/homebrew/2011/1/12/prdownloads-is-bad/ + EOS "col" => 2, }, { "url" => "http://foo.dl.sourceforge.net/sourceforge/foozip/foozip_1.0.tar.bz2", @@ -67,8 +69,11 @@ describe RuboCop::Cop::FormulaAudit::Urls do "col" => 2, }, { "url" => "http://http.debian.net/debian/dists/foo/", - "msg" => "Please use a secure mirror for Debian URLs.\nWe recommend:\n"\ - " https://mirrors.ocf.berkeley.edu/debian/dists/foo/\n", + "msg" => <<-EOS.undent, + Please use a secure mirror for Debian URLs. + We recommend: + https://mirrors.ocf.berkeley.edu/debian/dists/foo/ + EOS "col" => 2, }, { "url" => "http://foo.googlecode.com/files/foo-1.0.zip", @@ -96,8 +101,12 @@ describe RuboCop::Cop::FormulaAudit::Urls do "col" => 2, }, { "url" => "https://codeload.github.com/foo/bar/tar.gz/v0.1.1", - "msg" => "Use GitHub archive URLs:\n https://github.com/foo/bar/archive/v0.1.1.tar.gz\n"\ - "Rather than codeload:\n https://codeload.github.com/foo/bar/tar.gz/v0.1.1\n", + "msg" => <<-EOS.undent, + Use GitHub archive URLs: + https://github.com/foo/bar/archive/v0.1.1.tar.gz + Rather than codeload: + https://codeload.github.com/foo/bar/tar.gz/v0.1.1 + EOS "col" => 2, }, { "url" => "https://central.maven.org/maven2/com/bar/foo/1.1/foo-1.1.jar",