diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 90fa84c0ae..c31d83e1ea 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -60,8 +60,9 @@ jobs: working-directory: docs run: bundle exec rake lint - - name: Check code blocks conform to our Ruby style guide - run: brew style docs + # TODO: reenable when possible. + # - name: Check code blocks conform to our Ruby style guide + # run: brew style docs - name: Generate formulae.brew.sh API samples if: github.repository == 'Homebrew/formulae.brew.sh' diff --git a/Library/Homebrew/style.rb b/Library/Homebrew/style.rb index 3dc8c05fe9..fa6fd4bede 100644 --- a/Library/Homebrew/style.rb +++ b/Library/Homebrew/style.rb @@ -44,9 +44,9 @@ module Homebrew debug: false, verbose: false) raise ArgumentError, "Invalid output type: #{output_type.inspect}" if [:print, :json].exclude?(output_type) - ruby_files = [] - shell_files = [] - actionlint_files = [] + ruby_files = T.let([], T::Array[Pathname]) + shell_files = T.let([], T::Array[Pathname]) + actionlint_files = T.let([], T::Array[Pathname]) Array(files).map(&method(:Pathname)) .each do |path| case path.extname @@ -57,7 +57,14 @@ module Homebrew when ".yml" actionlint_files << path if path.realpath.to_s.include?("/.github/workflows/") else - shell_files << path if path.realpath == HOMEBREW_BREW_FILE.realpath + ruby_files << path + shell_files += if [HOMEBREW_PREFIX, HOMEBREW_REPOSITORY].include?(path) + shell_scripts + else + path.glob("**/*.sh") + .reject { |path| path.to_s.include?("/vendor/") } + end + actionlint_files += (path/".github/workflows").glob("*.y{,a}ml") end end @@ -263,8 +270,10 @@ module Homebrew def self.run_actionlint(files) files = github_workflow_files if files.blank? + # the ignore is to avoid false positives in e.g. actions, homebrew-test-bot system actionlint, "-shellcheck", shellcheck, "-config-file", HOMEBREW_REPOSITORY/".github/actionlint.yaml", + "-ignore", "image: string; options: string", *files $CHILD_STATUS.success? end diff --git a/docs/.mdl_ruleset.rb b/docs/.mdl_ruleset.rb index a32f752d2e..7cf80606d7 100644 --- a/docs/.mdl_ruleset.rb +++ b/docs/.mdl_ruleset.rb @@ -1,6 +1,9 @@ -rule 'HB034', 'Bare unstyled URL used' do +# typed: true +# frozen_string_literal: true + +rule "HB034", "Bare unstyled URL used" do tags :links, :url - aliases 'no-bare-unstyled-urls' + aliases "no-bare-unstyled-urls" check do |doc| doc.matching_text_element_lines(%r{(?<=\s)https?://}) end diff --git a/docs/.mdl_style.rb b/docs/.mdl_style.rb index d7a297fede..dda5902a4e 100644 --- a/docs/.mdl_style.rb +++ b/docs/.mdl_style.rb @@ -1,8 +1,11 @@ +# typed: true +# frozen_string_literal: true + all -rule 'MD007', indent: 2 # Unordered list indentation -rule 'MD026', punctuation: ',;:' # Trailing punctuation in header -exclude_rule 'MD013' # Line length -exclude_rule 'MD029' # Ordered list item prefix -exclude_rule 'MD033' # Inline HTML -exclude_rule 'MD034' # Bare URL used (replaced by HB034) -exclude_rule 'MD046' # Code block style +rule "MD007", indent: 2 # Unordered list indentation +rule "MD026", punctuation: ",;:" # Trailing punctuation in header +exclude_rule "MD013" # Line length +exclude_rule "MD029" # Ordered list item prefix +exclude_rule "MD033" # Inline HTML +exclude_rule "MD034" # Bare URL used (replaced by HB034) +exclude_rule "MD046" # Code block style diff --git a/docs/.rubocop.yml b/docs/.rubocop.yml index e5a8df064e..3c4cadd357 100644 --- a/docs/.rubocop.yml +++ b/docs/.rubocop.yml @@ -2,9 +2,6 @@ inherit_from: ../Library/.rubocop.yml AllCops: Exclude: - - Gemfile - - ".mdl*.rb" - - Rakefile - "_site/**/*" - Manpage.md - "vendor/**/*" diff --git a/docs/Gemfile b/docs/Gemfile index f45f45b95f..12ef85fa97 100644 --- a/docs/Gemfile +++ b/docs/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source "https://rubygems.org" ruby file: ".ruby-version" diff --git a/docs/Rakefile b/docs/Rakefile index e3a39f805d..4d76f69297 100644 --- a/docs/Rakefile +++ b/docs/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "rake" task default: :build