From 3923d331dedebb8e1670bb3148b900bf39376e8a Mon Sep 17 00:00:00 2001 From: Mike McQuaid <mike@mikemcquaid.com> Date: Tue, 15 Sep 2020 13:39:06 +0100 Subject: [PATCH] Fix brew style --- Library/.rubocop.yml | 5 +++++ Library/Homebrew/cask/installer.rb | 2 +- Library/Homebrew/diagnostic.rb | 10 ++++----- .../Homebrew/extend/os/mac/extend/ENV/std.rb | 22 +++++++++---------- .../extend/os/mac/extend/ENV/super.rb | 16 +++++++------- Library/Homebrew/os/mac/xquartz.rb | 9 ++++---- Library/Homebrew/test/cask/depends_on_spec.rb | 2 +- 7 files changed, 36 insertions(+), 30 deletions(-) diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index a93407e047..e87f5d9c58 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -194,6 +194,11 @@ Lint/AmbiguousRegexpLiteral: Exclude: - 'Taps/*/*/{Formula/,}*.rb' +# useful for metaprogramming in RSpec +Lint/ConstantDefinitionInBlock: + Exclude: + - '**/*_spec.rb' + # so many of these in formulae and can't be autocorrected Lint/ParenthesesAsGroupedExpression: Exclude: diff --git a/Library/Homebrew/cask/installer.rb b/Library/Homebrew/cask/installer.rb index ccca7637c3..0cbf38eb5f 100644 --- a/Library/Homebrew/cask/installer.rb +++ b/Library/Homebrew/cask/installer.rb @@ -276,7 +276,7 @@ module Cask def x11_dependencies return unless @cask.depends_on.x11 - raise CaskX11DependencyError, @cask.token unless MacOS::X11.installed? + raise CaskX11DependencyError, @cask.token unless MacOS::XQuartz.installed? end def graph_dependencies(cask_or_formula, acc = TopologicalHash.new) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 6d98c8f758..cade2779a7 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -915,11 +915,11 @@ module Homebrew none_string else cask_count = begin - tap.cask_files.count - rescue - error_tap_paths << tap.path - 0 - end + tap.cask_files.count + rescue + error_tap_paths << tap.path + 0 + end "#{tap.path} (#{cask_count} #{"cask".pluralize(cask_count)})" end diff --git a/Library/Homebrew/extend/os/mac/extend/ENV/std.rb b/Library/Homebrew/extend/os/mac/extend/ENV/std.rb index 680d391eef..e6829a57ae 100644 --- a/Library/Homebrew/extend/os/mac/extend/ENV/std.rb +++ b/Library/Homebrew/extend/os/mac/extend/ENV/std.rb @@ -11,25 +11,25 @@ module Stdenv def x11 # There are some config scripts here that should go in the PATH - append_path "PATH", MacOS::X11.bin.to_s + append_path "PATH", MacOS::XQuartz.bin.to_s # Append these to PKG_CONFIG_LIBDIR so they are searched # *after* our own pkgconfig directories, as we dupe some of the # libs in XQuartz. - append_path "PKG_CONFIG_LIBDIR", "#{MacOS::X11.lib}/pkgconfig" - append_path "PKG_CONFIG_LIBDIR", "#{MacOS::X11.share}/pkgconfig" + append_path "PKG_CONFIG_LIBDIR", "#{MacOS::XQuartz.lib}/pkgconfig" + append_path "PKG_CONFIG_LIBDIR", "#{MacOS::XQuartz.share}/pkgconfig" - append "LDFLAGS", "-L#{MacOS::X11.lib}" - append_path "CMAKE_PREFIX_PATH", MacOS::X11.prefix.to_s - append_path "CMAKE_INCLUDE_PATH", MacOS::X11.include.to_s - append_path "CMAKE_INCLUDE_PATH", "#{MacOS::X11.include}/freetype2" + append "LDFLAGS", "-L#{MacOS::XQuartz.lib}" + append_path "CMAKE_PREFIX_PATH", MacOS::XQuartz.prefix.to_s + append_path "CMAKE_INCLUDE_PATH", MacOS::XQuartz.include.to_s + append_path "CMAKE_INCLUDE_PATH", "#{MacOS::XQuartz.include}/freetype2" - append "CPPFLAGS", "-I#{MacOS::X11.include}" - append "CPPFLAGS", "-I#{MacOS::X11.include}/freetype2" + append "CPPFLAGS", "-I#{MacOS::XQuartz.include}" + append "CPPFLAGS", "-I#{MacOS::XQuartz.include}/freetype2" - append_path "ACLOCAL_PATH", "#{MacOS::X11.share}/aclocal" + append_path "ACLOCAL_PATH", "#{MacOS::XQuartz.share}/aclocal" - append "CFLAGS", "-I#{MacOS::X11.include}" unless MacOS::CLT.installed? + append "CFLAGS", "-I#{MacOS::XQuartz.include}" unless MacOS::CLT.installed? end def setup_build_environment(**options) diff --git a/Library/Homebrew/extend/os/mac/extend/ENV/super.rb b/Library/Homebrew/extend/os/mac/extend/ENV/super.rb index 7c5fc78912..6bc4edcc4b 100644 --- a/Library/Homebrew/extend/os/mac/extend/ENV/super.rb +++ b/Library/Homebrew/extend/os/mac/extend/ENV/super.rb @@ -24,7 +24,7 @@ module Superenv def homebrew_extra_paths paths = [] - paths << MacOS::X11.bin.to_s if x11? + paths << MacOS::XQuartz.bin.to_s if x11? paths end @@ -32,13 +32,13 @@ module Superenv def homebrew_extra_pkg_config_paths paths = \ ["/usr/lib/pkgconfig", "#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.version}"] - paths << "#{MacOS::X11.lib}/pkgconfig" << "#{MacOS::X11.share}/pkgconfig" if x11? + paths << "#{MacOS::XQuartz.lib}/pkgconfig" << "#{MacOS::XQuartz.share}/pkgconfig" if x11? paths end def homebrew_extra_aclocal_paths paths = [] - paths << "#{MacOS::X11.share}/aclocal" if x11? + paths << "#{MacOS::XQuartz.share}/aclocal" if x11? paths end @@ -54,7 +54,7 @@ module Superenv paths = [] paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml2" if libxml2_include_needed? paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/apache2" if MacOS::Xcode.without_clt? - paths << MacOS::X11.include.to_s << "#{MacOS::X11.include}/freetype2" if x11? + paths << MacOS::XQuartz.include.to_s << "#{MacOS::XQuartz.include}/freetype2" if x11? paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers" paths end @@ -65,7 +65,7 @@ module Superenv paths << "#{self["HOMEBREW_SDKROOT"]}/usr/lib" paths << Formula["llvm"].opt_lib.to_s end - paths << MacOS::X11.lib.to_s if x11? + paths << MacOS::XQuartz.lib.to_s if x11? paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries" paths end @@ -74,14 +74,14 @@ module Superenv paths = [] paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/libxml2" if libxml2_include_needed? paths << "#{self["HOMEBREW_SDKROOT"]}/usr/include/apache2" if MacOS::Xcode.without_clt? - paths << MacOS::X11.include.to_s << "#{MacOS::X11.include}/freetype2" if x11? + paths << MacOS::XQuartz.include.to_s << "#{MacOS::XQuartz.include}/freetype2" if x11? paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers" paths end def homebrew_extra_cmake_library_paths paths = [] - paths << MacOS::X11.lib.to_s if x11? + paths << MacOS::XQuartz.lib.to_s if x11? paths << "#{self["HOMEBREW_SDKROOT"]}/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries" paths end @@ -102,7 +102,7 @@ module Superenv end def set_x11_env_if_installed - ENV.x11 = MacOS::X11.installed? + ENV.x11 = MacOS::XQuartz.installed? end # @private diff --git a/Library/Homebrew/os/mac/xquartz.rb b/Library/Homebrew/os/mac/xquartz.rb index 76ed06ffd8..889cc13ac0 100644 --- a/Library/Homebrew/os/mac/xquartz.rb +++ b/Library/Homebrew/os/mac/xquartz.rb @@ -2,7 +2,10 @@ module OS module Mac - X11 = XQuartz = Module.new do # rubocop:disable Style/MutableConstant + # Helper module for querying XQuartz information. + # + # @api private + module XQuartz module_function DEFAULT_BUNDLE_PATH = Pathname.new("Applications/Utilities/XQuartz.app").freeze @@ -83,12 +86,10 @@ module OS PKGINFO_VERSION_MAP.fetch(str, str) end - # This should really be private, but for compatibility reasons it must - # remain public. New code should use `MacOS::X11.bin`, `MacOS::X11.lib` and - # `MacOS::X11.include` instead, as that accounts for Xcode-only systems. def prefix @prefix ||= Pathname.new("/opt/X11") if Pathname.new("/opt/X11/lib/libpng.dylib").exist? end + private_class_method :prefix def installed? !version.null? && !prefix.nil? diff --git a/Library/Homebrew/test/cask/depends_on_spec.rb b/Library/Homebrew/test/cask/depends_on_spec.rb index 9be83dac3f..d9424987da 100644 --- a/Library/Homebrew/test/cask/depends_on_spec.rb +++ b/Library/Homebrew/test/cask/depends_on_spec.rb @@ -76,7 +76,7 @@ describe "Satisfy Dependencies and Requirements", :cask do describe "depends_on x11" do before do - allow(MacOS::X11).to receive(:installed?).and_return(x11_installed) + allow(MacOS::XQuartz).to receive(:installed?).and_return(x11_installed) end context "when satisfied" do -- GitLab