diff options
| author | JCount | 2017-08-21 13:13:09 -0400 | 
|---|---|---|
| committer | GitHub | 2017-08-21 13:13:09 -0400 | 
| commit | 85fd43d4fe595f73b9168360b4c15a43e1a9debf (patch) | |
| tree | 9cb9fe2d2fe170ee828fdc5ef6bcad47356b4add | |
| parent | 4b34ca5b35b095e538b6e3bfe642eb57dad924ee (diff) | |
| parent | db20b0c281899e42d4d4bbe5a98e644e1f543df4 (diff) | |
| download | brew-85fd43d4fe595f73b9168360b4c15a43e1a9debf.tar.bz2 | |
Merge pull request #3063 from GauthamGoli/rubocop_spec_multiline_offenses_fix
audit: In Cops and their tests convert all multiline strings to heredocs
| -rw-r--r-- | Library/Homebrew/rubocops/patches_cop.rb | 20 | ||||
| -rw-r--r-- | Library/Homebrew/rubocops/urls_cop.rb | 6 | ||||
| -rw-r--r-- | Library/Homebrew/test/rubocops/patches_cop_spec.rb | 66 | ||||
| -rw-r--r-- | Library/Homebrew/test/rubocops/urls_cop_spec.rb | 21 | 
4 files changed, 83 insertions, 30 deletions
| diff --git a/Library/Homebrew/rubocops/patches_cop.rb b/Library/Homebrew/rubocops/patches_cop.rb index fb14d8acc..b27283382 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 676e73523..071a4c42d 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 4bd79bf35..092782bfb 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 280da6314..e51fb6be0 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", | 
