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
False positive 'Return value of fuction 'x' is never used'. #4036
Comments
At the call site, is |
|
Ok so the good news is that the resolver is doing its job and correctly identifying member calls in an argument list. The bad news is that it's not clear whether your |
No, I'm confused. I went to the first The (I've got a fair few inspections to go through, but I'll hold out hope...) |
Got a repro: the inspection yields a result for a function that's simply never invoked. While technically accurate, that is rather confusing. The inspection needs to filter out functions that have |
var functions = State.DeclarationFinder
.UserDeclarations(DeclarationType.Function)
.Where(item => !IsIgnoringInspectionResultFor(item, AnnotationName))
.ToList();
Okay, a little twist: needs to exclude references that are within the scope of the function itself, since the "return value assignment" counts as a reference. |
Why not simply check for the existence of references that are not assignments? |
@MDoerner because we're looking for functions whose return value is never used; it's a declaration result. That said, a reference result that flags all places where a function is invoked like a sub would be rather useful too! |
I think you misunderstood my comment. I was commenting on enhancement of the condition in the current inspection and referring to the preceding comment. |
Right. Unless the function returns an object that has a default member.. although at this point IIRC the resolver sets the assignment flag on the default member and not the function, right? |
The inspection already has a function |
The function:
The call site:
LogManager.Register FileLogger.Create(Strings.Join(Array("DBLog", Format$(Now, "yyyy.mm.dd hh.mm"), ".txt"), vbNullString), loggingLevel, TempVars.Item("dbPath").Value, 10)
And the inspection result:
And the instant analysis:
https://chat.stackexchange.com/transcript/message/44796336#44796336
The text was updated successfully, but these errors were encountered: