rubocops/urls: audit more Apache URLs and autocorrect#21744
rubocops/urls: audit more Apache URLs and autocorrect#21744
Conversation
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Looks good when 🟢!
Might be nice to have some autocorrect tests.
There was a problem hiding this comment.
Pull request overview
This PR expands Homebrew’s URL-auditing RuboCop to recognize more Apache download URL variants and automatically correct them to the recommended closer.lua form.
Changes:
- Broaden Apache URL detection to cover
dlcdn.apache.org,downloads.apache.org,dist.apache.org/repos/dist/release, and additionaldyn/.../mirrors.cgishapes. - Add autocorrection for matched Apache URLs, rewriting them to
https://www.apache.org/dyn/closer.lua?path=.... - Add RSpec coverage for the new Apache URL variants and enable autocorrect support in the
FormulaAudit::Urlscop.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Library/Homebrew/rubocops/shared/url_helper.rb | Extends the Apache URL matching regex and adds autocorrection to closer.lua?path=.... |
| Library/Homebrew/rubocops/urls.rb | Enables AutoCorrector for the FormulaAudit::Urls cop so the new correction block can run. |
| Library/Homebrew/test/rubocops/urls_spec.rb | Adds new specs asserting offenses + corrections for the newly recognized Apache URL forms. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
This PR expands Homebrew’s FormulaAudit/Urls Apache URL auditing to recognize additional Apache download URL variants and introduces an autocorrection to rewrite them to Apache’s recommended closer.lua?path=... form.
Changes:
- Extend Apache URL detection to cover
dlcdn.apache.org,downloads.apache.org,dist.apache.org/repos/dist/release/, and additionaldyn/mirrors.cgi/dyn/closer.cgiURL shapes. - Add autocorrection support to
FormulaAudit/Urlsfor Apache URL offenses. - Add RSpec coverage ensuring offenses are registered and corrected for the newly-detected Apache URL forms.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Library/Homebrew/test/rubocops/urls_spec.rb | Adds tests for Apache URL offense detection and autocorrection. |
| Library/Homebrew/rubocops/urls.rb | Enables autocorrection on the FormulaAudit::Urls cop. |
| Library/Homebrew/rubocops/shared/url_helper.rb | Broadens Apache URL matching and implements autocorrect to closer.lua?path=.... |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
brew lgtm(style, typechecking and tests) with your changes locally?Closer.lua is still the Apache's recommendation and it handles older releases when moved to archive - https://infra.apache.org/release-download-pages.html
PR adds detection for some alternative Apache download URLs:
Also match when URL includes extra parts, e.g. flink-cdc url is
Will need to style fix Homebrew/core formulae first.
Some other ideas for future PRs:
github.com/apache/.../archiveURL. Usually should switch to Apache URL. However, may need an exception for new projects that aren't available on Apache server yet.?path=with/based on https://infra.apache.org/release-download-pages.html#closer