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

Style/ConstantVisibility needs ♥️ #8724

Open
marcandre opened this issue Sep 15, 2020 · 1 comment
Open

Style/ConstantVisibility needs ♥️ #8724

marcandre opened this issue Sep 15, 2020 · 1 comment

Comments

@marcandre
Copy link
Contributor

The Style::ConstantVisibility cop has potential but could be made much more useful.

False positives: it should detect # @api private (or # @api public) in the associated comment, and also detect if the parent module is itself private (either via private_constant or @api private).

Modules vs literals: it should allow a config 'ExcludeModules' to restrict detection of literals only (EXAMPLE = 42, and not SomeClass = Struct.new()). Typically nested modules and classes are public, but literals should be private.

Auto-correction: it should offer auto-correction. A config option like DefaultVisibility could make it much nicer. Values could be: 'private_constant', 'public_constant', '@api private', or '@api public'. Autocorrector should be mindful of constants containing heredocs and/or assignments ending with comments.

@bbatsov
Copy link
Collaborator

bbatsov commented Sep 25, 2020

Yeah, totally agreed. Lots of room for improvement there.

tejasbubane added a commit to tejasbubane/rubocop that referenced this issue Jan 28, 2021
To not register offense for module definitions.

Issue rubocop#8724
bbatsov pushed a commit that referenced this issue Feb 14, 2021
To not register offense for module definitions.

Issue #8724
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants