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

Readability.LargeNumbers false positives #229

Closed
novaugust opened this issue Nov 13, 2016 · 7 comments
Closed

Readability.LargeNumbers false positives #229

novaugust opened this issue Nov 13, 2016 · 7 comments

Comments

@novaugust
Copy link
Contributor

novaugust commented Nov 13, 2016

Precheck

Environment

  • Credo version (mix credo -v): 0.5.2
  • Erlang/Elixir version (elixir -v): 1.3.0
  • Operating system: osx

What where you trying to do?

I have lists with lots of floats and large numbers. Sometimes credo is giving me false positives on needing underscores.

For this data, the first 7 lines are all fine, but it's compalning about the last 5.

test_data = [
      {[14_434, 0.000, 0.250, -0.500, 4_200_000], {14_193.7059228487, -461.81222427595}},
      {[7_275, -0.013, 0.300, -0.400, 3_242_800], {6_705.06114827335, -686.923024527031}},
      {[2_656, 0.000, 0.320, -0.283, 1_070_000], {1_875.04749892584, -540.482846075626}},
      {[6_928, 0.011, 0.280, -0.283, 2_580_000], {6_238.09826567172, -633.308400721897}},
      {[6_928, -0.011, 0.280, -0.283, 2_580_000], {6_238.09625455701, -633.328209922203}},
      {[6_928, 0.011, 0.280, 0.283, 2_580_000], {6_238.09625455701, 633.328209922203}},
      {[6_928, -0.011, 0.280, 0.283, 2_580_000], {6_238.09826567172, 633.308400721897}},
      {[14_434, 0.000, 0.287, -0.526, 8_740_000], {13_922.7016262733, -872.190348982156}}, #bad
      {[7_270, 0.000, 0.287, -0.526, 68_000], {7_262.51042806277, -13.6958182877388}}, #bad
      {[7_270, 0.000, 0.287, -0.526, 70_000], {7_262.28975554153, -14.0984231358245}}, #bad
      {[7_270, 0.000, 0.200, -0.500, 70_000], {7_263.34062452151, -16.5934712666501}}, #bad
      {[7_270, 0.000, 0.200, 0.500, 70_000], {7_263.34062452151, 16.5934712666501}} #bad
    ]

In each of the last 5 lines, the 5th item in the line is being reported as not having underscores

@novaugust novaugust changed the title Readability.LargeNumbers false positive around precise zeros: 0.000 Readability.LargeNumbers false positives Nov 13, 2016
@rrrene
Copy link
Owner

rrrene commented Nov 15, 2016

The problem is that pre Elixir 1.3.2 we use an unreliable function to retrieve the fragment:

# There's a bug in the :elixir_tokenizer.tokenize/3 in versions prior to

The solution will be to deprecate this check for Elixir < 1.3.2. Thx for reporting! 👍

@novaugust
Copy link
Contributor Author

Thanks for telling me what's wrong. How do you go about deprecating checks in Credo? I've been making enough noise over here I'd be happy to help

@rrrene
Copy link
Owner

rrrene commented Nov 16, 2016

We don't have a mode of operation for this yet. The Dogma project, which I contributed to before creating Credo has integrated something like this after we ran into the same issue.

The question is if we can adapt the approach for Credo without changing the architecture or if we want to "invent" a new module attribute for checks to show their Elixir compatibility (and then filter checks before-hand).

@devonestes
Copy link
Contributor

This seems like a fun thing to tackle!

I'd imagine that we're going to have more of these in the future as well, and since I was just in the Config module, I think I have a simple enough way of filtering out checks based on the current version of Elixir that Credo is running in.

I'll put together a quick version of it on my plane ride home tomorrow and see what you all think 😉

@rrrene
Copy link
Owner

rrrene commented Nov 27, 2016

@devonestes That'd be great. It would help to have some quick&dirty implementation of this, so we can discuss the direction which we are going to take 👍

@devonestes
Copy link
Contributor

I think we can close this issue now, right @rrrene?

@rrrene
Copy link
Owner

rrrene commented Dec 7, 2016

@devonestes Yes.
@novaugust This will be fixed in the next release. Thx again for reporting! 👍

@rrrene rrrene closed this as completed Dec 7, 2016
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

3 participants