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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Lint/NoReturnInBeginEndBlocks Cop #8457

Merged

Conversation

ashmaroli
Copy link
Member

@ashmaroli ashmaroli commented Nov 5, 2020

  • This is a 馃悰 bug fix.

Summary

  • Enable Lint/NoReturnInBeginEndBlocks
  • Split logic in offending Jekyll::PathManager.sanitized_path into a private class method.
  • Add a new private cache to stash base_directory appended with a forward slash.

Context

RuboCop 1.2.0 added Lint/NoReturnInBeginEndBlocks. According to its author:

This cop detects the usage of explicit return statements inside a begin..end block in the context of assignments.

The issue is that a return inside a begin..end block in assignment contexts will not assign the desired value to the variable, but will return the value expected to the caller.

In case you're using memoization, the memoized variable will be always nil and the code inside the begin..end block will
execute as many times as you access the memoized variable...

@ashmaroli ashmaroli requested a review from DirtyF November 5, 2020 13:32
@DirtyF DirtyF added this to the 4.2 milestone Nov 5, 2020
Copy link
Member

@DirtyF DirtyF left a comment

Choose a reason for hiding this comment

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

馃啑 if tests pass

@ashmaroli
Copy link
Member Author

@jekyllbot: merge +bug

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants