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

rubocops/lines: require a comment for skip_clean #18002

Closed
wants to merge 1 commit into from

Conversation

branchvincent
Copy link
Member

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

Related to the discussion in Homebrew/homebrew-core#176257, I didn't realize we expected skip_clean to be documented with a comment. This formalizes that requirement into an audit, scoped only to homebrew/core.

Copy link
Member

@issyl0 issyl0 left a comment

Choose a reason for hiding this comment

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

💪🏻 Thanks!

method_comment = processed_source.comments.find do |comment|
(method.loc.line - comment.loc.line).abs <= 1
end
return unless method_comment.nil?
Copy link
Member

Choose a reason for hiding this comment

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

nit, unless nil confuses me :-)

Suggested change
return unless method_comment.nil?
return if method_comment.present?

Copy link
Member

Choose a reason for hiding this comment

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

Or

Suggested change
return unless method_comment.nil?
return if !method_comment.nil?

Copy link
Member

Choose a reason for hiding this comment

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

I prefer the prior or the existing version to the second.

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.

One optional style nit from @issyl0 and should be good to go, thanks @branchvincent!

@Homebrew/core @Homebrew/maintainers any thoughts on other DSL elements that should always have a comment above them?

@p-linnane
Copy link
Member

Off the top of my head: patches should have an explanation of what they fix and when they can be removed.

@Bo98
Copy link
Member

Bo98 commented Aug 12, 2024

Yeah patches is something I campaigned on every PR while back to have comments to the point it seems to be common maintainer knowledge now.

Other cases are largely situational. E.g. if someone added a compiler flag workaround I'd also ask to add a comment (though can't really RuboCop check that).

pour_bottle? is however one I'd consider adding.

In all cases, be aware to check for and skip through parent on_system blocks as we can comment it this way:

# comment explaining horrible hack
on_macos do
  on_intel do
    pour_bottle? ...
  end
end

which is an acceptable form of documenting.

@p-linnane
Copy link
Member

+1 for compiler flags as well.

@MikeMcQuaid
Copy link
Member

Thanks folks!

@branchvincent would you be interested in adding patches/pour_bottle?/compiler flags in this or a follow-up PR?

@MikeMcQuaid
Copy link
Member

Another thought is e.g. ENV.deparallelize and anything else like ENV.O0 or ENV.O1.

@issyl0
Copy link
Member

issyl0 commented Aug 13, 2024

@branchvincent would you be interested in adding patches/pour_bottle?/compiler flags in this or a follow-up PR?

I'm interested if @branchvincent isn't. :-)

@branchvincent
Copy link
Member Author

@branchvincent would you be interested in adding patches/pour_bottle?/compiler flags in this or a follow-up PR?

Yea I'll add them here!

@issyl0 I can take an initial stab at covering these other DSLs but maybe you could help fill in any gaps I might miss? Like the on_macos blocks might be tricky

Also, I think I'll make this a strict audit to give us time to address all the existing offenses

@branchvincent branchvincent marked this pull request as draft August 13, 2024 15:52
@MikeMcQuaid
Copy link
Member

Yea I'll add them here!

Thanks!

Also, I think I'll make this a strict audit to give us time to address all the existing offenses

Good idea!

Copy link

github-actions bot commented Sep 4, 2024

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale No recent activity label Sep 4, 2024
@github-actions github-actions bot closed this Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale No recent activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants