From a79dc3e65b52a4ae9a3b3b0d850425d802c01403 Mon Sep 17 00:00:00 2001 From: Misty De Meo Date: Wed, 5 Jul 2017 16:34:59 -0700 Subject: Formula#keg_only should be a boolean --- Library/Homebrew/formula.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 0d000496b..f0b6f70bf 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1008,7 +1008,7 @@ class Formula # rarely, you don't want your library symlinked into the main prefix # see gettext.rb for an example def keg_only? - keg_only_reason && keg_only_reason.valid? + !!keg_only_reason && keg_only_reason.valid? end # @private -- cgit v1.2.3 From 5adca2e33d1beaed60f7f2fb7ce62e46b628c033 Mon Sep 17 00:00:00 2001 From: Misty De Meo Date: Wed, 5 Jul 2017 17:51:57 -0700 Subject: Disable Style/DoubleNegation cop As discussed in bbatsov/rubocop#3344, there are situations where this is the shortest and most idiomatic way to convert a value to a boolean - particularly for checking values which can be nil or truthy. --- Library/Homebrew/.rubocop.yml | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/.rubocop.yml b/Library/Homebrew/.rubocop.yml index 26c944529..4802d4c36 100644 --- a/Library/Homebrew/.rubocop.yml +++ b/Library/Homebrew/.rubocop.yml @@ -33,6 +33,10 @@ Style/BlockDelimiters: Exclude: - '**/*_spec.rb' +# used idiomatically to return boolean values +Style/DoubleNegation: + Enabled: false + # so many of these in formulae but none in here Style/GuardClause: Enabled: true -- cgit v1.2.3 From d9e0a0bce6f76f4c52286b70d39131b8351a7c5e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 7 Jul 2017 09:22:39 +0100 Subject: rubocop.yml: remove doublenegation disable. --- Library/Homebrew/.rubocop.yml | 4 ---- 1 file changed, 4 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/.rubocop.yml b/Library/Homebrew/.rubocop.yml index 4802d4c36..26c944529 100644 --- a/Library/Homebrew/.rubocop.yml +++ b/Library/Homebrew/.rubocop.yml @@ -33,10 +33,6 @@ Style/BlockDelimiters: Exclude: - '**/*_spec.rb' -# used idiomatically to return boolean values -Style/DoubleNegation: - Enabled: false - # so many of these in formulae but none in here Style/GuardClause: Enabled: true -- cgit v1.2.3 From fa031f5045f262974a439fe82a92479c9ccb6901 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 7 Jul 2017 09:23:31 +0100 Subject: formula: tweak keg_only? formatting. --- Library/Homebrew/formula.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index f0b6f70bf..da375d8a7 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1008,7 +1008,8 @@ class Formula # rarely, you don't want your library symlinked into the main prefix # see gettext.rb for an example def keg_only? - !!keg_only_reason && keg_only_reason.valid? + return false unless keg_only_reason + keg_only_reason.valid? end # @private -- cgit v1.2.3