Skip to content
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

Share code between cask token and formula name audits. #17562

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

reitermarkus
Copy link
Member

@reitermarkus reitermarkus commented Jun 25, 2024

  • 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 typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

This relaxes the casks token audit and makes the formula name audit more strict.

# frozen_string_literal: true

module Homebrew
class TokenAuditor
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
class TokenAuditor
class NameAuditor

Thoughts? Token is cask-specific so I think maybe "name" is clearer in this case. NBD though either way

Copy link
Member Author

Choose a reason for hiding this comment

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

name has a different meaning for casks.

Copy link
Member

@Rylan12 Rylan12 Jun 27, 2024

Choose a reason for hiding this comment

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

True, but also token has no meaning for formulae. When I'm speaking about what to call a formula or cask, I use the word "name" and mean Formula#name and Cask#token.

I'll leave it up to other people for their thoughts

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
class TokenAuditor
class FormulaNameCaskTokenAuditor

or something.

I agree TokenAuditor doesn't make sense if it can operate on Formula because they don't have tokens.

Comment on lines +24 to +25
# errors << "underscores" if token.include?("_")
# errors << "plus symbols" if token.include?("+")
Copy link
Member

Choose a reason for hiding this comment

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

Maybe accept the formula or cask itself in the initializer and then check these only if it's a cask?

Copy link
Member Author

Choose a reason for hiding this comment

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

Given we allow _ and + for formula names, I don't really see a good reason to disallow it for casks.

Copy link
Member

Choose a reason for hiding this comment

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

I don't feel strongly at the moment, but the comments should be removed if this is the plan

Copy link
Member Author

@reitermarkus reitermarkus Jun 27, 2024

Choose a reason for hiding this comment

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

Yes, I'll remove the comments before merging. We should check if casks should be renamed/aliased (plus -> +).

@MikeMcQuaid
Copy link
Member

This relaxes the casks token audit and makes the formula name audit more strict.

I think it's nicer to maintain consistency between them both, making/keeping them both stricter.

@reitermarkus
Copy link
Member Author

I think it's nicer to maintain consistency between them both, making/keeping them both stricter.

Can you clarify what you mean here?

@MikeMcQuaid
Copy link
Member

I think it's nicer to maintain consistency between them both, making/keeping them both stricter.

Can you clarify what you mean here?

I'm not sure how to clarify, really! I'm just disagreeing with the sentence here that relaxing the token audit so that it's not consistent with the formula name audit seems like introducing undesirable inconsistency.

@reitermarkus
Copy link
Member Author

reitermarkus commented Jun 26, 2024

relaxing the token audit so that it's not consistent with the formula name audit seems like introducing undesirable inconsistency

The cask token audit is relaxed a bit while the formula name is made more strict, so the end result is they are consistent.

@MikeMcQuaid
Copy link
Member

The cask token audit is relaxed a bit while the formula name is made more strict, so the end result is they are consistent.

Hah, ok, sorry for my misunderstanding then 👍🏻

@reitermarkus reitermarkus marked this pull request as ready for review June 27, 2024 15:27
@reitermarkus reitermarkus changed the title WIP: Share code between cask token and formula name audits. Share code between cask token and formula name audits. Jun 27, 2024
name = formula.name

problem "Formula name '#{name}' must not contain uppercase letters." if name != name.downcase
token_auditor = Homebrew::TokenAuditor.new(name)
unless (errors = token_auditor.errors).empty?
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
unless (errors = token_auditor.errors).empty?
if (errors = token_auditor.errors).any?

or

Suggested change
unless (errors = token_auditor.errors).empty?
if (errors = token_auditor.presence)

# frozen_string_literal: true

module Homebrew
class TokenAuditor
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
class TokenAuditor
class FormulaNameCaskTokenAuditor

or something.

I agree TokenAuditor doesn't make sense if it can operate on Formula because they don't have tokens.

@Rylan12 Rylan12 removed their request for review June 29, 2024 01:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants