Skip to content

CC0006 : should not trigger when loop variable used in multiple places. #1035

@RachelDavids

Description

@RachelDavids

#Bug
Should not trigger when loop variable used in loop &/or non-standard increment.

public void Test()
{
    int[] ints = {1, 2, 3, 4, 5, 6, 7, 8};
    for (int j = 0; j < ints.Length; j += 2)
    {
        int a = ints[j];
        int b = ints[j + 1];
    }
}

Current output after fix applied (generates uncompilable code.):

public void Test()
{
    int[] ints = {1, 2, 3, 4, 5, 6, 7, 8};
	foreach (var a in ints)
	{
		int b = ints[j + 1];
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions