Brew: description audit stopped working

Created on 8 Oct 2017  路  14Comments  路  Source: Homebrew/brew

  • [x] Confirmed this is a problem with running a brew command and not brew installing or the post-install behaviour of one or more formulae? If it's a formulae-specific problem please file this issue at the relevant tap e.g. for Homebrew/homebrew-core https://github.com/Homebrew/homebrew-core/issues/new
  • [x] Ran brew update and retried your prior step?
  • [x] Ran brew doctor, fixed all issues and retried your prior step?
  • [x] Ran brew config and brew doctor and included their output with your issue?

To help us debug your issue please explain:

  • What you were trying to do (and why)
    Run brew audit --strict or brew audit --new-formula on formulae with one or more desc violations because we like to enforce pedantry.

  • What happened (include command output)
    The command output nothing because no violation is detected.

  • What you expected to happen
    Sufficient complaining to cause someone to consider fixing the description.

  • Step-by-step reproduction instructions (by running brew commands)
    Add a bad description to any formula and run brew audit --strict on it.

iMac-TMP:Homebrew joe$ brew config
HOMEBREW_VERSION: 1.3.4-100-g5cbf8bd
ORIGIN: https://github.com/Homebrew/brew
HEAD: 5cbf8bdaa7ff080948618d7f3f62f8be2f72ef97
Last commit: 12 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 085acb040b35fc8db4ccec5f2073509ce0871386
Core tap last commit: 30 minutes ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local/Homebrew
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: octa-core 64-bit skylake
Homebrew Ruby: 2.3.3 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/bin/ruby
Clang: 8.0 build 800
Git: 2.10.1 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Perl: /usr/bin/perl
Python: /usr/bin/python
Ruby: /usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
Java: 1.8.0_121, 1.7.0_154-zulu-7.20.0.3
macOS: 10.11.6-x86_64
Xcode: 8.2.1
CLT: 8.2.0.0.1.1480973914
X11: 2.7.11 => /opt/X11
iMac-TMP:Homebrew joe$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: The filesystem on / appears to be case-sensitive.
The default macOS filesystem is case-insensitive. Please report any apparent problems.
iMac-TMP:homebrew-core joe$ git diff -- Formula/wget.rb
diff --git a/Formula/wget.rb b/Formula/wget.rb
index 0a7ae63..92490ca 100644
--- a/Formula/wget.rb
+++ b/Formula/wget.rb
@@ -1,7 +1,7 @@
 # NOTE: Configure will fail if using awk 20110810 from dupes.
 # Upstream issue: https://savannah.gnu.org/bugs/index.php?37063
 class Wget < Formula
-  desc "Internet file retriever"
+  desc "An Any-to-PostScript filter asjagasgasjagasgasjagasgasjagasgasjagasgasjagasgasjagasgasjagasgasjagasgasjagasgasjagasgasjagasgasjagasgasjagasgasjagasgasjagasg"
   homepage "https://www.gnu.org/software/wget/"
   url "https://ftp.gnu.org/gnu/wget/wget-1.19.1.tar.gz"
   mirror "https://ftpmirror.gnu.org/wget/wget-1.19.1.tar.gz"
iMac-TMP:homebrew-core joe$ brew audit --strict wget
iMac-TMP:homebrew-core joe$

git bisect leads me to 9eb51db400261545822c8c03c2e9d587d70e8ad0 as the first bad commit.

iMac-TMP:Homebrew joe$ git bisect bad
9eb51db400261545822c8c03c2e9d587d70e8ad0 is the first bad commit
commit 9eb51db400261545822c8c03c2e9d587d70e8ad0
Author: Mike McQuaid <[email protected]>
Date:   Sun Sep 24 19:10:57 2017 +0100

    Rubocop 0.50 and target 2.3.

:040000 040000 7e98e5993eeca9eb1960aa7e6fbe5b1eca726b5b 38ad8af98332b43176282241df9c5a866ae258b1 M    Library

CC @MikeMcQuaid

bug

Most helpful comment

It's been a while since something has been more pedantic than me.

:rofl:

All 14 comments

It's pretty strange brew tests didn't catch this.

Can confirm that flipping it back to the prior rubocop version with no other code changes resolves this issue:

HOMEBREW_RUBOCOP_VERSION = "0.49.1"

I _think_ something is failing with the parameters(desc_call).first call in the new rubocop. As soon as that's called everything seems to fall flat on its face:

diff --git a/Library/Homebrew/rubocops/formula_desc_cop.rb b/Library/Homebrew/rubocops/formula_desc_cop.rb
index 2b613c9b4..64477f9e5 100644
--- a/Library/Homebrew/rubocops/formula_desc_cop.rb
+++ b/Library/Homebrew/rubocops/formula_desc_cop.rb
@@ -20,12 +20,8 @@ module RuboCop

           # Check if a formula's desc is too long
           desc = parameters(desc_call).first
-          desc_length = "#{@formula_name}: #{string_content(desc)}".length
-          max_desc_length = 80
-          return if desc_length <= max_desc_length
           problem <<-EOS.undent
-            Description is too long. "name: desc" should be less than #{max_desc_length} characters.
-            Length is calculated as #{@formula_name} + desc. (currently #{desc_length})
+            This is the desc: #{desc}
           EOS
         end
       end
=> brew audit --new-formula a2ps
a2ps:
  * New formulae should not require patches to build. Patches should be submitted and accepted upstream first.
Error: 1 problem in 1 formula

It's possible all the parameters(<xyz>).first usages are borked, actually.

I can add option "32-bit" back into a2ps and run brew audit --new-formula a2ps and it doesn't complain, and that's a whole different cop, obviously. Same deal with duplicating the url as a mirror which should be complained about because of this.

@DomT4 yeah we'll probably have to re-run audit on everything once this is fixed to make sure nothing slipped through.

@DomT4 looks like https://github.com/Homebrew/brew/pull/3284 fixes this.

Aye. The completely silent failure is just super 馃槗. Hopefully not too much has slipped through the gate before it was noticed, and before a fix can be stuck in place.

@DomT4 looks like #3284 fixes this.

Can confirm this locally. It correctly flags all the things I deliberately borked:

a2ps:
  * C: 2: col 3: Description is too long. "name: desc" should be less than 80 characters.
    Length is calculated as a2ps + desc. (currently 162)
  * C: 2: col 9: Description shouldn't start with an indefinite article i.e. "An"
  * C: 5: col 3: URL should not be duplicated as a mirror: https://ftp.gnu.org/gnu/a2ps/a2ps-4.14.tar.gz
  * C: 21: col 3: Options should begin with with/without. Migrate '--32-bit' with `deprecated_option`.
  * C: 21: col 11: macOS has been 64-bit only since 10.6 so 32-bit options are deprecated.
  * C: 40: col 12: xcodebuild should be passed an explicit "SYMROOT"
  * New formulae should not require patches to build. Patches should be submitted and accepted upstream first.
Error: 7 problems in 1 formula

Closed via #3284.

馃憤. It's not related to this, but it feels weird that we treat desc "" as a perfectly valid desc. Stumbled into that testing earlier.

lol well at least it's very concise :roll_eyes:

Thanks for the help troubleshooting this @DomT4 :heart:

lol well at least it's very concise

If anyone's particularly fussed something like:

diff --git a/Library/Homebrew/rubocops/formula_desc_cop.rb b/Library/Homebrew/rubocops/formula_desc_cop.rb
index 2b613c9b4..d9e84453d 100644
--- a/Library/Homebrew/rubocops/formula_desc_cop.rb
+++ b/Library/Homebrew/rubocops/formula_desc_cop.rb
@@ -18,14 +18,20 @@ module RuboCop
             return
           end

-          # Check if a formula's desc is too long
+          # Check formula desc length. Ensure desc isn't an empty
+          # string & that it doesn't exceed 80 characters.
           desc = parameters(desc_call).first
-          desc_length = "#{@formula_name}: #{string_content(desc)}".length
+          pure_desc_length = string_content(desc).length
+          if pure_desc_length.zero?
+            problem "For dog's sake"
+          end
+
+          named_desc_length = "#{@formula_name}: #{string_content(desc)}".length
           max_desc_length = 80
           return if desc_length <= max_desc_length
           problem <<-EOS.undent
             Description is too long. "name: desc" should be less than #{max_desc_length} characters.
-            Length is calculated as #{@formula_name} + desc. (currently #{desc_length})
+            Length is calculated as #{@formula_name} + desc. (currently #{named_desc_length})
           EOS
         end
       end

does the job. I threw that together in about 20 seconds so I'm sure it can be about 200% neater.

Thanks for the help troubleshooting this @DomT4 鉂わ笍

No worries at all! 鉂わ笍. Always happy to poke around. They're making me learn Python3 at the moment so always a pleasure to get to spend time around Ruby again 馃槈.

They're making me learn Python3 at the moment

Isn't that some form of abuse?

Isn't that some form of abuse?

It's _so much fussier_ than Python2. It's been a while since something has been more pedantic than me.

It's been a while since something has been more pedantic than me.

:rofl:

Was this page helpful?
0 / 5 - 0 ratings