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

Forbid RBI outside of configurable AllowedPaths #83

Merged
merged 1 commit into from
Nov 22, 2021

Conversation

RyanBrushett
Copy link
Contributor

#79

ForbidRBIOutsideOfSorbetDir makes the assumption that RBI files will always be kept under sorbet/rbi which is not necessarily the case. See the sorbet docs on RBI files within gems for one example of this. Refactoring the cop a bit allows us to be flexible for these sorts of setups.

AllowedPaths will default to ["sorbet/rbi/**"] to be consistent with ForbidRBIOutsideOfSorbetDir
This cop makes no attempts to tell a user where to put things, but allows them to tailor the cop to their needs.
I decided that having AllowedPaths set explicitly to an empty list, nil value, or list containing nil meant it was broken.

See tests for a rundown.

@RyanBrushett RyanBrushett requested a review from a team November 19, 2021 20:40
nil,
location: source_range(processed_source.buffer, 1, 0),
message: message
) if allowed_paths.none? { |pattern| File.fnmatch(pattern, processed_source.file_path) }
Copy link
Member

Choose a reason for hiding this comment

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

TIL about fnmatch.

- Default to ["sorbet/rbi/**"]
- Add offense on empty AllowedPaths

Co-authored-by: Alexandre Terrasa <[email protected]>
@RyanBrushett RyanBrushett force-pushed the ryanb-rbi-outside-of-sorbet-dir branch from b84b371 to ddd0e0d Compare November 22, 2021 15:13
@RyanBrushett RyanBrushett merged commit 649297d into master Nov 22, 2021
@RyanBrushett RyanBrushett deleted the ryanb-rbi-outside-of-sorbet-dir branch November 22, 2021 15:15
@shopify-shipit shopify-shipit bot temporarily deployed to production December 3, 2021 16:57 Inactive
@shopify-shipit shopify-shipit bot temporarily deployed to production December 9, 2021 00:10 Inactive
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.

4 participants