Skip to content

Replace assignment to variable with increment of variable #742

@kwhitefoot

Description

@kwhitefoot

New analyzer:

A lot of legacy code (and a surprising amount of new code) contains statements that update a variable by adding to it or multiplying it. This can be replaced by an increment

Before:

    a = a + b
    c = c * d
    e = e / f
    g = h - i

After:

    a += b
    c *= d
    e /= f
    g -= i

Diagnostic Id: CC0116
Category: Style
Severity: Info

This is for both C# and VB.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions