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

Add Cop to block external references to "Internal" code #56

Merged
merged 10 commits into from
Oct 30, 2024

Conversation

medlefsen
Copy link
Contributor

This PR adds a new "Betterment/InternalsProtection" cop which enforces a pattern of putting internal code into Internals sub modules.

If you have a module MyModule which has a submodule or class that you don't want accessed from other modules, you can place it under MyModule::Internals (e.g. MyModule::Internals::MyPrivateClass) to indicate that code in other modules should not access it. This cop enforces that by blocking references to constants defined within Internals modules from code in other modules.

It also restricts string references to class names in ActiveRecord association definitions, and properly handles references in specs.

Copy link
Member

@smudge smudge left a comment

Choose a reason for hiding this comment

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

platform LGTM

Copy link
Contributor

@effron effron left a comment

Choose a reason for hiding this comment

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

domainLGTM

@medlefsen medlefsen merged commit 9d4009a into Betterment:main Oct 30, 2024
4 checks passed
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.

3 participants