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

audit: Migrate scheme checks for cvs, bzr, hg, fossil and svn+http to Rubocop + add tests #7619

Merged

Conversation

mathaeus
Copy link
Contributor

@mathaeus mathaeus commented May 20, 2020

Migrate scheme checks for cvs, bzr, hg, fossil and svn+http to Rubocop.

Motivated by #7392

  • 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?

@@ -66,6 +66,11 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node)
problem "#{url} should be `https://www.apache.org/dyn/closer.lua?path=#{match[1]}`"
end

version_control_pattern = %r{^(cvs|bzr|hg|fossil)://}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure about where to best put it in this file. Any input appreciated.

Copy link
Member

Choose a reason for hiding this comment

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

This seems fine to me! Alternative would be a VERSION_CONTROL_PATTERN = %r{^(cvs|bzr|hg|fossil)://}.freeze at the class level.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, thanks for pointing out.

Btw, I also tried this, to have all the vcs stuff combined:

version_control_patterns = Regexp.union([%r{^(cvs|bzr|hg|fossil)://}, 
                                         %r{^(svn)\+http://}])
audit_urls(urls, version_control_patterns) do |match, _|
  problem "Use of the #{match[0]} scheme is deprecated, pass `:using => :#{match[1]}` instead"
end

But then the problem is that the matching svn is not contained in match[1], but rather match[2]. I'm not an expert with Regexp.union. Maybe you have an idea to optimize this code :)

Copy link
Member

Choose a reason for hiding this comment

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

Yeh, I've tried and can't find a way to match them consistently unfortunately. Two regex seems fine 👍

Copy link
Member

Choose a reason for hiding this comment

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

I used https://rubular.com for testing in case that's useful to you.

@mathaeus mathaeus changed the title audit: Migrate scheme checks for cvs, bzr, hg and fossil to Rubocop audit: Migrate scheme checks for cvs, bzr, hg and fossil to Rubocop + add tests May 20, 2020
@mathaeus mathaeus force-pushed the migrate_vcs_scheme_checks_to_rubocop branch from 19568f1 to bb9665c Compare May 21, 2020 01:52
@mathaeus mathaeus changed the title audit: Migrate scheme checks for cvs, bzr, hg and fossil to Rubocop + add tests audit: Migrate scheme checks for cvs, bzr, hg, fossil and svn+http to Rubocop + add tests May 21, 2020
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.

Great work again @mathaeus!

@@ -66,6 +66,11 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node)
problem "#{url} should be `https://www.apache.org/dyn/closer.lua?path=#{match[1]}`"
end

version_control_pattern = %r{^(cvs|bzr|hg|fossil)://}
Copy link
Member

Choose a reason for hiding this comment

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

This seems fine to me! Alternative would be a VERSION_CONTROL_PATTERN = %r{^(cvs|bzr|hg|fossil)://}.freeze at the class level.

@MikeMcQuaid MikeMcQuaid merged commit bb44b71 into Homebrew:master May 21, 2020
@mathaeus mathaeus deleted the migrate_vcs_scheme_checks_to_rubocop branch May 21, 2020 15:17
@BrewTestBot BrewTestBot added the outdated PR was locked due to age label Dec 29, 2020
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Dec 29, 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