C#

C#

Made by DeepSource

Audit required: enum used for permissions is missing the Flags attribute CS-A1004

Bug risk
Critical

Flags attribute is generally used when representing multiple values often via bitwise operators. It is recommended that enums used in implementing permissions use this attribute.

Bad Practice

enum MyEnum
{
    None   = 0,
    First  = 1 << 0,
    Second = 1 << 1,
    Third  = 1 << 2,
    Fourth = 1 << 3
}

Recommended

[Flags]
enum MyEnum
{
    None   = 0,
    First  = 1 << 0,
    Second = 1 << 1,
    Third  = 1 << 2,
    Fourth = 1 << 3

    /* `One` and `Four` can now be represented as `MyEnum.One | MyEnum.Four` (using the `|` bitwise operator) */
}

Reference