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

Cop idea: check for code outside of named class or module #1118

Open
DeedleFake opened this issue Sep 13, 2023 · 0 comments
Open

Cop idea: check for code outside of named class or module #1118

DeedleFake opened this issue Sep 13, 2023 · 0 comments

Comments

@DeedleFake
Copy link

Is your feature request related to a problem? Please describe.

A very rare but non-zero number of times, code has been accidentally placed outside of the class or module corresponding to the file that it's in, i.e.

# app/services/example_service.rb
class ExampleService
  ...
end

puts 'Whoops. This shouldn't be here.'

Describe the solution you'd like

Check for code in files with classes or modules named after them, so ignore things like config initializers, that isn't in said class or module and report it.

Describe alternatives you've considered

Convoluted regular expressions that would probably miss stuff. For example, something like grep -r '^[A-Z]' app lib.

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

No branches or pull requests

1 participant