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
rubocops/cask: Disallow protocol in cask URL verified stanza #14886
rubocops/cask: Disallow protocol in cask URL verified stanza #14886
Conversation
Review period will end on 2023-03-07 at 00:00:00 UTC. |
# typed: true | ||
# frozen_string_literal: true | ||
|
||
require "forwardable" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what this does, I copied and pasted from other cops. 😳
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's meaningless without any use of def_delegator(s)
: https://ruby-doc.org/stdlib-2.5.1/libdoc/forwardable/rdoc/Forwardable.html (which would make a nice cop by itself)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought so, but it's in a few cops that don't make use of def_delegators
either. I guess that's a mistake. One RuboCop at a time for me, though. 😆
@@ -0,0 +1,37 @@ | |||
# typed: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorbet doesn't run successfully. Need to read up on https://sorbet.org/docs/requires-ancestor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading https://blog.appsignal.com/2021/01/13/using-mixins-and-modules-in-your-ruby-on-rails-application.html for a general overview of mixins, and https://sorbet.org/docs/requires-ancestor, I do not understand what it wants me to do. As the person who introduced this requires_ancestor
thing, @dduugg can you shed any light (either here or in Slack)? Have I taken a wrong approach here somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module RuboCop::Cop::Cask::OnUrlStanza
requires_ancestor { RuboCop::Cop::Cask::UrlLegacyCommaSeparators }
end
This code means that any module that includes RuboCop::Cop::Cask::OnUrlStanza
must subclass RuboCop::Cop::Cask::UrlLegacyCommaSeparators
. This makes the methods defined in the latter available in the former. (In this specific case, OnUrlStanza
makes use of on_url_stanza
, the lone method defined in UrlLegacyCommaSeparators
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, so if we now have RuboCop::Cop::Cask::Url
and RuboCop::Cop::Cask::UrlLegacyCommaSeparators
cops that have the on_url_stanza
method , which one should inherit from which? They're separate cops.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured it out!
d2bc47c
to
fb81024
Compare
- Apparently the "verified" parameter in the URL (present when a Cask's download URL is not the same as its homepage) shouldn't have the protocol (`https`, `http`) at the front. - Removing this has happened manually in the past, so here's an autocorrecting RuboCop for it.
fb81024
to
79db987
Compare
- The `on_url_stanza` method is now used in two cops, `Url` and `UrlLegacyCommaSeparators`. Make the latter inherit from the former to make Sorbet happy. - The style and typecheck checks now pass fine.
- I suspect these were copy-pasted from other cops, like I did in Homebrew#14886 (comment). - The "forwardable" require is unnecesary if the cop doesn't `extend Forwardable` and use `def_delegator`. - The "uri" require is unnecessary if the cop doesn't call `URI` methods.
- According to Homebrew/brew#14717 it's wrong to have the protocol in the "verified" part of a Cask URL. So there's now an autocorrecting RuboCop for it at Homebrew/brew#14886. This fixes the singular offense.
- According to Homebrew/brew#14717 it's wrong to have the protocol in the "verified" part of a Cask URL. So there's now an autocorrecting RuboCop for it at Homebrew/brew#14886. This fixes the singular offense.
* Update youdaonote from 7.2.3 to 7.2.4 * youdaonote: Remove protocol from verified stanza - According to Homebrew/brew#14717 it's wrong to have the protocol in the "verified" part of a Cask URL. So there's now an autocorrecting RuboCop for it at Homebrew/brew#14886. This fixes the singular offense. --------- Co-authored-by: Issy Long <me@issyl0.co.uk>
Review period skipped due to |
Thanks again @issyl0! |
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?https
,http
) at the front.It works!