Skip to content

LGTM.com - false positive - cs/unused-collection when usage is within methods that caller overrides within an abstract class #2776

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

Open
ahsonkhan opened this issue Feb 6, 2020 · 0 comments

Comments

@ahsonkhan
Copy link

Description of the false positive

The cs/unused-collection is resulting in some false positives: https://lgtm.com/rules/1506094606044/

URL to the alert on the project page on LGTM.com

https://lgtm.com/projects/g/dotnet/corefx/snapshot/4fed824926d1c659c494bd5261fbae0236b2e9da/files/src/System.Linq.Expressions/src/System/Runtime/CompilerServices/CallSiteBinder.cs?sort=name&dir=ASC&mode=heatmap#x343810f1b8fd4a23:1

In this particular case, the collection is initialized here and then passed to an abstract method (so the caller could have needed/accessed the elements):
Initialized: https://source.dot.net/#System.Linq.Expressions/System/Runtime/CompilerServices/CallSiteBinder.cs,7785087df39cf34b
Passed to an abstract method: https://source.dot.net/#System.Linq.Expressions/System/Runtime/CompilerServices/CallSiteBinder.cs,129
User defined method that overrides it accesses the collection elements: https://source.dot.net/#System.Linq.Expressions/System/Runtime/CompilerServices/CallSiteBinder.cs,9c8a7458b545d05d

For example, see:
https://source.dot.net/#System.Linq.Expressions/System/Dynamic/DynamicMetaObjectBinder.cs,49

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

2 participants