From 819e7aab7be9e4d3086f405dc76d7ea15a167062 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Tue, 23 Jan 2024 23:06:04 +0000 Subject: [PATCH] Teach `brew style` about `docs/.rubocop.yml` - Yes, we have yet another `.rubocop.yml` but in-line exclusions in `` in the Markdown seemed more ugly. - This needed tweaks to `brew style` to make it read the new config file when we're scanning docs. --- .github/workflows/docs.yml | 2 +- Library/Homebrew/style.rb | 2 ++ docs/.rubocop.yml | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 docs/.rubocop.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 81004f9addc00b..8e9e40014a6b20 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -42,7 +42,7 @@ jobs: - name: Check code blocks conform to our Ruby style guide working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }}/docs - run: brew style -- *.md + run: brew style . - name: Build the site and check for broken links working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }}/docs diff --git a/Library/Homebrew/style.rb b/Library/Homebrew/style.rb index 6c8240c0f58f12..6d803d19a8e0c7 100644 --- a/Library/Homebrew/style.rb +++ b/Library/Homebrew/style.rb @@ -126,6 +126,8 @@ def self.run_rubocop(files, output_type, files&.map!(&:expand_path) if files.blank? || files == [HOMEBREW_REPOSITORY] files = [HOMEBREW_LIBRARY_PATH] + elsif files.any? { |f| f.to_s.start_with? HOMEBREW_REPOSITORY/"docs" } + args << "--config" << (HOMEBREW_REPOSITORY/"docs/.rubocop.yml") elsif files.none? { |f| f.to_s.start_with? HOMEBREW_LIBRARY_PATH } args << "--config" << (HOMEBREW_LIBRARY/".rubocop.yml") end diff --git a/docs/.rubocop.yml b/docs/.rubocop.yml new file mode 100644 index 00000000000000..710242f6f6e34a --- /dev/null +++ b/docs/.rubocop.yml @@ -0,0 +1,21 @@ +inherit_from: ../Library/.rubocop.yml + +AllCops: + Exclude: + - Gemfile + - ".mdl*.rb" + - Rakefile + - "_site/**/*" + +# These are included in docs deliberately to show what +# `brew create` does and what the user should replace. +FormulaAudit/Comments: + Enabled: false + +# The bottle block line length is long in its full form. +Layout/LineLength: + Max: 123 + +# Apparently Casks are allowed to have constant definitions in blocks and we document this. +Lint/ConstantDefinitionInBlock: + Enabled: false