
- Fixing the test expected output was unbelievably tedious. - There's been debate about this setting being `false` but in https://github.com/Homebrew/brew/pull/15136#issuecomment-1500063225 we decided that it was worth using the default since RuboCop behaviour changed so we'd have had to do some horrible things to keep it as `false` - https://github.com/Homebrew/brew/pull/15136#issuecomment-1500037278 - and multiple maintainers specify the `--display-cop-names` option to `brew style` themselves since it's clearer what's gone wrong.
48 lines
1.3 KiB
Ruby
48 lines
1.3 KiB
Ruby
# typed: false
|
|
# frozen_string_literal: true
|
|
|
|
require "rubocops/caveats"
|
|
|
|
describe RuboCop::Cop::FormulaAudit::Caveats do
|
|
subject(:cop) { described_class.new }
|
|
|
|
context "when auditing `caveats`" do
|
|
it "reports an offense if `setuid` is mentioned" do
|
|
expect_offense(<<~RUBY)
|
|
class Foo < Formula
|
|
homepage "https://brew.sh/foo"
|
|
url "https://brew.sh/foo-1.0.tgz"
|
|
def caveats
|
|
"setuid"
|
|
^^^^^^^^ FormulaAudit/Caveats: Don't recommend setuid in the caveats, suggest sudo instead.
|
|
end
|
|
end
|
|
RUBY
|
|
end
|
|
|
|
it "reports an offense if an escape character is present" do
|
|
expect_offense(<<~RUBY)
|
|
class Foo < Formula
|
|
homepage "https://brew.sh/foo"
|
|
url "https://brew.sh/foo-1.0.tgz"
|
|
def caveats
|
|
"\\x1B"
|
|
^^^^^^ FormulaAudit/Caveats: Don't use ANSI escape codes in the caveats.
|
|
end
|
|
end
|
|
RUBY
|
|
|
|
expect_offense(<<~RUBY)
|
|
class Foo < Formula
|
|
homepage "https://brew.sh/foo"
|
|
url "https://brew.sh/foo-1.0.tgz"
|
|
def caveats
|
|
"\\u001b"
|
|
^^^^^^^^ FormulaAudit/Caveats: Don't use ANSI escape codes in the caveats.
|
|
end
|
|
end
|
|
RUBY
|
|
end
|
|
end
|
|
end
|