From 3b79b4d079742052863860c8b090f1632eb3b21a Mon Sep 17 00:00:00 2001
From: "L. E. Segovia" <13498015+amyspark@users.noreply.github.com>
Date: Sat, 24 Nov 2018 11:21:52 +0000
Subject: [PATCH] More styling fixes

---
 Library/Homebrew/cask/audit.rb |  4 ++--
 Library/Homebrew/utils/curl.rb | 13 +++++++------
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb
index 097e2d8711..39933bbfff 100644
--- a/Library/Homebrew/cask/audit.rb
+++ b/Library/Homebrew/cask/audit.rb
@@ -322,7 +322,7 @@ module Cask
 
     def check_https_availability
       return unless download
-      unless cask.url.blank? || cask.url.using
+      if !cask.url.blank? && !cask.url.using
         check_url_for_https_availability(cask.url, user_agents: [cask.url.user_agent])
       end
       check_url_for_https_availability(cask.appcast) unless cask.appcast.blank?
@@ -331,7 +331,7 @@ module Cask
 
     def check_url_for_https_availability(url_to_check, user_agents: [:default])
       problem = curl_check_http_content(url_to_check.to_s, user_agents: user_agents)
-      add_error problem unless problem.nil?
+      add_error problem if problem
     end
   end
 end
diff --git a/Library/Homebrew/utils/curl.rb b/Library/Homebrew/utils/curl.rb
index 343e8a125f..8492b23587 100644
--- a/Library/Homebrew/utils/curl.rb
+++ b/Library/Homebrew/utils/curl.rb
@@ -116,8 +116,9 @@ def curl_check_http_content(url, user_agents: [:default], check_content: false,
   file_match = details[:file_hash] == secure_details[:file_hash]
 
   if (etag_match || content_length_match || file_match) &&
-     secure_details[:final_url].start_with?("https://")
-    return "The URL #{url} should use HTTPS rather than HTTP" if url.start_with?("http://")
+     secure_details[:final_url].start_with?("https://") &&
+     url.start_with?("http://")
+    return "The URL #{url} should use HTTPS rather than HTTP"
   end
 
   return unless check_content
@@ -128,8 +129,9 @@ def curl_check_http_content(url, user_agents: [:default], check_content: false,
 
   # Check for the same content after removing all protocols
   if (details[:file] == secure_details[:file]) &&
-     secure_details[:final_url].start_with?("https://")
-    return "The URL #{url} should use HTTPS rather than HTTP" if url.start_with?("http://")
+     secure_details[:final_url].start_with?("https://") &&
+     url.start_with?("http://")
+    return "The URL #{url} should use HTTPS rather than HTTP"
   end
 
   return unless strict
@@ -157,8 +159,7 @@ def curl_http_content_headers_and_checksum(url, hash_needed: false, user_agent:
   while status_code == :unknown || status_code.to_s.start_with?("3")
     headers, _, output = output.partition("\r\n\r\n")
     status_code = headers[%r{HTTP\/.* (\d+)}, 1]
-    location = headers[/^Location:\s*(.*)$/i, 1]
-    final_url = location.chomp if location
+    final_url = headers[/^Location:\s*(.*)$/i, 1]&.chomp
   end
 
   output_hash = Digest::SHA256.digest(output) if hash_needed
-- 
GitLab