<commit_before># typed: false
# frozen_string_literal: true

require "rubocops/options"

describe RuboCop::Cop::FormulaAudit::Options do
  subject(:cop) { described_class.new }

  context "When auditing options" do
    it "reports an offense when using the 32-bit option" do
      expect_offense(<<~RUBY)
        class Foo < Formula
          url 'https://brew.sh/foo-1.0.tgz'
          option "with-32-bit"
                       ^^^^^^ macOS has been 64-bit only since 10.6 so 32-bit options are deprecated.
        end
      RUBY
    end

    it "with universal" do
      expect_offense(<<~RUBY)
        class Foo < Formula
          url 'https://brew.sh/foo-1.0.tgz'
          option :universal
          ^^^^^^^^^^^^^^^^^ macOS has been 64-bit only since 10.6 so universal options are deprecated.
        end
      RUBY
    end

    it "with bad option names" do
      expect_offense(<<~RUBY)
        class Foo < Formula
          url 'https://brew.sh/foo-1.0.tgz'
          option :cxx11
          option "examples", "with-examples"
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Options should begin with with/without. Migrate '--examples' with `deprecated_option`.
        end
      RUBY
    end

    it "with without-check option name" do
      expect_offense(<<~RUBY)
        class Foo < Formula
          url 'https://brew.sh/foo-1.0.tgz'
          option "without-check"
          ^^^^^^^^^^^^^^^^^^^^^^ Use '--without-test' instead of '--without-check'. Migrate '--without-check' with `deprecated_option`.
        end
      RUBY
    end

    it "with deprecated_optionss" do
      expect_offense(<<~RUBY, "/homebrew-core/")
        class Foo < Formula
          url 'https://brew.sh/foo-1.0.tgz'
          deprecated_option "examples" => "with-examples"
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Formulae in homebrew/core should not use `deprecated_option`.
        end
      RUBY
    end

    it "with options" do
      expect_offense(<<~RUBY, "/homebrew-core/")
        class Foo < Formula
          url 'https://brew.sh/foo-1.0.tgz'<commit_msg>rubocops/options: use rubocop v1 API<commit_after># typed: false
# frozen_string_literal: true

require "rubocops/options"

describe RuboCop::Cop::FormulaAudit::Options do
  subject(:cop) { described_class.new }

  context "When auditing options" do
    it "reports an offense when using the 32-bit option" do
      expect_offense(<<~RUBY)
        class Foo < Formula
          url 'https://brew.sh/foo-1.0.tgz'
          option "with-32-bit"
                 ^^^^^^^^^^^^^ macOS has been 64-bit only since 10.6 so 32-bit options are deprecated.
        end
      RUBY
    end

    it "reports an offense when using `:universal`" do
      expect_offense(<<~RUBY)
        class Foo < Formula
          url 'https://brew.sh/foo-1.0.tgz'
          option :universal
          ^^^^^^^^^^^^^^^^^ macOS has been 64-bit only since 10.6 so universal options are deprecated.
        end
      RUBY
    end

    it "reports an offense when using bad option names" do
      expect_offense(<<~RUBY)
        class Foo < Formula
          url 'https://brew.sh/foo-1.0.tgz'
          option :cxx11
          option "examples", "with-examples"
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Options should begin with with/without. Migrate '--examples' with `deprecated_option`.
        end
      RUBY
    end

    it "reports an offense when using `without-check` option names" do
      expect_offense(<<~RUBY)
        class Foo < Formula
          url 'https://brew.sh/foo-1.0.tgz'
          option "without-check"
          ^^^^^^^^^^^^^^^^^^^^^^ Use '--without-test' instead of '--without-check'. Migrate '--without-check' with `deprecated_option`.
        end
      RUBY
    end

    it "reports an offense when using `deprecated_option` in homebrew/core" do
      expect_offense(<<~RUBY, "/homebrew-core/")
        class Foo < Formula
          url 'https://brew.sh/foo-1.0.tgz'
          deprecated_option "examples" => "with-examples"
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Formulae in homebrew/core should not use `deprecated_option`.
        end
      RUBY
    end

    it "reports an offense when using `option` in homebrew/core" do
      expect_offense(<<~RUBY, "/homebrew-core/")
        class Foo < Formula
          url 'https://brew.sh/foo-1.0.tgz'
{'fraction_non_alphanumeric': 0.15813739050253572, 'fraction_numerical': 0.014061779621945597, 'mean_word_length': 2.2428998505231688, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 5, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6605029', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1297, 'n_words': 361}