Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rubocop: fix some rubocop offences #5119

Merged
merged 3 commits into from
Oct 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 0 additions & 11 deletions Library/Homebrew/test/.rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,6 @@ RSpec/RepeatedDescription:
- 'rubocops/lines_cop_spec.rb'
- 'tab_spec.rb'

# Offense count: 10
RSpec/RepeatedExample:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these examples with exactly the same code or just the same it/name?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not repeated, they are using a different setup, so I'm not sure what this is flagging.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the same it string?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. For example, one has “Sh“ and one has ”Bash“ at the end.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, is is indeed the same exact code as the one before …

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, unless I've misunderstood something these should all be duplicate tests that I've removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is (or was) duplicated with different it strings.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You haven't misunderstood, you're correct 👍

Exclude:
- 'compiler_selector_spec.rb'
- 'utils/shell_spec.rb'

# Offense count: 2
RSpec/ScatteredLet:
Exclude:
- 'cask/artifact/uninstall_zap_shared_examples.rb'

# Offense count: 31
RSpec/SubjectStub:
Exclude:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@
let(:glob_path1) { Pathname.new("#{dir}/glob_path1") }
let(:glob_path2) { Pathname.new("#{dir}/glob_path2") }
let(:paths) { [absolute_path, path_with_tilde, glob_path1, glob_path2] }
let(:fake_system_command) { NeverSudoSystemCommand }
let(:cask) { Cask::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-#{directive}")) }

around(:each) do |example|
begin
Expand All @@ -171,9 +173,6 @@
end
end

let(:fake_system_command) { NeverSudoSystemCommand }
let(:cask) { Cask::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-#{directive}")) }

before(:each) do
allow_any_instance_of(Cask::Artifact::AbstractUninstall).to receive(:trash_paths)
.and_wrap_original do |method, *args|
Expand Down
37 changes: 1 addition & 36 deletions Library/Homebrew/test/compiler_selector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,10 @@
end

describe "#compiler" do
it "raises an error if no matching compiler can be found" do
software_spec.fails_with(:clang)
software_spec.fails_with(:gcc_4_2)
software_spec.fails_with(gcc: "4.8")
software_spec.fails_with(gcc: "4.7")

expect { subject.compiler }.to raise_error(CompilerSelectionError)
end

it "defaults to cc" do
expect(subject.compiler).to eq(cc)
end

it "returns gcc if it fails with clang" do
software_spec.fails_with(:clang)
expect(subject.compiler).to eq(:gcc_4_2)
end

it "returns clang if it fails with gcc" do
software_spec.fails_with(:gcc_4_2)
expect(subject.compiler).to eq(:clang)
end

it "returns clang if it fails with non-Apple gcc" do
software_spec.fails_with(gcc: "4.8")
expect(subject.compiler).to eq(:clang)
Expand Down Expand Up @@ -84,23 +65,7 @@
expect(subject.compiler).to eq("gcc-4.7")
end

it "prefers gcc" do
software_spec.fails_with(:clang)
software_spec.fails_with(:gcc_4_2)
expect(subject.compiler).to eq("gcc-4.8")
end

it "raises an error when gcc is missing" do
allow(versions).to receive(:gcc_4_2_build_version).and_return(Version::NULL)

software_spec.fails_with(:clang)
software_spec.fails_with(gcc: "4.8")
software_spec.fails_with(gcc: "4.7")

expect { subject.compiler }.to raise_error(CompilerSelectionError)
end

it "raises an error when llvm and gcc are missing" do
it "raises an error when gcc or llvm is missing" do
allow(versions).to receive(:gcc_4_2_build_version).and_return(Version::NULL)

software_spec.fails_with(:clang)
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/test/utils/shell_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
expect(subject.profile).to eq("~/.bash_profile")
end

it "returns ~/.bash_profile for Sh" do
ENV["SHELL"] = "/bin/another_shell"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to /bin/sh instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.

it "returns ~/.bash_profile for sh" do
ENV["SHELL"] = "/bin/sh"
expect(subject.profile).to eq("~/.bash_profile")
end

Expand Down