Merge pull request #14877 from issyl0/rubocop-layout/multiline-method-indentation
rubocop: Enable `Layout/MultilineMethodCallIndentation` & fix offenses
This commit is contained in:
commit
984e8d1503
@ -10,11 +10,6 @@ Homebrew/MoveToExtendOS:
|
|||||||
- "{extend,test,requirements}/**/*"
|
- "{extend,test,requirements}/**/*"
|
||||||
- "os.rb"
|
- "os.rb"
|
||||||
|
|
||||||
# make rspec formatting more flexible
|
|
||||||
Layout/MultilineMethodCallIndentation:
|
|
||||||
Exclude:
|
|
||||||
- "**/*_spec.rb"
|
|
||||||
|
|
||||||
Naming/PredicateName:
|
Naming/PredicateName:
|
||||||
AllowedMethods:
|
AllowedMethods:
|
||||||
- is_32_bit?
|
- is_32_bit?
|
||||||
|
@ -232,10 +232,9 @@ describe Cask::Cask, :cask do
|
|||||||
context "when loaded from json file" do
|
context "when loaded from json file" do
|
||||||
it "returns expected hash" do
|
it "returns expected hash" do
|
||||||
expect(Homebrew::API::Cask).not_to receive(:fetch_source)
|
expect(Homebrew::API::Cask).not_to receive(:fetch_source)
|
||||||
hash = Cask::CaskLoader::FromAPILoader
|
hash = Cask::CaskLoader::FromAPILoader.new(
|
||||||
.new("everything", from_json: JSON.parse(expected_json))
|
"everything", from_json: JSON.parse(expected_json)
|
||||||
.load(config: nil)
|
).load(config: nil).to_h
|
||||||
.to_h
|
|
||||||
|
|
||||||
expect(hash).to be_a(Hash)
|
expect(hash).to be_a(Hash)
|
||||||
expect(JSON.pretty_generate(hash)).to eq(expected_json)
|
expect(JSON.pretty_generate(hash)).to eq(expected_json)
|
||||||
|
@ -28,7 +28,8 @@ describe Cask::Cmd::Install, :cask do
|
|||||||
it "recognizes the --appdir flag" do
|
it "recognizes the --appdir flag" do
|
||||||
appdir = mktmpdir
|
appdir = mktmpdir
|
||||||
|
|
||||||
expect(Cask::CaskLoader).to receive(:load).with("local-caffeine", any_args)
|
expect(Cask::CaskLoader).to receive(:load)
|
||||||
|
.with("local-caffeine", any_args)
|
||||||
.and_wrap_original { |f, *args|
|
.and_wrap_original { |f, *args|
|
||||||
caffeine = f.call(*args)
|
caffeine = f.call(*args)
|
||||||
expect(caffeine.config.appdir).to eq appdir
|
expect(caffeine.config.appdir).to eq appdir
|
||||||
@ -41,7 +42,8 @@ describe Cask::Cmd::Install, :cask do
|
|||||||
it "recognizes the --appdir flag from HOMEBREW_CASK_OPTS" do
|
it "recognizes the --appdir flag from HOMEBREW_CASK_OPTS" do
|
||||||
appdir = mktmpdir
|
appdir = mktmpdir
|
||||||
|
|
||||||
expect(Cask::CaskLoader).to receive(:load).with("local-caffeine", any_args)
|
expect(Cask::CaskLoader).to receive(:load)
|
||||||
|
.with("local-caffeine", any_args)
|
||||||
.and_wrap_original { |f, *args|
|
.and_wrap_original { |f, *args|
|
||||||
caffeine = f.call(*args)
|
caffeine = f.call(*args)
|
||||||
expect(caffeine.config.appdir).to eq appdir
|
expect(caffeine.config.appdir).to eq appdir
|
||||||
@ -57,7 +59,8 @@ describe Cask::Cmd::Install, :cask do
|
|||||||
global_appdir = mktmpdir
|
global_appdir = mktmpdir
|
||||||
appdir = mktmpdir
|
appdir = mktmpdir
|
||||||
|
|
||||||
expect(Cask::CaskLoader).to receive(:load).with("local-caffeine", any_args)
|
expect(Cask::CaskLoader).to receive(:load)
|
||||||
|
.with("local-caffeine", any_args)
|
||||||
.and_wrap_original { |f, *args|
|
.and_wrap_original { |f, *args|
|
||||||
caffeine = f.call(*args)
|
caffeine = f.call(*args)
|
||||||
expect(caffeine.config.appdir).to eq appdir
|
expect(caffeine.config.appdir).to eq appdir
|
||||||
|
@ -41,14 +41,16 @@ describe CompilerSelector do
|
|||||||
|
|
||||||
it "returns gcc-6 if gcc formula offers gcc-6 on mac", :needs_macos do
|
it "returns gcc-6 if gcc formula offers gcc-6 on mac", :needs_macos do
|
||||||
software_spec.fails_with(:clang)
|
software_spec.fails_with(:clang)
|
||||||
allow(Formulary).to receive(:factory).with("gcc")
|
allow(Formulary).to receive(:factory)
|
||||||
|
.with("gcc")
|
||||||
.and_return(instance_double(Formula, version: Version.new("6.0")))
|
.and_return(instance_double(Formula, version: Version.new("6.0")))
|
||||||
expect(selector.compiler).to eq("gcc-6")
|
expect(selector.compiler).to eq("gcc-6")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns gcc-5 if gcc formula offers gcc-5 on linux", :needs_linux do
|
it "returns gcc-5 if gcc formula offers gcc-5 on linux", :needs_linux do
|
||||||
software_spec.fails_with(:clang)
|
software_spec.fails_with(:clang)
|
||||||
allow(Formulary).to receive(:factory).with("gcc@11")
|
allow(Formulary).to receive(:factory)
|
||||||
|
.with("gcc@11")
|
||||||
.and_return(instance_double(Formula, version: Version.new("5.0")))
|
.and_return(instance_double(Formula, version: Version.new("5.0")))
|
||||||
expect(selector.compiler).to eq("gcc-5")
|
expect(selector.compiler).to eq("gcc-5")
|
||||||
end
|
end
|
||||||
@ -57,7 +59,8 @@ describe CompilerSelector do
|
|||||||
software_spec.fails_with(:clang)
|
software_spec.fails_with(:clang)
|
||||||
software_spec.fails_with(gcc: "5")
|
software_spec.fails_with(gcc: "5")
|
||||||
software_spec.fails_with(gcc: "7")
|
software_spec.fails_with(gcc: "7")
|
||||||
allow(Formulary).to receive(:factory).with("gcc@11")
|
allow(Formulary).to receive(:factory)
|
||||||
|
.with("gcc@11")
|
||||||
.and_return(instance_double(Formula, version: Version.new("5.0")))
|
.and_return(instance_double(Formula, version: Version.new("5.0")))
|
||||||
expect(selector.compiler).to eq("gcc-6")
|
expect(selector.compiler).to eq("gcc-6")
|
||||||
end
|
end
|
||||||
@ -65,7 +68,8 @@ describe CompilerSelector do
|
|||||||
it "returns gcc-7 if gcc formula offers gcc-5 and fails with gcc <= 6 on linux", :needs_linux do
|
it "returns gcc-7 if gcc formula offers gcc-5 and fails with gcc <= 6 on linux", :needs_linux do
|
||||||
software_spec.fails_with(:clang)
|
software_spec.fails_with(:clang)
|
||||||
software_spec.fails_with(:gcc) { version "6" }
|
software_spec.fails_with(:gcc) { version "6" }
|
||||||
allow(Formulary).to receive(:factory).with("gcc@11")
|
allow(Formulary).to receive(:factory)
|
||||||
|
.with("gcc@11")
|
||||||
.and_return(instance_double(Formula, version: Version.new("5.0")))
|
.and_return(instance_double(Formula, version: Version.new("5.0")))
|
||||||
expect(selector.compiler).to eq("gcc-7")
|
expect(selector.compiler).to eq("gcc-7")
|
||||||
end
|
end
|
||||||
|
@ -86,6 +86,8 @@ describe "brew bottle" do
|
|||||||
system "git", "commit", "-m", "testball 0.1"
|
system "git", "commit", "-m", "testball 0.1"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# RuboCop would align the `.and` with `.to_stdout` which is too floaty.
|
||||||
|
# rubocop:disable Layout/MultilineMethodCallIndentation
|
||||||
expect {
|
expect {
|
||||||
brew "bottle",
|
brew "bottle",
|
||||||
"--merge",
|
"--merge",
|
||||||
@ -105,6 +107,7 @@ describe "brew bottle" do
|
|||||||
EOS
|
EOS
|
||||||
.and not_to_output.to_stderr
|
.and not_to_output.to_stderr
|
||||||
.and be_a_success
|
.and be_a_success
|
||||||
|
# rubocop:enable Layout/MultilineMethodCallIndentation
|
||||||
|
|
||||||
expect((core_tap.path/"Formula/testball.rb").read).to eq <<~EOS
|
expect((core_tap.path/"Formula/testball.rb").read).to eq <<~EOS
|
||||||
class Testball < Formula
|
class Testball < Formula
|
||||||
@ -153,6 +156,8 @@ describe "brew bottle" do
|
|||||||
system "git", "commit", "-m", "testball 0.1"
|
system "git", "commit", "-m", "testball 0.1"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# RuboCop would align the `.and` with `.to_stdout` which is too floaty.
|
||||||
|
# rubocop:disable Layout/MultilineMethodCallIndentation
|
||||||
expect {
|
expect {
|
||||||
brew "bottle",
|
brew "bottle",
|
||||||
"--merge",
|
"--merge",
|
||||||
@ -172,6 +177,7 @@ describe "brew bottle" do
|
|||||||
EOS
|
EOS
|
||||||
.and not_to_output.to_stderr
|
.and not_to_output.to_stderr
|
||||||
.and be_a_success
|
.and be_a_success
|
||||||
|
# rubocop:enable Layout/MultilineMethodCallIndentation
|
||||||
|
|
||||||
expect((core_tap.path/"Formula/testball.rb").read).to eq <<~EOS
|
expect((core_tap.path/"Formula/testball.rb").read).to eq <<~EOS
|
||||||
class Testball < Formula
|
class Testball < Formula
|
||||||
@ -218,6 +224,8 @@ describe "brew bottle" do
|
|||||||
system "git", "commit", "-m", "testball 0.1"
|
system "git", "commit", "-m", "testball 0.1"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# RuboCop would align the `.and` with `.to_stdout` which is too floaty.
|
||||||
|
# rubocop:disable Layout/MultilineMethodCallIndentation
|
||||||
expect {
|
expect {
|
||||||
brew "bottle",
|
brew "bottle",
|
||||||
"--merge",
|
"--merge",
|
||||||
@ -239,6 +247,7 @@ describe "brew bottle" do
|
|||||||
EOS
|
EOS
|
||||||
.and not_to_output.to_stderr
|
.and not_to_output.to_stderr
|
||||||
.and be_a_success
|
.and be_a_success
|
||||||
|
# rubocop:enable Layout/MultilineMethodCallIndentation
|
||||||
|
|
||||||
expect((core_tap.path/"Formula/testball.rb").read).to eq <<~EOS
|
expect((core_tap.path/"Formula/testball.rb").read).to eq <<~EOS
|
||||||
class Testball < Formula
|
class Testball < Formula
|
||||||
|
@ -20,7 +20,8 @@ describe CurlGitHubPackagesDownloadStrategy do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "calls curl with anonymous authentication headers" do
|
it "calls curl with anonymous authentication headers" do
|
||||||
expect(strategy).to receive(:system_command).with(
|
expect(strategy).to receive(:system_command)
|
||||||
|
.with(
|
||||||
/curl/,
|
/curl/,
|
||||||
hash_including(args: array_including_cons("--header", "Authorization: Bearer QQ==")),
|
hash_including(args: array_including_cons("--header", "Authorization: Bearer QQ==")),
|
||||||
)
|
)
|
||||||
@ -34,7 +35,8 @@ describe CurlGitHubPackagesDownloadStrategy do
|
|||||||
let(:authorization) { "Bearer dead-beef-cafe" }
|
let(:authorization) { "Bearer dead-beef-cafe" }
|
||||||
|
|
||||||
it "calls curl with the provided header value" do
|
it "calls curl with the provided header value" do
|
||||||
expect(strategy).to receive(:system_command).with(
|
expect(strategy).to receive(:system_command)
|
||||||
|
.with(
|
||||||
/curl/,
|
/curl/,
|
||||||
hash_including(args: array_including_cons("--header", "Authorization: #{authorization}")),
|
hash_including(args: array_including_cons("--header", "Authorization: #{authorization}")),
|
||||||
)
|
)
|
||||||
|
@ -29,7 +29,8 @@ describe CurlPostDownloadStrategy do
|
|||||||
}
|
}
|
||||||
|
|
||||||
it "adds the appropriate curl args" do
|
it "adds the appropriate curl args" do
|
||||||
expect(strategy).to receive(:system_command).with(
|
expect(strategy).to receive(:system_command)
|
||||||
|
.with(
|
||||||
/curl/,
|
/curl/,
|
||||||
hash_including(args: array_including_cons("-d", "form=data").and(array_including_cons("-d", "is=good"))),
|
hash_including(args: array_including_cons("-d", "form=data").and(array_including_cons("-d", "is=good"))),
|
||||||
)
|
)
|
||||||
@ -44,7 +45,8 @@ describe CurlPostDownloadStrategy do
|
|||||||
let(:specs) { { using: :post } }
|
let(:specs) { { using: :post } }
|
||||||
|
|
||||||
it "adds the appropriate curl args" do
|
it "adds the appropriate curl args" do
|
||||||
expect(strategy).to receive(:system_command).with(
|
expect(strategy).to receive(:system_command)
|
||||||
|
.with(
|
||||||
/curl/,
|
/curl/,
|
||||||
hash_including(args: array_including_cons("-X", "POST")),
|
hash_including(args: array_including_cons("-X", "POST")),
|
||||||
)
|
)
|
||||||
|
@ -42,7 +42,8 @@ describe CurlDownloadStrategy do
|
|||||||
let(:specs) { { user_agent: "Mozilla/25.0.1" } }
|
let(:specs) { { user_agent: "Mozilla/25.0.1" } }
|
||||||
|
|
||||||
it "adds the appropriate curl args" do
|
it "adds the appropriate curl args" do
|
||||||
expect(strategy).to receive(:system_command).with(
|
expect(strategy).to receive(:system_command)
|
||||||
|
.with(
|
||||||
/curl/,
|
/curl/,
|
||||||
hash_including(args: array_including_cons("--user-agent", "Mozilla/25.0.1")),
|
hash_including(args: array_including_cons("--user-agent", "Mozilla/25.0.1")),
|
||||||
)
|
)
|
||||||
@ -59,7 +60,8 @@ describe CurlDownloadStrategy do
|
|||||||
let(:specs) { { user_agent: :fake } }
|
let(:specs) { { user_agent: :fake } }
|
||||||
|
|
||||||
it "adds the appropriate curl args" do
|
it "adds the appropriate curl args" do
|
||||||
expect(strategy).to receive(:system_command).with(
|
expect(strategy).to receive(:system_command)
|
||||||
|
.with(
|
||||||
/curl/,
|
/curl/,
|
||||||
hash_including(args: array_including_cons(
|
hash_including(args: array_including_cons(
|
||||||
"--user-agent",
|
"--user-agent",
|
||||||
@ -84,7 +86,8 @@ describe CurlDownloadStrategy do
|
|||||||
}
|
}
|
||||||
|
|
||||||
it "adds the appropriate curl args and does not URL-encode the cookies" do
|
it "adds the appropriate curl args and does not URL-encode the cookies" do
|
||||||
expect(strategy).to receive(:system_command).with(
|
expect(strategy).to receive(:system_command)
|
||||||
|
.with(
|
||||||
/curl/,
|
/curl/,
|
||||||
hash_including(args: array_including_cons("-b", "coo=k/e;mon=ster")),
|
hash_including(args: array_including_cons("-b", "coo=k/e;mon=ster")),
|
||||||
)
|
)
|
||||||
@ -99,7 +102,8 @@ describe CurlDownloadStrategy do
|
|||||||
let(:specs) { { referer: "https://somehost/also" } }
|
let(:specs) { { referer: "https://somehost/also" } }
|
||||||
|
|
||||||
it "adds the appropriate curl args" do
|
it "adds the appropriate curl args" do
|
||||||
expect(strategy).to receive(:system_command).with(
|
expect(strategy).to receive(:system_command)
|
||||||
|
.with(
|
||||||
/curl/,
|
/curl/,
|
||||||
hash_including(args: array_including_cons("-e", "https://somehost/also")),
|
hash_including(args: array_including_cons("-e", "https://somehost/also")),
|
||||||
)
|
)
|
||||||
@ -116,9 +120,12 @@ describe CurlDownloadStrategy do
|
|||||||
let(:specs) { { headers: ["foo", "bar"] } }
|
let(:specs) { { headers: ["foo", "bar"] } }
|
||||||
|
|
||||||
it "adds the appropriate curl args" do
|
it "adds the appropriate curl args" do
|
||||||
expect(strategy).to receive(:system_command).with(
|
expect(strategy).to receive(:system_command)
|
||||||
|
.with(
|
||||||
/curl/,
|
/curl/,
|
||||||
hash_including(args: array_including_cons("--header", "foo").and(array_including_cons("--header", "bar"))),
|
hash_including(
|
||||||
|
args: array_including_cons("--header", "foo").and(array_including_cons("--header", "bar")),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.at_least(:once)
|
.at_least(:once)
|
||||||
.and_return(instance_double(SystemCommand::Result, success?: true, stdout: "", assert_success!: nil))
|
.and_return(instance_double(SystemCommand::Result, success?: true, stdout: "", assert_success!: nil))
|
||||||
@ -132,7 +139,8 @@ describe CurlDownloadStrategy do
|
|||||||
|
|
||||||
context "with an asset hosted under example.com" do
|
context "with an asset hosted under example.com" do
|
||||||
it "leaves the URL unchanged" do
|
it "leaves the URL unchanged" do
|
||||||
expect(strategy).to receive(:system_command).with(
|
expect(strategy).to receive(:system_command)
|
||||||
|
.with(
|
||||||
/curl/,
|
/curl/,
|
||||||
hash_including(args: array_including_cons(url)),
|
hash_including(args: array_including_cons(url)),
|
||||||
)
|
)
|
||||||
@ -149,7 +157,8 @@ describe CurlDownloadStrategy do
|
|||||||
let(:status) { instance_double(Process::Status, success?: true, exitstatus: 0) }
|
let(:status) { instance_double(Process::Status, success?: true, exitstatus: 0) }
|
||||||
|
|
||||||
it "rewrites the URL correctly" do
|
it "rewrites the URL correctly" do
|
||||||
expect(strategy).to receive(:system_command).with(
|
expect(strategy).to receive(:system_command)
|
||||||
|
.with(
|
||||||
/curl/,
|
/curl/,
|
||||||
hash_including(args: array_including_cons("#{artifact_domain}/#{resource_path}")),
|
hash_including(args: array_including_cons("#{artifact_domain}/#{resource_path}")),
|
||||||
)
|
)
|
||||||
@ -166,7 +175,8 @@ describe CurlDownloadStrategy do
|
|||||||
let(:status) { instance_double(Process::Status, success?: true, exitstatus: 0) }
|
let(:status) { instance_double(Process::Status, success?: true, exitstatus: 0) }
|
||||||
|
|
||||||
it "rewrites the URL correctly" do
|
it "rewrites the URL correctly" do
|
||||||
expect(strategy).to receive(:system_command).with(
|
expect(strategy).to receive(:system_command)
|
||||||
|
.with(
|
||||||
/curl/,
|
/curl/,
|
||||||
hash_including(args: array_including_cons("#{artifact_domain}/#{resource_path}")),
|
hash_including(args: array_including_cons("#{artifact_domain}/#{resource_path}")),
|
||||||
)
|
)
|
||||||
|
@ -191,7 +191,8 @@ describe Resource do
|
|||||||
fn = instance_double(Pathname, file?: true, basename: "foo")
|
fn = instance_double(Pathname, file?: true, basename: "foo")
|
||||||
checksum = resource.sha256(TEST_SHA256)
|
checksum = resource.sha256(TEST_SHA256)
|
||||||
|
|
||||||
expect(fn).to receive(:verify_checksum).with(checksum)
|
expect(fn).to receive(:verify_checksum)
|
||||||
|
.with(checksum)
|
||||||
.and_raise(ChecksumMismatchError.new(fn, checksum, Object.new))
|
.and_raise(ChecksumMismatchError.new(fn, checksum, Object.new))
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
|
@ -10,7 +10,8 @@ describe User do
|
|||||||
|
|
||||||
describe "#gui?" do
|
describe "#gui?" do
|
||||||
before do
|
before do
|
||||||
allow(SystemCommand).to receive(:run).with("who", any_args)
|
allow(SystemCommand).to receive(:run)
|
||||||
|
.with("who", any_args)
|
||||||
.and_return([who_output, "", instance_double(Process::Status, success?: true)])
|
.and_return([who_output, "", instance_double(Process::Status, success?: true)])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user