-
Notifications
You must be signed in to change notification settings - Fork 423
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
SpaceAroundOperator: false positive on unary minus (Elixir 1.6.0) #495
Comments
I'm also seeing warnings with Elixir 1.6.0 when compiling verk (which depends on latest credo):
|
@halfdan I see those too, but I think they're unrelated to this issue. Might be worth opening a separate issue for that so that this thread doesn't get confusing for people. |
@randycoulman Ah, fair enough 👍 - only glimpsed over your issue and didn't realise it was describing a different issue. |
Experienced the same issue with Elixir 1.6.1 and Credo 0.8.10:
Here are workaround which are possible
|
@randycoulman @halfdan @AntonShevel Could you test with |
@rrrene Seems to be fixed for the example I originally reported. Thanks! |
@rrrene I'm experiencing this error too Environment
What were you trying to do?Set up credo into my pre-commit on the project: https://github.com/dwyl/hits-elixir Expected outcomeCredo runs and reports any needed changes or success message. Actual OutcomeCredo was erroring:
Based on your comment in #496 (comment) and now it runs successfully locally doing Fail with no further explanation: Any advice? |
@Cleop There is no evidence of Credo breaking in the screens. Maybe there's a misunderstanding here? Since Credo is reporting issues on the code, it will exit with an exit status other than zero. This causes "Pre-commit failed on You can mute the exit status via |
@rrrene thanks for getting back to me. So credo was failing with the Now it passes when run simply as |
@Cleop I am in a bit of a rush, so I will be impolite and just dump this list of links:
Hope this helps to clear things up. 👍 |
Thanks @rrrene I understand it now 👍 |
I'm having a similar issue after updating to 0.9.0. The problem was not there on 0.8.10. I am able to reproduce with this small example code: def my_fun(x) when x < -4 do
x
end
def my_fun(x) when -4 < x do
x
end Credo will warn about the second function but not the first:
|
@randycoulman @halfdan @AntonShevel @Cleop Again, thanks for reporting this 😀 It should now be fixed on You can try this by setting the Credo dep to {:credo, github: "rrrene/credo"} Please report back if your issue is solved! 👍 |
It should be be fixed in the latest version ( If it is not, please feel free to re-open this issue! |
The issue I described above is gone now. Thanks! :) |
Precheck
Environment
mix credo -v
): 0.8.10elixir -v
): 1.6.0What were you trying to do?
Attempting to upgrade an application from Elixir 1.5.3/credo 0.8.6 -> Elixir 1.6.0. In Elixir 1.6.0, credo 0.8.6 failed in
Code.toTokens
. After reviewing the CHANGELOG, I realized that I'd need to also upgrade credo to 0.8.10, so I did that as well.Expected outcome
No credo warnings.
Actual outcome
Running credo on the app resulted in a new SpaceAroundOperator warning that wasn't present previously. The line in question is:
The error message points at the
*
in the50 * 50
part of the expression, but by changing the code to this:the error goes away.
It looks like the
-
is not being properly interpreted as a unary minus in this case. There is code to detect in when the following characters are numeric (which is why the-1
works in the new code).I also tested with Elixir 1.5.3/credo 0.8.10 and did not see the same warning, so this appears to be a new issue with Elixir 1.6.0.
The text was updated successfully, but these errors were encountered: