From 80ae5b2660d293adc9d1ad4aaa376500910a339a Mon Sep 17 00:00:00 2001 From: Mislav Marohnić Date: Tue, 15 Aug 2017 17:32:12 +0200 Subject: bump-formula-pr: forward compatibility with `hub fork` Due to limitations of `hub fork` in hub 2.2, scripts had to repeat the command at least two times; the 2nd time was to read the fork name from the "fatal: remote MYNAME already exists" message output from git. In upcoming hub 2.3, the `hub fork` command is improved to always output the remote name, regardless of whether one already existed or not. With this approach, only one `hub fork` call will ever be necessary when hub is up to date. --- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index e9e98d450..521c76302 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -296,9 +296,7 @@ module Homebrew ohai "git fetch --unshallow origin" if shallow ohai "git checkout --no-track -b #{branch} origin/master" ohai "git commit --no-edit --verbose --message='#{formula.name} #{new_formula_version}#{devel_message}' -- #{formula.path}" - ohai "hub fork --no-remote" - ohai "hub fork" - ohai "hub fork (to read $HUB_REMOTE)" + ohai "hub fork # read $HUB_REMOTE" ohai "git push --set-upstream $HUB_REMOTE #{branch}:#{branch}" ohai "hub pull-request --browse -m '#{formula.name} #{new_formula_version}#{devel_message}'" ohai "git checkout -" @@ -308,9 +306,9 @@ module Homebrew safe_system "git", "commit", "--no-edit", "--verbose", "--message=#{formula.name} #{new_formula_version}#{devel_message}", "--", formula.path - safe_system "hub", "fork", "--no-remote" - quiet_system "hub", "fork" - remote = Utils.popen_read("hub fork 2>&1")[/fatal: remote (.+) already exists\./, 1] + remote = Utils.popen_read("hub fork 2>&1")[/remote:? (\S+)/, 1] + # repeat for hub 2.2 backwards compatibility: + remote = Utils.popen_read("hub fork 2>&1")[/remote:? (\S+)/, 1] if remote.to_s.empty? odie "cannot get remote from 'hub'!" if remote.to_s.empty? safe_system "git", "push", "--set-upstream", remote, "#{branch}:#{branch}" pr_message = <<-EOS.undent -- cgit v1.2.3 From 923c84d4f7c4e0cf09bfb417deb83bff2364c199 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 27 Aug 2017 09:39:28 +0000 Subject: add some heuristics to https upgrade check --- Library/Homebrew/dev-cmd/audit.rb | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 2c9336481..4fadae1a4 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -201,7 +201,7 @@ class FormulaAuditor @specs = %w[stable devel head].map { |s| formula.send(s) }.compact end - def self.check_http_content(url, name, user_agents: [:default]) + def self.check_http_content(type, url, name, user_agents: [:default]) return unless url.start_with? "http" details = nil @@ -236,8 +236,31 @@ class FormulaAuditor details[:content_length] == secure_details[:content_length] file_match = details[:file_hash] == secure_details[:file_hash] - return if !etag_match && !content_length_match && !file_match - "The URL #{url} could use HTTPS rather than HTTP" + if etag_match || content_length_match || file_match + return "The URL #{url} could use HTTPS rather than HTTP" + end + + if type == "homepage" + + details[:file] = details[:file].gsub(/https?:\\?\/\\?\//, '/') + secure_details[:file] = secure_details[:file].gsub(/https?:\\?\/\\?\//, '/') + + # Same content after normalization + if details[:file] == secure_details[:file] + return "The URL #{url} could use HTTPS rather than HTTP" + end + + # Same size, different content after normalization + # (typical causes: Generated ID, Timestamp, Unix time) + if details[:file].length == secure_details[:file].length + return "The URL #{url} could use HTTPS rather than HTTP" + end + + lenratio = (100 * secure_details[:file].length / details[:file].length).to_i + if lenratio >= 90 && lenratio <= 120 + return "The URL #{url} may be able to use HTTPS rather than HTTP. Please verify it in a browser." + end + end end def self.http_content_headers_and_checksum(url, hash_needed: false, user_agent: :default) @@ -260,6 +283,7 @@ class FormulaAuditor etag: headers[%r{ETag: ([wW]\/)?"(([^"]|\\")*)"}, 2], content_length: headers[/Content-Length: (\d+)/, 1], file_hash: output_hash, + file: output, } end @@ -564,7 +588,8 @@ class FormulaAuditor return unless @online return unless DevelopmentTools.curl_handles_most_https_homepages? - if http_content_problem = FormulaAuditor.check_http_content(homepage, + if http_content_problem = FormulaAuditor.check_http_content("homepage", + homepage, formula.name, user_agents: [:browser, :default]) problem http_content_problem @@ -1219,7 +1244,8 @@ class ResourceAuditor # A `brew mirror`'ed URL is usually not yet reachable at the time of # pull request. next if url =~ %r{^https://dl.bintray.com/homebrew/mirror/} - if http_content_problem = FormulaAuditor.check_http_content(url, name) + if http_content_problem = FormulaAuditor.check_http_content("url", + url, name) problem http_content_problem end elsif strategy <= GitDownloadStrategy -- cgit v1.2.3 From 11b267a7cfb3411c74c4fc21732463d543fc4fb3 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 27 Aug 2017 17:52:26 +0000 Subject: try addressing style issues --- Library/Homebrew/dev-cmd/audit.rb | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 4fadae1a4..97fc93db9 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -240,26 +240,25 @@ class FormulaAuditor return "The URL #{url} could use HTTPS rather than HTTP" end - if type == "homepage" + return if type != "homepage" - details[:file] = details[:file].gsub(/https?:\\?\/\\?\//, '/') - secure_details[:file] = secure_details[:file].gsub(/https?:\\?\/\\?\//, '/') + details[:file] = details[:file].gsub(%r{https?:\\?\/\\?\/}, "/") + secure_details[:file] = secure_details[:file].gsub(%r{https?:\\?\/\\?\/}, "/") - # Same content after normalization - if details[:file] == secure_details[:file] - return "The URL #{url} could use HTTPS rather than HTTP" - end + # Same content after normalization + if details[:file] == secure_details[:file] + return "The URL #{url} could use HTTPS rather than HTTP" + end - # Same size, different content after normalization - # (typical causes: Generated ID, Timestamp, Unix time) - if details[:file].length == secure_details[:file].length - return "The URL #{url} could use HTTPS rather than HTTP" - end + # Same size, different content after normalization + # (typical causes: Generated ID, Timestamp, Unix time) + if details[:file].length == secure_details[:file].length + return "The URL #{url} could use HTTPS rather than HTTP" + end - lenratio = (100 * secure_details[:file].length / details[:file].length).to_i - if lenratio >= 90 && lenratio <= 120 - return "The URL #{url} may be able to use HTTPS rather than HTTP. Please verify it in a browser." - end + lenratio = (100 * secure_details[:file].length / details[:file].length).to_i + if lenratio >= 90 && lenratio <= 120 + return "The URL #{url} may be able to use HTTPS rather than HTTP. Please verify it in a browser." end end -- cgit v1.2.3 From 1c2c390c6fae78062c28a8ed1610936a4c2dd412 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 27 Aug 2017 18:00:59 +0000 Subject: try addressing style issues #2 --- Library/Homebrew/dev-cmd/audit.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 97fc93db9..d468d69cb 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -257,9 +257,8 @@ class FormulaAuditor end lenratio = (100 * secure_details[:file].length / details[:file].length).to_i - if lenratio >= 90 && lenratio <= 120 - return "The URL #{url} may be able to use HTTPS rather than HTTP. Please verify it in a browser." - end + return if lenratio < 90 || lenratio > 120 + "The URL #{url} may be able to use HTTPS rather than HTTP. Please verify it in a browser." end def self.http_content_headers_and_checksum(url, hash_needed: false, user_agent: :default) -- cgit v1.2.3 From 53be6bb4bd69eaf8cc8e5c3c1ac9ecd1ddb1582c Mon Sep 17 00:00:00 2001 From: mansimarkaur Date: Thu, 27 Jul 2017 04:40:27 +0530 Subject: Added check for svn availability --- Library/Homebrew/dev-cmd/audit.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 2c9336481..0e4500a12 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -1228,7 +1228,9 @@ class ResourceAuditor end elsif strategy <= SubversionDownloadStrategy next unless DevelopmentTools.subversion_handles_most_https_certificates? - unless Utils.svn_remote_exists url + if !Utils.svn_available? + problem "No valid version of svn found" + elsif Utils.svn_remote_exists url problem "The URL #{url} is not a valid svn URL" end end -- cgit v1.2.3 From 3d8873ca5b6270351ac8e4260fba8a41f8c0fe04 Mon Sep 17 00:00:00 2001 From: mansimarkaur Date: Tue, 29 Aug 2017 16:14:00 +0530 Subject: url skipped if svn not available when auditing urls --- Library/Homebrew/dev-cmd/audit.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 0e4500a12..be332481c 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -1228,9 +1228,8 @@ class ResourceAuditor end elsif strategy <= SubversionDownloadStrategy next unless DevelopmentTools.subversion_handles_most_https_certificates? - if !Utils.svn_available? - problem "No valid version of svn found" - elsif Utils.svn_remote_exists url + next unless Utils.svn_available? + if Utils.svn_remote_exists url problem "The URL #{url} is not a valid svn URL" end end -- cgit v1.2.3 From c30b94135853b809eda34c5c347c549bbf08a42d Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 29 Aug 2017 12:31:07 +0000 Subject: review follow-up #1 --- Library/Homebrew/dev-cmd/audit.rb | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index d468d69cb..5a86c0adf 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -201,7 +201,7 @@ class FormulaAuditor @specs = %w[stable devel head].map { |s| formula.send(s) }.compact end - def self.check_http_content(type, url, name, user_agents: [:default]) + def self.check_http_content(url, name, user_agents: [:default], check_content: false) return unless url.start_with? "http" details = nil @@ -237,23 +237,24 @@ class FormulaAuditor file_match = details[:file_hash] == secure_details[:file_hash] if etag_match || content_length_match || file_match - return "The URL #{url} could use HTTPS rather than HTTP" + return "The URL #{url} should use HTTPS rather than HTTP" end - return if type != "homepage" + return unless check_content - details[:file] = details[:file].gsub(%r{https?:\\?\/\\?\/}, "/") - secure_details[:file] = secure_details[:file].gsub(%r{https?:\\?\/\\?\/}, "/") + no_protocol_file_contents = %r{https?:\\?/\\?/} + details[:file] = details[:file].gsub(no_protocol_file_contents, "/") + secure_details[:file] = secure_details[:file].gsub(no_protocol_file_contents, "/") - # Same content after normalization + # Check for the same content after removing all protocols if details[:file] == secure_details[:file] - return "The URL #{url} could use HTTPS rather than HTTP" + return "The URL #{url} should use HTTPS rather than HTTP" end # Same size, different content after normalization # (typical causes: Generated ID, Timestamp, Unix time) if details[:file].length == secure_details[:file].length - return "The URL #{url} could use HTTPS rather than HTTP" + return "The URL #{url} may be able to use HTTPS rather than HTTP. Please verify it in a browser." end lenratio = (100 * secure_details[:file].length / details[:file].length).to_i @@ -586,10 +587,10 @@ class FormulaAuditor return unless @online return unless DevelopmentTools.curl_handles_most_https_homepages? - if http_content_problem = FormulaAuditor.check_http_content("homepage", - homepage, + if http_content_problem = FormulaAuditor.check_http_content(homepage, formula.name, - user_agents: [:browser, :default]) + user_agents: [:browser, :default], + check_content: true) problem http_content_problem end end @@ -1242,8 +1243,7 @@ class ResourceAuditor # A `brew mirror`'ed URL is usually not yet reachable at the time of # pull request. next if url =~ %r{^https://dl.bintray.com/homebrew/mirror/} - if http_content_problem = FormulaAuditor.check_http_content("url", - url, name) + if http_content_problem = FormulaAuditor.check_http_content(url, name) problem http_content_problem end elsif strategy <= GitDownloadStrategy -- cgit v1.2.3 From 56ccf10efaac5f97bae6b2e5aef9ef87d7529328 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 29 Aug 2017 12:53:45 +0000 Subject: limit some heuristics to strict mode --- Library/Homebrew/dev-cmd/audit.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 5a86c0adf..17948ea2c 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -201,7 +201,7 @@ class FormulaAuditor @specs = %w[stable devel head].map { |s| formula.send(s) }.compact end - def self.check_http_content(url, name, user_agents: [:default], check_content: false) + def self.check_http_content(url, name, user_agents: [:default], check_content: false, strict: false) return unless url.start_with? "http" details = nil @@ -251,6 +251,8 @@ class FormulaAuditor return "The URL #{url} should use HTTPS rather than HTTP" end + return unless strict + # Same size, different content after normalization # (typical causes: Generated ID, Timestamp, Unix time) if details[:file].length == secure_details[:file].length @@ -590,7 +592,8 @@ class FormulaAuditor if http_content_problem = FormulaAuditor.check_http_content(homepage, formula.name, user_agents: [:browser, :default], - check_content: true) + check_content: true, + strict: @strict) problem http_content_problem end end -- cgit v1.2.3 From 18f5b43d9001955784e235ce7f87068038175a82 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 29 Aug 2017 17:02:27 +0000 Subject: fix length ratio range --- Library/Homebrew/dev-cmd/audit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 17948ea2c..93aab6384 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -260,7 +260,7 @@ class FormulaAuditor end lenratio = (100 * secure_details[:file].length / details[:file].length).to_i - return if lenratio < 90 || lenratio > 120 + return if lenratio < 90 || lenratio > 110 "The URL #{url} may be able to use HTTPS rather than HTTP. Please verify it in a browser." end -- cgit v1.2.3 From f301e5c4f4a3094aa9a1a1cf76a34efbd04b838d Mon Sep 17 00:00:00 2001 From: Dominyk Tiller Date: Thu, 31 Aug 2017 21:33:09 +0100 Subject: audit: add a nudge to remove ENV.java_cache --- Library/Homebrew/dev-cmd/audit.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index be332481c..3c6867f45 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -869,6 +869,10 @@ class FormulaAuditor problem "Use \"depends_on :x11\" instead of \"ENV.x11\"" end + if line.include?("ENV.java_cache") + problem "In-formula ENV.java_cache usage has been deprecated & should be removed." + end + # Avoid hard-coding compilers if line =~ %r{(system|ENV\[.+\]\s?=)\s?['"](/usr/bin/)?(gcc|llvm-gcc|clang)['" ]} problem "Use \"\#{ENV.cc}\" instead of hard-coding \"#{Regexp.last_match(3)}\"" -- cgit v1.2.3 From 42e2c71dbc9c744fdabab70bf51dce106a76f0a6 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 1 Sep 2017 16:47:31 +0000 Subject: cleanup range check --- Library/Homebrew/dev-cmd/audit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 93aab6384..f6a8b10a6 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -260,7 +260,7 @@ class FormulaAuditor end lenratio = (100 * secure_details[:file].length / details[:file].length).to_i - return if lenratio < 90 || lenratio > 110 + return unless (90..110).cover?(lenratio) "The URL #{url} may be able to use HTTPS rather than HTTP. Please verify it in a browser." end -- cgit v1.2.3 From bbf71921eb2b2cce5072bb615fac3a2bc96fcfc7 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 3 Sep 2017 21:42:46 +0100 Subject: audit: fix subversion remote check logic. Stop flagging invalid URLs as valid and vice-versa. Fixes #3118. --- Library/Homebrew/dev-cmd/audit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 3c6867f45..d8306609b 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -1233,7 +1233,7 @@ class ResourceAuditor elsif strategy <= SubversionDownloadStrategy next unless DevelopmentTools.subversion_handles_most_https_certificates? next unless Utils.svn_available? - if Utils.svn_remote_exists url + unless Utils.svn_remote_exists url problem "The URL #{url} is not a valid svn URL" end end -- cgit v1.2.3 From 267def28faab69388be3bc6347c0644f6ca812e8 Mon Sep 17 00:00:00 2001 From: Gautham Goli Date: Fri, 4 Aug 2017 01:18:00 +0530 Subject: audit: Port rules from line_problems to rubocop part 3 --- Library/Homebrew/dev-cmd/audit.rb | 47 --------------------------------------- 1 file changed, 47 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index d089f308d..87377bd77 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -892,10 +892,6 @@ class FormulaAuditor problem "Use spaces instead of tabs for indentation" if line =~ /^[ ]*\t/ - if line.include?("ENV.x11") - problem "Use \"depends_on :x11\" instead of \"ENV.x11\"" - end - if line.include?("ENV.java_cache") problem "In-formula ENV.java_cache usage has been deprecated & should be removed." end @@ -913,14 +909,6 @@ class FormulaAuditor problem "Use ENV instead of invoking '#{Regexp.last_match(1)}' to modify the environment" end - if formula.name != "wine" && line =~ /ENV\.universal_binary/ - problem "macOS has been 64-bit only since 10.6 so ENV.universal_binary is deprecated." - end - - if line =~ /build\.universal\?/ - problem "macOS has been 64-bit only so build.universal? is deprecated." - end - if line =~ /version == ['"]HEAD['"]/ problem "Use 'build.head?' instead of inspecting 'version'" end @@ -961,12 +949,6 @@ class FormulaAuditor problem "Use build instead of ARGV to check options" end - problem "Use new-style option definitions" if line.include?("def options") - - if line.end_with?("def test") - problem "Use new-style test definitions (test do)" - end - if line.include?("MACOS_VERSION") problem "Use MacOS.version instead of MACOS_VERSION" end @@ -980,11 +962,6 @@ class FormulaAuditor problem "\"#{$&}\" is deprecated, use a comparison to MacOS.version instead" end - if line =~ /skip_clean\s+:all/ - problem "`skip_clean :all` is deprecated; brew no longer strips symbols\n" \ - "\tPass explicit paths to prevent Homebrew from removing empty folders." - end - if line =~ /depends_on [A-Z][\w:]+\.new$/ problem "`depends_on` can take requirement classes instead of instances" end @@ -1023,30 +1000,6 @@ class FormulaAuditor problem "Use `assert_match` instead of `assert ...include?`" end - if line.include?('system "npm", "install"') && !line.include?("Language::Node") && - formula.name !~ /^kibana(\@\d+(\.\d+)?)?$/ - problem "Use Language::Node for npm install args" - end - - if line.include?("fails_with :llvm") - problem "'fails_with :llvm' is now a no-op so should be removed" - end - - if line =~ /system\s+['"](otool|install_name_tool|lipo)/ && formula.name != "cctools" - problem "Use ruby-macho instead of calling #{Regexp.last_match(1)}" - end - - if formula.tap.to_s == "homebrew/core" - ["OS.mac?", "OS.linux?"].each do |check| - next unless line.include?(check) - problem "Don't use #{check}; Homebrew/core only supports macOS" - end - end - - if line =~ /((revision|version_scheme)\s+0)/ - problem "'#{Regexp.last_match(1)}' should be removed" - end - return unless @strict problem "`#{Regexp.last_match(1)}` in formulae is deprecated" if line =~ /(env :(std|userpaths))/ -- cgit v1.2.3 From 4ec26aea4025d19e70cdf59da6dfd7be3a389e44 Mon Sep 17 00:00:00 2001 From: Gautham Goli Date: Mon, 4 Sep 2017 13:47:05 +0530 Subject: audit: Port audit_class to rubocop, add tests and autocorrect --- Library/Homebrew/dev-cmd/audit.rb | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index d089f308d..1f8acb1b9 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -381,21 +381,6 @@ class FormulaAuditor end end - def audit_class - if @strict - unless formula.test_defined? - problem "A `test do` test block should be added" - end - end - - classes = %w[GithubGistFormula ScriptFileFormula AmazonWebServicesFormula] - klass = classes.find do |c| - Object.const_defined?(c) && formula.class < Object.const_get(c) - end - - problem "#{klass} is deprecated, use Formula instead" if klass - end - # core aliases + tap alias names + tap alias full name @@aliases ||= Formula.aliases + Formula.tap_aliases -- cgit v1.2.3 From d45ff9c0fdfa834c55c01f9c95fe18064fabd76a Mon Sep 17 00:00:00 2001 From: Gautham Goli Date: Sat, 2 Sep 2017 12:38:18 +0530 Subject: audit: Add a global flag to silent warning when auditing --- Library/Homebrew/dev-cmd/audit.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 1f8acb1b9..884861c87 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -54,6 +54,7 @@ module Homebrew def audit Homebrew.inject_dump_stats!(FormulaAuditor, /^audit_/) if ARGV.switch? "D" + Homebrew.auditing = true formula_count = 0 problem_count = 0 -- cgit v1.2.3 From 9562cceef15977306c9664f4f19892992a63e44a Mon Sep 17 00:00:00 2001 From: Dominyk Tiller Date: Tue, 5 Sep 2017 03:35:44 +0100 Subject: audit: stop demanding a HTTP HEAD mirror for curl Not sure if this is how you want to handle it but having a HEAD mirror for `curl` is just silliness. Ref: https://github.com/Homebrew/homebrew-core/commit/e36b95849ae38ade30605155d75cf6e731b4e38f --- Library/Homebrew/dev-cmd/audit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index d089f308d..cfc57ac92 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -1237,7 +1237,7 @@ class ResourceAuditor def audit_urls urls = [url] + mirrors - if name == "curl" && !urls.find { |u| u.start_with?("http://") } + if name == "curl" && !urls.find { |u| u.start_with?("http://") } && url != Formula["curl"].head.url problem "should always include at least one HTTP url" end -- cgit v1.2.3 From 03ace9b1104f1ddc2adc75a68531167d7e3ea7e0 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 14 Sep 2017 19:58:37 +0100 Subject: Require more HTTP mirrors for old OS X versions. This allows the bootstrap of `curl` and `git` on versions of Mac OS X that cannot reliably download from HTTPS servers any longer. Once these are both installed users are able to update Homebrew and download files securely. Also, as we're doing this, don't point 10.5 users to Tigerbrew as they are already given caveats for using Homebrew itself. --- Library/Homebrew/dev-cmd/audit.rb | 47 ++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 15 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index bec035567..783237826 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -202,12 +202,12 @@ class FormulaAuditor @specs = %w[stable devel head].map { |s| formula.send(s) }.compact end - def self.check_http_content(url, name, user_agents: [:default], check_content: false, strict: false) + def self.check_http_content(url, user_agents: [:default], check_content: false, strict: false, require_http: false) return unless url.start_with? "http" details = nil user_agent = nil - hash_needed = url.start_with?("http:") && name != "curl" + hash_needed = url.start_with?("http:") && !require_http user_agents.each do |ua| details = http_content_headers_and_checksum(url, hash_needed: hash_needed, user_agent: ua) user_agent = ua @@ -576,7 +576,6 @@ class FormulaAuditor return unless DevelopmentTools.curl_handles_most_https_homepages? if http_content_problem = FormulaAuditor.check_http_content(homepage, - formula.name, user_agents: [:browser, :default], check_content: true, strict: @strict) @@ -629,13 +628,14 @@ class FormulaAuditor end %w[Stable Devel HEAD].each do |name| - next unless spec = formula.send(name.downcase) + spec_name = name.downcase.to_sym + next unless spec = formula.send(spec_name) - ra = ResourceAuditor.new(spec, online: @online, strict: @strict).audit + ra = ResourceAuditor.new(spec, spec_name, online: @online, strict: @strict).audit problems.concat ra.problems.map { |problem| "#{name}: #{problem}" } spec.resources.each_value do |resource| - ra = ResourceAuditor.new(resource, online: @online, strict: @strict).audit + ra = ResourceAuditor.new(resource, spec_name, online: @online, strict: @strict).audit problems.concat ra.problems.map { |problem| "#{name} resource #{resource.name.inspect}: #{problem}" } @@ -1086,10 +1086,10 @@ class FormulaAuditor end class ResourceAuditor - attr_reader :problems - attr_reader :version, :checksum, :using, :specs, :url, :mirrors, :name + attr_reader :name, :version, :checksum, :url, :mirrors, :using, :specs, :owner + attr_reader :spec_name, :problems - def initialize(resource, options = {}) + def initialize(resource, spec_name, options = {}) @name = resource.name @version = resource.version @checksum = resource.checksum @@ -1097,9 +1097,11 @@ class ResourceAuditor @mirrors = resource.mirrors @using = resource.using @specs = resource.specs - @online = options[:online] - @strict = options[:strict] - @problems = [] + @owner = resource.owner + @spec_name = spec_name + @online = options[:online] + @strict = options[:strict] + @problems = [] end def audit @@ -1173,11 +1175,26 @@ class ResourceAuditor problem "Redundant :using value in URL" end + def self.curl_git_openssl_and_deps + @curl_git_openssl_and_deps ||= begin + formulae_names = ["curl", "git", "openssl"] + formulae_names += formulae_names.flat_map do |f| + Formula[f].recursive_dependencies.map(&:name) + end + formulae_names.uniq + rescue FormulaUnavailableError + [] + end + end + def audit_urls urls = [url] + mirrors - if name == "curl" && !urls.find { |u| u.start_with?("http://") } && url != Formula["curl"].head.url - problem "should always include at least one HTTP url" + require_http = ResourceAuditor.curl_git_openssl_and_deps.include?(owner.name) + + if spec_name == :stable && require_http && + !urls.find { |u| u.start_with?("http://") } + problem "should always include at least one HTTP mirror" end return unless @online @@ -1189,7 +1206,7 @@ class ResourceAuditor # A `brew mirror`'ed URL is usually not yet reachable at the time of # pull request. next if url =~ %r{^https://dl.bintray.com/homebrew/mirror/} - if http_content_problem = FormulaAuditor.check_http_content(url, name) + if http_content_problem = FormulaAuditor.check_http_content(url, name, require_http: require_http) problem http_content_problem end elsif strategy <= GitDownloadStrategy -- cgit v1.2.3 From 2e43d95498eedd3c61f7c013a0a419c2c0aac098 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 15 Sep 2017 10:17:40 +0100 Subject: audit: fix check_http_content args. --- Library/Homebrew/dev-cmd/audit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 783237826..4220fce47 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -1206,7 +1206,7 @@ class ResourceAuditor # A `brew mirror`'ed URL is usually not yet reachable at the time of # pull request. next if url =~ %r{^https://dl.bintray.com/homebrew/mirror/} - if http_content_problem = FormulaAuditor.check_http_content(url, name, require_http: require_http) + if http_content_problem = FormulaAuditor.check_http_content(url, require_http: require_http) problem http_content_problem end elsif strategy <= GitDownloadStrategy -- cgit v1.2.3 From ffdda0eb9f4a2e56366e8c665d147d9be637f6f4 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 16 Sep 2017 12:41:08 +0100 Subject: Tweaks for older Mac OS X versions. - `brew update` should try to install `curl` before `git` on older versions of Mac OS X where it is needed for accessing modern SSL certificates. - We don't need an HTTP mirror for `git` because `curl` will already be installed before it is downloaded. - Don't recommend GCC on Mac OS X versions where it can't be built with the default system compiler. - Start using the Homebrew `curl` on Mac OS X versions where it is needed as soon as it is installed. --- Library/Homebrew/dev-cmd/audit.rb | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 4220fce47..e2a288fdb 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -574,7 +574,7 @@ class FormulaAuditor return unless @online - return unless DevelopmentTools.curl_handles_most_https_homepages? + return unless DevelopmentTools.curl_handles_most_https_certificates? if http_content_problem = FormulaAuditor.check_http_content(homepage, user_agents: [:browser, :default], check_content: true, @@ -1175,9 +1175,9 @@ class ResourceAuditor problem "Redundant :using value in URL" end - def self.curl_git_openssl_and_deps - @curl_git_openssl_and_deps ||= begin - formulae_names = ["curl", "git", "openssl"] + def self.curl_openssl_and_deps + @curl_openssl_and_deps ||= begin + formulae_names = ["curl", "openssl"] formulae_names += formulae_names.flat_map do |f| Formula[f].recursive_dependencies.map(&:name) end @@ -1190,11 +1190,14 @@ class ResourceAuditor def audit_urls urls = [url] + mirrors - require_http = ResourceAuditor.curl_git_openssl_and_deps.include?(owner.name) + curl_openssl_or_deps = ResourceAuditor.curl_openssl_and_deps.include?(owner.name) - if spec_name == :stable && require_http && - !urls.find { |u| u.start_with?("http://") } - problem "should always include at least one HTTP mirror" + if spec_name == :stable && curl_openssl_or_deps + problem "should not use xz tarballs" if url.end_with?(".xz") + + unless urls.find { |u| u.start_with?("http://") } + problem "should always include at least one HTTP mirror" + end end return unless @online @@ -1206,7 +1209,7 @@ class ResourceAuditor # A `brew mirror`'ed URL is usually not yet reachable at the time of # pull request. next if url =~ %r{^https://dl.bintray.com/homebrew/mirror/} - if http_content_problem = FormulaAuditor.check_http_content(url, require_http: require_http) + if http_content_problem = FormulaAuditor.check_http_content(url, require_http: curl_openssl_or_deps) problem http_content_problem end elsif strategy <= GitDownloadStrategy -- cgit v1.2.3 From 56ab1ef5a860beb2f180bbf26bfc74a0d569dce9 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 23 Sep 2017 21:10:25 +0100 Subject: audit: hack around El Capitan audit failure. --- Library/Homebrew/dev-cmd/audit.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index e2a288fdb..5d1871f54 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -214,7 +214,12 @@ class FormulaAuditor break if details[:status].to_s.start_with?("2") end - return "The URL #{url} is not reachable" unless details[:status] + unless details[:status] + # Hack around https://github.com/Homebrew/brew/issues/3199 + return if MacOS.version == :el_capitan + return "The URL #{url} is not reachable" + end + unless details[:status].start_with? "2" return "The URL #{url} is not reachable (HTTP status code #{details[:status]})" end -- cgit v1.2.3 From e984623214d2a55d30c342e0a4607eb2fe56d017 Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Sat, 23 Sep 2017 23:00:29 -0700 Subject: audit: don't check for homebrew/science duplicates It's just noise to turn the migration PRs red over expected duplicates. --- Library/Homebrew/dev-cmd/audit.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 5d1871f54..a9768c856 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -419,6 +419,7 @@ class FormulaAuditor @@local_official_taps_name_map ||= Tap.select(&:official?).flat_map(&:formula_names) .each_with_object({}) do |tap_formula_full_name, name_map| + next if tap_formula_full_name.start_with?("homebrew/science/") tap_formula_name = tap_formula_full_name.split("/").last name_map[tap_formula_name] ||= [] name_map[tap_formula_name] << tap_formula_full_name -- cgit v1.2.3 From 28c78384501e159ecb45e0ffa29ff419a22701d8 Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Sun, 24 Sep 2017 00:29:34 -0700 Subject: audit: also skip homebrew/science duplicates found by search_taps Follow-up to #3202. --- Library/Homebrew/dev-cmd/audit.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index a9768c856..743b9484e 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -430,6 +430,7 @@ class FormulaAuditor if @online Homebrew.search_taps(name, silent: true).each do |tap_formula_full_name| + next if tap_formula_full_name.start_with?("homebrew/science/") tap_formula_name = tap_formula_full_name.split("/").last next if tap_formula_name != name same_name_tap_formulae << tap_formula_full_name -- cgit v1.2.3 From 01e9ec9a9f723b2ef89c7adfaea39f9e4db9aede Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 24 Sep 2017 19:24:46 +0100 Subject: Rubocop: automatic rule fixes. --- Library/Homebrew/dev-cmd/audit.rb | 4 ++-- Library/Homebrew/dev-cmd/bottle.rb | 2 +- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 2 +- Library/Homebrew/dev-cmd/pull.rb | 4 ++-- Library/Homebrew/dev-cmd/release-notes.rb | 4 +--- 5 files changed, 7 insertions(+), 9 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 743b9484e..1fb89c3a4 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -707,7 +707,7 @@ class FormulaAuditor end stable = formula.stable - case stable && stable.url + case stable&.url when /[\d\._-](alpha|beta|rc\d)/ matched = Regexp.last_match(1) version_prefix = stable.version.to_s.sub(/\d+$/, "") @@ -1018,7 +1018,7 @@ class FormulaAuditor def audit_reverse_migration # Only enforce for new formula being re-added to core and official taps return unless @strict - return unless formula.tap && formula.tap.official? + return unless formula.tap&.official? return unless formula.tap.tap_migrations.key?(formula.name) problem <<-EOS.undent diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index d8aefc4c0..577924a34 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -283,7 +283,7 @@ module Homebrew raise ensure ignore_interrupts do - original_tab.write if original_tab + original_tab&.write unless ARGV.include? "--skip-relocation" keg.replace_placeholders_with_locations changed_files end diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 521c76302..87a239b98 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -124,7 +124,7 @@ module Homebrew Formula.each do |f| if is_devel && f.devel && f.devel.url && f.devel.url.match(base_url) guesses << f - elsif f.stable && f.stable.url && f.stable.url.match(base_url) + elsif f.stable&.url && f.stable.url.match(base_url) guesses << f end end diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb index a8f35531f..931cba07f 100644 --- a/Library/Homebrew/dev-cmd/pull.rb +++ b/Library/Homebrew/dev-cmd/pull.rb @@ -75,7 +75,7 @@ module Homebrew tap = CoreTap.instance elsif (testing_match = arg.match %r{/job/Homebrew.*Testing/(\d+)/}) tap = ARGV.value("tap") - tap = if tap && tap.start_with?("homebrew/") + tap = if tap&.start_with?("homebrew/") Tap.fetch("homebrew", tap.strip_prefix("homebrew/")) elsif tap odie "Tap option did not start with \"homebrew/\": #{tap}" @@ -350,7 +350,7 @@ module Homebrew files << Regexp.last_match(1) if line =~ %r{^\+\+\+ b/(.*)} end files.each do |file| - if tap && tap.formula_file?(file) + if tap&.formula_file?(file) formula_name = File.basename(file, ".rb") formulae << formula_name unless formulae.include?(formula_name) else diff --git a/Library/Homebrew/dev-cmd/release-notes.rb b/Library/Homebrew/dev-cmd/release-notes.rb index e578869bf..496023956 100644 --- a/Library/Homebrew/dev-cmd/release-notes.rb +++ b/Library/Homebrew/dev-cmd/release-notes.rb @@ -10,10 +10,8 @@ module Homebrew def release_notes previous_tag = ARGV.named.first - unless previous_tag - previous_tag = Utils.popen_read("git tag --list --sort=-version:refname") + previous_tag ||= Utils.popen_read("git tag --list --sort=-version:refname") .lines.first.chomp - end odie "Could not find any previous tags!" unless previous_tag end_ref = ARGV.named[1] || "origin/master" -- cgit v1.2.3 From cf5fdeef1d8e9fd053121145882835b87eec2a43 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 24 Sep 2017 20:12:58 +0100 Subject: Rubocop: manual rule fixes. --- Library/Homebrew/dev-cmd/audit.rb | 2 +- Library/Homebrew/dev-cmd/bottle.rb | 4 ++-- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 2 +- Library/Homebrew/dev-cmd/pull.rb | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 1fb89c3a4..a7d498c0d 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -358,7 +358,7 @@ class FormulaAuditor end valid_alias_names = [alias_name_major, alias_name_major_minor] - if formula.tap && !formula.tap.core_tap? + unless formula.tap&.core_tap? versioned_aliases.map! { |a| "#{formula.tap}/#{a}" } valid_alias_names.map! { |a| "#{formula.tap}/#{a}" } end diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index 577924a34..8dfd0d12c 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -47,7 +47,7 @@ BOTTLE_ERB = <<-EOS.freeze <% elsif cellar != BottleSpecification::DEFAULT_CELLAR %> cellar "<%= cellar %>" <% end %> - <% if rebuild > 0 %> + <% if rebuild.positive? %> rebuild <%= rebuild %> <% end %> <% checksums.each do |checksum_type, checksum_values| %> @@ -186,7 +186,7 @@ module Homebrew ohai "Determining #{f.full_name} bottle rebuild..." versions = FormulaVersions.new(f) rebuilds = versions.bottle_version_map("origin/master")[f.pkg_version] - rebuilds.pop if rebuilds.last.to_i > 0 + rebuilds.pop if rebuilds.last.to_i.positive? rebuild = rebuilds.empty? ? 0 : rebuilds.max.to_i + 1 end diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 87a239b98..21abed7d9 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -89,7 +89,7 @@ module Homebrew def check_for_duplicate_pull_requests(formula) pull_requests = fetch_pull_requests(formula) - return unless pull_requests && !pull_requests.empty? + return unless pull_requests&.empty? duplicates_message = <<-EOS.undent These open pull requests may be duplicates: #{pull_requests.map { |pr| "#{pr["title"]} #{pr["html_url"]}" }.join("\n")} diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb index 931cba07f..cd0d6fbd0 100644 --- a/Library/Homebrew/dev-cmd/pull.rb +++ b/Library/Homebrew/dev-cmd/pull.rb @@ -69,7 +69,7 @@ module Homebrew tap = nil ARGV.named.each do |arg| - if arg.to_i > 0 + if arg.to_i.positive? issue = arg url = "https://github.com/Homebrew/homebrew-core/pull/#{arg}" tap = CoreTap.instance -- cgit v1.2.3 From feda0242be174c63925a7e982cc05d6e9748acd8 Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Mon, 25 Sep 2017 23:01:36 -0700 Subject: bump-formula-pr: fix duplicates check `return unless pull_requests && !pull_requests.empty?` and `return unless pull_requests&.empty?` are not equivalent. --- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 21abed7d9..87d8274cc 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -89,7 +89,8 @@ module Homebrew def check_for_duplicate_pull_requests(formula) pull_requests = fetch_pull_requests(formula) - return unless pull_requests&.empty? + return unless pull_requests + return if pull_requests.empty? duplicates_message = <<-EOS.undent These open pull requests may be duplicates: #{pull_requests.map { |pr| "#{pr["title"]} #{pr["html_url"]}" }.join("\n")} -- cgit v1.2.3