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

Detect degenerated workarounds for Style/NumericLiterals #3749

Merged
merged 1 commit into from Dec 16, 2016
Merged

Detect degenerated workarounds for Style/NumericLiterals #3749

merged 1 commit into from Dec 16, 2016

Conversation

kamaradclimber
Copy link
Contributor

@kamaradclimber kamaradclimber commented Nov 30, 2016

Users might be tempted to replace 8192 by 819_2 without
understanding the underscore as a thousand separator


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).
  • 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.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • 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).

@@ -16,6 +16,7 @@
* [#3451](https://github.com/bbatsov/rubocop/issues/3451): Add new `require_parentheses_when_complex` style to `Style/TernaryParentheses` cop. ([@swcraig][])
* [#3600](https://github.com/bbatsov/rubocop/issues/3600): Add new `Bundler/OrderedGems` cop. ([@tdeo][])
* [#3479](https://github.com/bbatsov/rubocop/issues/3479): Add new configuration option `IgnoredPatterns` to `Metrics/LineLength`. ([@jonas054][])
* [#3749](https://github.com/bbatsov/rubocop/pull/3749): Detect corner case of `Style/NumericLitterals`. ([@kamaradclimber][])
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be moved the the master section of the readme.

@bbatsov
Copy link
Collaborator

bbatsov commented Dec 13, 2016

Apart from my small remark - the change looks good to me.

Users might be tempted to replace 8192 by 819_2 without
understanding the underscore as a thousand separator

Change-Id: If97f6c0ebdedf69df36530168a385f4a896a0a39
@kamaradclimber
Copy link
Contributor Author

@bbatsov thanks for you feedback, I've moved the changelog line to its proper place.

@bbatsov bbatsov merged commit 6004788 into rubocop:master Dec 16, 2016
@kamaradclimber kamaradclimber deleted the numeric_litterals branch December 23, 2016 09:19
@iGEL
Copy link
Contributor

iGEL commented Feb 16, 2017

@kamaradclimber, @bbatsov I think, this is a bad idea. We use money objects which we initialize with cents, so to get $123,456.78, we used Money.usd(123_456_78), which is a lot better to read than Money.usd(12_345_678). The previous behavior was perfect for us.

Instead on enforcing this, I'd rather provide a better offense message explaining the proper usage.

@mikegee
Copy link
Contributor

mikegee commented Feb 16, 2017

@iGEL Please refer to the discussion in #3981.

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