X Tutup
The Wayback Machine - https://web.archive.org/web/20260322124320/https://github.com/github/codeql/issues/3747
Skip to content

LGTM.com - false positive: cs/useless-assignment-to-local when variable is a Func that is called #3747

@Nateowami

Description

@Nateowami

When a function is assigned to a local variable and then called, LGTM reports that the assignment is useless because the variable is never read.

For example, in the C# code below getCollection is assigned and then called, which should count as being "read."

Func<T, IEnumerable<TItem>> getCollection = field.Compile();
IEnumerable<TItem> collection = getCollection(_entity);

Example where this is happening:
https://lgtm.com/projects/g/sillsdev/web-xforge/snapshot/f3b0c76c3301061b4cd5e9ac97d8e8fb7ee07db5/files/src/SIL.XForge/DataAccess/MemoryUpdateBuilder.cs#xccaf3ec2e56ca355:1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup