Skip to content

Commit

Permalink
Merge pull request #14920 from issyl0/rubocop-block-delimiters
Browse files Browse the repository at this point in the history
rubocop: Clean up `Style/BlockDelimiters` excludes and autofix offenses
  • Loading branch information
MikeMcQuaid authored Mar 9, 2023
2 parents b3c9b49 + 3a83b54 commit 4bf55c6
Show file tree
Hide file tree
Showing 117 changed files with 729 additions and 733 deletions.
2 changes: 0 additions & 2 deletions Library/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,6 @@ Style/BarePercentLiterals:
Style/BlockDelimiters:
BracesRequiredMethods:
- "sig"
Exclude:
- "Homebrew/**/*_spec.rb"

# Use consistent style for better readability.
Style/CollectionMethods:
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/test/ENV_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
it "ensures the environment is restored" do
before = subject.dup

expect {
expect do
subject.with_build_environment do
subject["foo"] = "bar"
raise StandardError
end
}.to raise_error(StandardError)
end.to raise_error(StandardError)

expect(subject["foo"]).to be_nil
expect(subject).to eq(before)
Expand Down
8 changes: 4 additions & 4 deletions Library/Homebrew/test/api/cask_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def mock_curl_download(stdout:)
end

describe "::all_casks" do
let(:casks_json) {
let(:casks_json) do
<<~EOS
[{
"token": "foo",
Expand All @@ -32,13 +32,13 @@ def mock_curl_download(stdout:)
"url": "https://brew.sh/bar"
}]
EOS
}
let(:casks_hash) {
end
let(:casks_hash) do
{
"foo" => { "url" => "https://brew.sh/foo" },
"bar" => { "url" => "https://brew.sh/bar" },
}
}
end

it "returns the expected cask JSON list" do
mock_curl_download stdout: casks_json
Expand Down
12 changes: 6 additions & 6 deletions Library/Homebrew/test/api/formula_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def mock_curl_download(stdout:)
end

describe "::all_formulae" do
let(:formulae_json) {
let(:formulae_json) do
<<~EOS
[{
"name": "foo",
Expand All @@ -37,21 +37,21 @@ def mock_curl_download(stdout:)
"aliases": []
}]
EOS
}
let(:formulae_hash) {
end
let(:formulae_hash) do
{
"foo" => { "url" => "https://brew.sh/foo", "aliases" => ["foo-alias1", "foo-alias2"] },
"bar" => { "url" => "https://brew.sh/bar", "aliases" => ["bar-alias"] },
"baz" => { "url" => "https://brew.sh/baz", "aliases" => [] },
}
}
let(:formulae_aliases) {
end
let(:formulae_aliases) do
{
"foo-alias1" => "foo",
"foo-alias2" => "foo",
"bar-alias" => "bar",
}
}
end

it "returns the expected formula JSON list" do
mock_curl_download stdout: formulae_json
Expand Down
8 changes: 4 additions & 4 deletions Library/Homebrew/test/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ def mock_curl_download(stdout:)

it "raises an error if the JSON file is invalid" do
mock_curl_download stdout: json_invalid
expect {
expect do
described_class.fetch_json_api_file("baz.json", target: cache_dir/"baz.json")
}.to raise_error(SystemExit)
end.to raise_error(SystemExit)
end
end

Expand All @@ -78,9 +78,9 @@ def mock_curl_download(stdout:)

it "raises an error if the file does not exist" do
mock_curl_output success: false
expect {
expect do
described_class.fetch_homebrew_cask_source("bar", git_head: "master")
}.to raise_error(ArgumentError, /No valid file found/)
end.to raise_error(ArgumentError, /No valid file found/)
end
end
end
4 changes: 2 additions & 2 deletions Library/Homebrew/test/bottle_filename_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
describe "::create" do
subject { described_class.create(f, :tag, 0) }

let(:f) {
let(:f) do
formula do
url "https://brew.sh/foo.tar.gz"
version "1.0"
end
}
end

its(:to_s) { is_expected.to eq "formula_name--1.0.tag.bottle.tar.gz" }
end
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/test/cache_store_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
cache_store = instance_double(described_class, "cache_store", write_if_dirty!: nil)
expect(described_class).to receive(:new).with(type).and_return(cache_store)
expect(cache_store).to receive(:write_if_dirty!)
described_class.use(type) { |_db|
described_class.use(type) do |_db|
# do nothing
}
end
end
end

Expand Down
8 changes: 4 additions & 4 deletions Library/Homebrew/test/cask/artifact/alt_target_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
describe "activate to alternate target" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-alt-target")) }

let(:install_phase) {
let(:install_phase) do
cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact|
artifact.install_phase(command: NeverSudoSystemCommand, force: false)
end
}
end

let(:source_path) { cask.staged_path.join("Caffeine.app") }
let(:target_path) { cask.config.appdir.join("AnotherName.app") }
Expand All @@ -29,15 +29,15 @@
end

describe "when app is in a subdirectory" do
let(:cask) {
let(:cask) do
Cask::Cask.new("subdir") do
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage "https://brew.sh/local-caffeine"
version "1.2.3"
sha256 "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94"
app "subdir/Caffeine.app", target: "AnotherName.app"
end
}
end

it "installs the given apps using the proper target directory" do
appsubdir = cask.staged_path.join("subdir").tap(&:mkpath)
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/test/cask/artifact/app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
end

describe "when app is in a subdirectory" do
let(:cask) {
let(:cask) do
Cask::Cask.new("subdir") do
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
homepage "https://brew.sh/local-caffeine"
version "1.2.3"
sha256 "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94"
app "subdir/Caffeine.app"
end
}
end

it "installs the given app using the proper target directory" do
appsubdir = cask.staged_path.join("subdir").tap(&:mkpath)
Expand Down
24 changes: 12 additions & 12 deletions Library/Homebrew/test/cask/artifact/binary_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# frozen_string_literal: true

describe Cask::Artifact::Binary, :cask do
let(:cask) {
let(:cask) do
Cask::CaskLoader.load(cask_path("with-binary")).tap do |cask|
InstallHelper.install_without_artifacts(cask)
end
}
end
let(:artifacts) { cask.artifacts.select { |a| a.is_a?(described_class) } }
let(:binarydir) { cask.config.binarydir }
let(:expected_path) { binarydir.join("binary") }
Expand All @@ -21,9 +21,9 @@
end

context "when --no-binaries is specified" do
let(:cask) {
let(:cask) do
Cask::CaskLoader.load(cask_path("with-binary"))
}
end

it "doesn't link the binary when --no-binaries is specified" do
Cask::Installer.new(cask, binaries: false).install
Expand All @@ -41,11 +41,11 @@
end

context "when the binary is not executable" do
let(:cask) {
let(:cask) do
Cask::CaskLoader.load(cask_path("with-non-executable-binary")).tap do |cask|
InstallHelper.install_without_artifacts(cask)
end
}
end

let(:expected_path) { cask.config.binarydir.join("naked_non_executable") }

Expand All @@ -65,23 +65,23 @@
it "avoids clobbering an existing binary by linking over it" do
FileUtils.touch expected_path

expect {
expect do
artifacts.each do |artifact|
artifact.install_phase(command: NeverSudoSystemCommand, force: false)
end
}.to raise_error(Cask::CaskError)
end.to raise_error(Cask::CaskError)

expect(expected_path).not_to be :symlink?
end

it "avoids clobbering an existing symlink" do
expected_path.make_symlink("/tmp")

expect {
expect do
artifacts.each do |artifact|
artifact.install_phase(command: NeverSudoSystemCommand, force: false)
end
}.to raise_error(Cask::CaskError)
end.to raise_error(Cask::CaskError)

expect(File.readlink(expected_path)).to eq("/tmp")
end
Expand All @@ -97,11 +97,11 @@
end

context "when the binary is inside an app package" do
let(:cask) {
let(:cask) do
Cask::CaskLoader.load(cask_path("with-embedded-binary")).tap do |cask|
InstallHelper.install_without_artifacts(cask)
end
}
end

it "links the binary to the proper directory" do
cask.artifacts.select { |a| a.is_a?(Cask::Artifact::App) }.each do |artifact|
Expand Down
20 changes: 10 additions & 10 deletions Library/Homebrew/test/cask/artifact/generic_artifact_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
describe Cask::Artifact::Artifact, :cask do
let(:cask) { Cask::CaskLoader.load(cask_path("with-generic-artifact")) }

let(:install_phase) {
let(:install_phase) do
lambda do
cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact|
artifact.install_phase(command: NeverSudoSystemCommand, force: false)
end
end
}
end

let(:source_path) { cask.staged_path.join("Caffeine.app") }
let(:target_path) { cask.config.appdir.join("Caffeine.app") }
Expand All @@ -21,25 +21,25 @@

context "without target" do
it "fails to load" do
expect {
expect do
Cask::CaskLoader.load(cask_path("invalid/invalid-generic-artifact-no-target"))
}.to raise_error(Cask::CaskInvalidError, /Generic Artifact.*requires.*target/)
end.to raise_error(Cask::CaskInvalidError, /Generic Artifact.*requires.*target/)
end
end

context "with relative target" do
it "does not fail to load" do
expect {
expect do
Cask::CaskLoader.load(cask_path("generic-artifact-relative-target"))
}.not_to raise_error
end.not_to raise_error
end
end

context "with user-relative target" do
it "does not fail to load" do
expect {
expect do
Cask::CaskLoader.load(cask_path("generic-artifact-user-relative-target"))
}.not_to raise_error
end.not_to raise_error
end
end

Expand All @@ -53,9 +53,9 @@
it "avoids clobbering an existing artifact" do
target_path.mkpath

expect {
expect do
install_phase.call
}.to raise_error(Cask::CaskError)
end.to raise_error(Cask::CaskError)

expect(source_path).to be_a_directory
expect(target_path).to be_a_directory
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/test/cask/artifact/installer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
let(:args) { { manual: "installer" } }

it "shows a message prompting to run the installer manually" do
expect {
expect do
installer.install_phase(command: command)
}.to output(%r{run the installer at:\s+#{staged_path}/installer}).to_stdout
end.to output(%r{run the installer at:\s+#{staged_path}/installer}).to_stdout
end
end

Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/test/cask/artifact/manpage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
end

context "with install" do
let(:install_phase) {
let(:install_phase) do
lambda do
cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact|
artifact.install_phase(command: NeverSudoSystemCommand, force: false)
end
end
}
end

let(:source_path) { cask.staged_path.join("manpage.1") }
let(:target_path) { cask.config.manpagedir.join("man1/manpage.1") }
Expand Down
8 changes: 4 additions & 4 deletions Library/Homebrew/test/cask/artifact/suite_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
describe Cask::Artifact::Suite, :cask do
let(:cask) { Cask::CaskLoader.load(cask_path("with-suite")) }

let(:install_phase) {
let(:install_phase) do
lambda do
cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact|
artifact.install_phase(command: NeverSudoSystemCommand, force: false)
end
end
}
end

let(:target_path) { cask.config.appdir.join("Caffeine") }
let(:source_path) { cask.staged_path.join("Caffeine") }
Expand All @@ -28,9 +28,9 @@
it "avoids clobbering an existing suite by moving over it" do
target_path.mkpath

expect {
expect do
install_phase.call
}.to raise_error(Cask::CaskError)
end.to raise_error(Cask::CaskError)

expect(source_path).to be_a_directory
expect(target_path).to be_a_directory
Expand Down
Loading

0 comments on commit 4bf55c6

Please sign in to comment.