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

Rubocop warning for snake_case source file names: a suggestion for improvement #2923

Closed
ghost opened this issue Mar 7, 2016 · 1 comment
Closed

Comments

@ghost
Copy link

ghost commented Mar 7, 2016

Rubocop version:

0.37.2 (using Parser 2.3.0.6, running on ruby 2.3.0 x86_64-linux)

Hello. Not sure if this is worth reporting since this is fairly minor but
if you feel that this is not important, feel free to close it any moment
in time.

I ran rubocop against a codebase of medium size and it gave some
warnings/errors. One warning was a bit confusing though:

bioroebe/lib/bioroebe/is_on_roebe?.rb:1:1: C: Use snake_case for source file names.
class Bioroebe # require 'bioroebe/is_on_roebe?.rb'

So rubocop says that one should use snake_case for source
file names. Fair enough.

Now, the name of this file is:

is_on_roebe?.rb

And technically, I would think that this is actually snake_case
already, since we had no upcased characters in it. I assume that
rubocop complains about the ? actually. The "?" token has no
uppercased or lowercased variant. One could reason that it already
is uppercased as-is, but then what would be its lowercased
variant - a tiny "?" perhaps? :)

Rubocop may or may not issue a warning for the use of ? in a
filename or not, that is fine. But I think the warning message
itself should be slightly different in this case, not only just
for characters such as "?" but also for all characters that have
no distinction between upcase and lowercase variants. For
alphabetical characters, this is all usually doable, e. g. "r"
versus uppercase "R". For other characters, this is not always
possible - I am thinking of some unicode names too. Rubocop
accepts "_" in filenames too right now.

At any rate - my suggestion would be to pick either one of the
following:

  • Ignore tokens that can not be uppercased/lowercased altogether
    when issuing a warning about filenames.
  • Use a different warning for filenames like that. This here may
    be slightly better altogether.

The warning could then be:

"Use standard alphabetical characters for file names.", for
instance. And "_" will continue to be ignored either way since
it is so common.

Thanks!

@bbatsov
Copy link
Collaborator

bbatsov commented Mar 8, 2016

Hmm, I've never seen such a filename. What's your reasoning to use ? in a filename?

@bbatsov bbatsov closed this as completed in 76e0f14 Mar 9, 2016
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