From 323ff660fa5c5572266f4ac9b8d46cec8b4c0b15 Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Thu, 11 Feb 2021 13:24:19 +0000 Subject: [PATCH] rubocop: use consistent array/hash indentation --- Library/.rubocop.yml | 6 +++ Library/Homebrew/cask/artifact/installer.rb | 6 +-- Library/Homebrew/cask/dsl.rb | 48 +++++++++---------- Library/Homebrew/cask/dsl/container.rb | 6 +-- Library/Homebrew/cask/dsl/depends_on.rb | 14 +++--- Library/Homebrew/formulary.rb | 10 ++-- Library/Homebrew/metafiles.rb | 6 +-- Library/Homebrew/os/mac/keg.rb | 8 ++-- Library/Homebrew/test/cask/cask_spec.rb | 14 +++--- Library/Homebrew/test/cask/dsl_spec.rb | 20 ++++---- .../Homebrew/test/livecheck/livecheck_spec.rb | 14 +++--- .../Homebrew/test/os/mac/diagnostic_spec.rb | 23 ++++----- Library/Homebrew/unpack_strategy/dmg.rb | 24 +++++----- 13 files changed, 101 insertions(+), 98 deletions(-) diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index 5769367b8a..9fc9c955a1 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -240,6 +240,12 @@ Layout/SpaceAroundOperators: Layout/RescueEnsureAlignment: Enabled: false +# significantly less indentation involved; more consistent +Layout/FirstArrayElementIndentation: + EnforcedStyle: consistent +Layout/FirstHashElementIndentation: + EnforcedStyle: consistent + # favour parens-less DSL-style arguments Lint/AmbiguousBlockAssociation: Enabled: false diff --git a/Library/Homebrew/cask/artifact/installer.rb b/Library/Homebrew/cask/artifact/installer.rb index b9d181d0e7..91ffe92f57 100644 --- a/Library/Homebrew/cask/artifact/installer.rb +++ b/Library/Homebrew/cask/artifact/installer.rb @@ -13,9 +13,9 @@ module Cask # @api private class Installer < AbstractArtifact VALID_KEYS = Set.new([ - :manual, - :script, - ]).freeze + :manual, + :script, + ]).freeze # Extension module for manual installers. module ManualInstaller diff --git a/Library/Homebrew/cask/dsl.rb b/Library/Homebrew/cask/dsl.rb index 3125316274..244ebf38f4 100644 --- a/Library/Homebrew/cask/dsl.rb +++ b/Library/Homebrew/cask/dsl.rb @@ -64,30 +64,30 @@ module Cask ].freeze DSL_METHODS = Set.new([ - :appcast, - :artifacts, - :auto_updates, - :caveats, - :conflicts_with, - :container, - :desc, - :depends_on, - :homepage, - :language, - :languages, - :name, - :sha256, - :staged_path, - :url, - :version, - :appdir, - :discontinued?, - :livecheck, - :livecheckable?, - *ORDINARY_ARTIFACT_CLASSES.map(&:dsl_key), - *ACTIVATABLE_ARTIFACT_CLASSES.map(&:dsl_key), - *ARTIFACT_BLOCK_CLASSES.flat_map { |klass| [klass.dsl_key, klass.uninstall_dsl_key] }, - ]).freeze + :appcast, + :artifacts, + :auto_updates, + :caveats, + :conflicts_with, + :container, + :desc, + :depends_on, + :homepage, + :language, + :languages, + :name, + :sha256, + :staged_path, + :url, + :version, + :appdir, + :discontinued?, + :livecheck, + :livecheckable?, + *ORDINARY_ARTIFACT_CLASSES.map(&:dsl_key), + *ACTIVATABLE_ARTIFACT_CLASSES.map(&:dsl_key), + *ARTIFACT_BLOCK_CLASSES.flat_map { |klass| [klass.dsl_key, klass.uninstall_dsl_key] }, + ]).freeze attr_reader :cask, :token diff --git a/Library/Homebrew/cask/dsl/container.rb b/Library/Homebrew/cask/dsl/container.rb index 852907b32e..a386adab8d 100644 --- a/Library/Homebrew/cask/dsl/container.rb +++ b/Library/Homebrew/cask/dsl/container.rb @@ -10,9 +10,9 @@ module Cask # @api private class Container VALID_KEYS = Set.new([ - :type, - :nested, - ]).freeze + :type, + :nested, + ]).freeze attr_accessor(*VALID_KEYS, :pairs) diff --git a/Library/Homebrew/cask/dsl/depends_on.rb b/Library/Homebrew/cask/dsl/depends_on.rb index ca85b1e44b..26aed28b1f 100644 --- a/Library/Homebrew/cask/dsl/depends_on.rb +++ b/Library/Homebrew/cask/dsl/depends_on.rb @@ -12,13 +12,13 @@ module Cask # @api private class DependsOn < SimpleDelegator VALID_KEYS = Set.new([ - :formula, - :cask, - :macos, - :arch, - :x11, - :java, - ]).freeze + :formula, + :cask, + :macos, + :arch, + :x11, + :java, + ]).freeze VALID_ARCHES = { intel: { type: :intel, bits: 64 }, diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 52f18dbef7..ac62ff0433 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -502,11 +502,11 @@ module Formulary name = name.to_s.downcase taps.map do |tap| Pathname.glob([ - "#{tap}Formula/#{name}.rb", - "#{tap}HomebrewFormula/#{name}.rb", - "#{tap}#{name}.rb", - "#{tap}Aliases/#{name}", - ]).find(&:file?) + "#{tap}Formula/#{name}.rb", + "#{tap}HomebrewFormula/#{name}.rb", + "#{tap}#{name}.rb", + "#{tap}Aliases/#{name}", + ]).find(&:file?) end.compact end end diff --git a/Library/Homebrew/metafiles.rb b/Library/Homebrew/metafiles.rb index 2e4034706d..e7e71963df 100644 --- a/Library/Homebrew/metafiles.rb +++ b/Library/Homebrew/metafiles.rb @@ -8,9 +8,9 @@ module Metafiles LICENSES = Set.new(%w[copying copyright license licence]).freeze # {https://github.com/github/markup#markups} EXTENSIONS = Set.new(%w[ - .adoc .asc .asciidoc .creole .html .markdown .md .mdown .mediawiki .mkdn - .org .pod .rdoc .rst .rtf .textile .txt .wiki - ]).freeze + .adoc .asc .asciidoc .creole .html .markdown .md .mdown .mediawiki .mkdn + .org .pod .rdoc .rst .rtf .textile .txt .wiki + ]).freeze BASENAMES = Set.new(%w[about authors changelog changes history news notes notice readme todo]).freeze module_function diff --git a/Library/Homebrew/os/mac/keg.rb b/Library/Homebrew/os/mac/keg.rb index 039db0b907..901c4dc7ee 100644 --- a/Library/Homebrew/os/mac/keg.rb +++ b/Library/Homebrew/os/mac/keg.rb @@ -58,10 +58,10 @@ class Keg # Try signing again odebug "Codesigning (2nd try) #{file}" result = system_command("codesign", args: [ - "--sign", "-", "--force", - "--preserve-metadata=entitlements,requirements,flags,runtime", - file - ], print_stderr: false) + "--sign", "-", "--force", + "--preserve-metadata=entitlements,requirements,flags,runtime", + file + ], print_stderr: false) return if result.success? # If it fails again, error out diff --git a/Library/Homebrew/test/cask/cask_spec.rb b/Library/Homebrew/test/cask/cask_spec.rb index 2072dff887..26a2032800 100644 --- a/Library/Homebrew/test/cask/cask_spec.rb +++ b/Library/Homebrew/test/cask/cask_spec.rb @@ -9,16 +9,16 @@ describe Cask::Cask, :cask do context "and there are duplicate versions" do it "uses the last unique version" do allow(cask).to receive(:timestamped_versions).and_return([ - ["1.2.2", "0999"], - ["1.2.3", "1000"], - ["1.2.2", "1001"], - ]) + ["1.2.2", "0999"], + ["1.2.3", "1000"], + ["1.2.2", "1001"], + ]) expect(cask).to receive(:timestamped_versions) expect(cask.versions).to eq([ - "1.2.3", - "1.2.2", - ]) + "1.2.3", + "1.2.2", + ]) end end end diff --git a/Library/Homebrew/test/cask/dsl_spec.rb b/Library/Homebrew/test/cask/dsl_spec.rb index cd713b3282..403256248f 100644 --- a/Library/Homebrew/test/cask/dsl_spec.rb +++ b/Library/Homebrew/test/cask/dsl_spec.rb @@ -80,8 +80,8 @@ describe Cask::DSL, :cask do end expect(cask.name).to eq([ - "Proper Name", - ]) + "Proper Name", + ]) end it "Accepts an array value to the name stanza" do @@ -90,9 +90,9 @@ describe Cask::DSL, :cask do end expect(cask.name).to eq([ - "Proper Name", - "Alternate Name", - ]) + "Proper Name", + "Alternate Name", + ]) end it "Accepts multiple name stanzas" do @@ -102,9 +102,9 @@ describe Cask::DSL, :cask do end expect(cask.name).to eq([ - "Proper Name", - "Alternate Name", - ]) + "Proper Name", + "Alternate Name", + ]) end end @@ -497,8 +497,8 @@ describe Cask::DSL, :cask do it "does not include a trailing slash" do config = Cask::Config.new(explicit: { - appdir: "/Applications/", - }) + appdir: "/Applications/", + }) cask = Cask::Cask.new("appdir-trailing-slash", config: config) do binary "#{appdir}/some/path" diff --git a/Library/Homebrew/test/livecheck/livecheck_spec.rb b/Library/Homebrew/test/livecheck/livecheck_spec.rb index 3b5df88553..5bdbfd9aba 100644 --- a/Library/Homebrew/test/livecheck/livecheck_spec.rb +++ b/Library/Homebrew/test/livecheck/livecheck_spec.rb @@ -68,13 +68,13 @@ describe Homebrew::Livecheck do it "returns a hash containing the livecheck status" do expect(livecheck.status_hash(f, "error", ["Unable to get versions"])) .to eq({ - formula: "test", - status: "error", - messages: ["Unable to get versions"], - meta: { - livecheckable: true, - }, - }) + formula: "test", + status: "error", + messages: ["Unable to get versions"], + meta: { + livecheckable: true, + }, + }) end end diff --git a/Library/Homebrew/test/os/mac/diagnostic_spec.rb b/Library/Homebrew/test/os/mac/diagnostic_spec.rb index d8c1436355..e81993cd8f 100644 --- a/Library/Homebrew/test/os/mac/diagnostic_spec.rb +++ b/Library/Homebrew/test/os/mac/diagnostic_spec.rb @@ -84,20 +84,18 @@ describe Homebrew::Diagnostic::Checks do describe "#check_broken_sdks" do it "doesn't trigger when SDK versions are as expected" do allow(OS::Mac).to receive(:sdk_locator).and_return(OS::Mac::CLT.sdk_locator) - allow_any_instance_of(OS::Mac::CLTSDKLocator).to receive(:all_sdks) - .and_return([ - OS::Mac::SDK.new(OS::Mac::Version.new("11"), "/some/path/MacOSX.sdk", :clt), - OS::Mac::SDK.new(OS::Mac::Version.new("10.15"), "/some/path/MacOSX10.15.sdk", :clt), - ]) + allow_any_instance_of(OS::Mac::CLTSDKLocator).to receive(:all_sdks).and_return([ + OS::Mac::SDK.new(OS::Mac::Version.new("11"), "/some/path/MacOSX.sdk", :clt), + OS::Mac::SDK.new(OS::Mac::Version.new("10.15"), "/some/path/MacOSX10.15.sdk", :clt), + ]) expect(checks.check_broken_sdks).to be_nil end it "triggers when the CLT SDK version doesn't match the folder name" do - allow_any_instance_of(OS::Mac::CLTSDKLocator).to receive(:all_sdks) - .and_return([ - OS::Mac::SDK.new(OS::Mac::Version.new("10.14"), "/some/path/MacOSX10.15.sdk", :clt), - ]) + allow_any_instance_of(OS::Mac::CLTSDKLocator).to receive(:all_sdks).and_return([ + OS::Mac::SDK.new(OS::Mac::Version.new("10.14"), "/some/path/MacOSX10.15.sdk", :clt), + ]) expect(checks.check_broken_sdks) .to include("SDKs in your Command Line Tools (CLT) installation do not match the SDK folder names") @@ -105,10 +103,9 @@ describe Homebrew::Diagnostic::Checks do it "triggers when the Xcode SDK version doesn't match the folder name" do allow(OS::Mac).to receive(:sdk_locator).and_return(OS::Mac::Xcode.sdk_locator) - allow_any_instance_of(OS::Mac::XcodeSDKLocator).to receive(:all_sdks) - .and_return([ - OS::Mac::SDK.new(OS::Mac::Version.new("10.14"), "/some/path/MacOSX10.15.sdk", :xcode), - ]) + allow_any_instance_of(OS::Mac::XcodeSDKLocator).to receive(:all_sdks).and_return([ + OS::Mac::SDK.new(OS::Mac::Version.new("10.14"), "/some/path/MacOSX10.15.sdk", :xcode), + ]) expect(checks.check_broken_sdks) .to include("The contents of the SDKs in your Xcode installation do not match the SDK folder names") diff --git a/Library/Homebrew/unpack_strategy/dmg.rb b/Library/Homebrew/unpack_strategy/dmg.rb index 2b04e12d44..5f2fea6825 100644 --- a/Library/Homebrew/unpack_strategy/dmg.rb +++ b/Library/Homebrew/unpack_strategy/dmg.rb @@ -13,18 +13,18 @@ module UnpackStrategy # Helper module for listing the contents of a volume mounted from a disk image. module Bom DMG_METADATA = Set.new(%w[ - .background - .com.apple.timemachine.donotpresent - .com.apple.timemachine.supported - .DocumentRevisions-V100 - .DS_Store - .fseventsd - .MobileBackups - .Spotlight-V100 - .TemporaryItems - .Trashes - .VolumeIcon.icns - ]).freeze + .background + .com.apple.timemachine.donotpresent + .com.apple.timemachine.supported + .DocumentRevisions-V100 + .DS_Store + .fseventsd + .MobileBackups + .Spotlight-V100 + .TemporaryItems + .Trashes + .VolumeIcon.icns + ]).freeze private_constant :DMG_METADATA refine Pathname do