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

Improve Style/FrozenStringLiteralComment message #3999

Merged
merged 1 commit into from Feb 3, 2017

Conversation

burke
Copy link
Contributor

@burke burke commented Feb 1, 2017

We've had a bunch of developers confused by the previous message; I think this one is more clear.

Specifically, unless the user knows about this specific cop being enabled, the annotation "Missing frozen string literal comment" on a line like require 'test_helper' doesn't really educate them on how to proceed.


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists). (N/A)
  • Used the same coding conventions as the rest of the project.
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests. (N/A)
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format. (N/A)
  • All tests are passing.
  • The new code doesn't generate RuboCop offenses.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Updated cop documentation with rake generate_cops_documentation (required only when you've added a new cop or changed the configuration/documentation of an existing cop). (N/A)

Copy link

@anniecodes anniecodes left a comment

Choose a reason for hiding this comment

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

This makes it a lot clearer that the problem isn't with whatever the first line of your file is but that you need to add something to the file to make this rule pass. 👍

Copy link

@christhomson christhomson left a comment

Choose a reason for hiding this comment

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

👍 much clearer.

@burke
Copy link
Contributor Author

burke commented Feb 1, 2017

Noticed CI was red because of too-long lines. Fixed, sorry!

@@ -12,7 +12,7 @@ class FrozenStringLiteralComment < Cop
include ConfigurableEnforcedStyle
include FrozenStringLiteral

MSG = 'Missing frozen string literal comment.'.freeze
MSG = 'File must begin with "# frozen_string_literal: true".'.freeze
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that's a bit confusing as well. The file should really begin with this - keep in mind there things like shebangs and other magic comments. Also - code snippets in messages should be in backticks, not double quotes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. How about something like:

MSG = 'Comment must be present near top of file: `# frozen_string_literal: true`.'

It's a difficult thing to phrase clearly without getting too wordy :/

Copy link
Collaborator

Choose a reason for hiding this comment

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

How about Missing magic comment ....? That seems clear enough to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Works for me. Updated.

@bbatsov bbatsov merged commit 45fe0cf into rubocop:master Feb 3, 2017
@bbatsov
Copy link
Collaborator

bbatsov commented Feb 3, 2017

Thanks! 👍

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.

None yet

4 participants