Skip to content

livecheck: add RuboCops #8643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 17, 2020
Merged

livecheck: add RuboCops #8643

merged 2 commits into from
Sep 17, 2020

Conversation

nandahkrishna
Copy link
Member

@nandahkrishna nandahkrishna commented Sep 8, 2020

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew tests with your changes locally?

This PR creates an audit and adds RuboCops for livecheck.

Audit

Check whether livecheck is able to find versions (doesn't error out) for formulae with livecheck blocks defined.

RuboCops

  1. Ensure that skipped formulae do not have additional livecheck information such as url, regex, etc.
  2. Ensure that a url is provided.
  3. Ensure that a formula URL is referenced by a symbol (:head, :stable, :homepage).
  4. Ensure that regexes contain \.t and not \.tgz or \.tar\.gz, etc.
  5. Ensure that a regex is provided for strategy :page_match.
  6. Ensure that regexes are case-insensitive (except formulae in allowlist).
  7. Ensure that the regex is enclosed within parentheses.

I haven'[t included the cop for counting number of capturing groups – I wasn't able to write a regex that was able to do this, and I couldn't find a method/function to count capturing groups without matching.

The regex for the extension checking needs to be verified. Here's a more convoluted version I wrote that matches all possible tar extensions (I think): https://rubular.com/r/d5uJPJIONM63VE

It is possible that I've missed some important points in this PR description, but I will answer any questions as they arise. Looking forward to your reviews and suggestions everyone. Thanks!

CC @samford

Sorry, something went wrong.

@nandahkrishna
Copy link
Member Author

Ah, I'd forgotten to mention: CI is 🔴 because of some recent updates to livecheck URLs in homebrew/core, which violate a cop this PR introduces. I'll create a PR to fix those issues.

@nandahkrishna
Copy link
Member Author

nandahkrishna commented Sep 13, 2020

With the latest commit, some changes have been made:

  • livecheck_formula now accepts a hash containing the arguments (for the args parameter), and this is converted into an OpenStruct to be able to access the arguments via methods. As a result the LivecheckArgs class I'd earlier added is no longer required.

  • Fixed spelling/comment error(s) and incorporated review suggestions.

@nandahkrishna
Copy link
Member Author

The tests I added pass locally (brew tests --online --only dev-cmd/audit), but this failure seems to be related to the general issue of livecheck network tests not working on CI. If it's okay, I'll remove that particular test alone for now, and add it once we've arrived at a solution for the failures.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nits but otherwise looks great, nice work!

@nandahkrishna
Copy link
Member Author

I've made all the changes @MikeMcQuaid, let me know if this is good to merge. I'll create a separate PR to address the livecheck puts suggestion and audit.

@nandahkrishna nandahkrishna changed the title livecheck: add audit and RuboCops livecheck: add RuboCops Sep 17, 2020
@nandahkrishna nandahkrishna merged commit 4393df8 into Homebrew:master Sep 17, 2020
@nandahkrishna nandahkrishna deleted the livecheck-rubocop branch September 17, 2020 14:39
@BrewTestBot BrewTestBot added the outdated PR was locked due to age label Dec 11, 2020
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Dec 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants