-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Closes #398 - Fixed newsletter analysis to allow guard clause #400
Conversation
Signed-off-by: Willy Wombat <[email protected]>
@@ -1,5 +1,4 @@ | |||
defmodule TwoFer do | |||
@someUnusedModuleAttribute 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you change this by mistake?
This is the source of the failing tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did change it as it caused an unused compiler warning and my setup locally stops in that case!!
I will revert the change and retest. Thanks.
Yes that fixes the tests! I guess I don't know the codebase well enough (yet!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, the compiler warning is on purpose, so we can test if we actually detect it :)
form do | ||
def open_log(_ignore) when _ignore do | ||
_block_includes do | ||
File.open!(_ignore, [:write]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also include all of the variations we had before (with and without File
, with and without !
). I know they are not all super likely, but we might as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't remove any of the existing variants though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant let's duplicate all four existing variants and add the when _ignore
, not just for File.open!
.
Right now if someone uses
import File
def open_log(path) when is_binary(path) do
open!(path, [:write])
end
It will trigger a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha!
Signed-off-by: Willy Wombat <[email protected]>
Signed-off-by: Willy Wombat <[email protected]>
Sorry one last thing: for completeness, we should add tests for all 8 cases, something like test_exercise_analysis "open_log accepts 8 several variants",
comments_exclude: [ElixirAnalyzer.Constants.newsletter_open_log_uses_option_write()] do
[ defmodule Newsletter do
import File
def open_log(path) when is_binary(path) do
open!(path, [:write])
end
end
end,
....
]
|
Signed-off-by: Willy Wombat <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's great, thank you so much for your contribution!
My pleasure |
Following discussions with @jiegillet and an upstream code fix.