- Language: C#
- Rule: S2183
- Product: SonarQube for Visual Studio 8.11.0.11944
- IDE: Visual Studio Community 2022 17.12.4
- Connected mode: No
The rule S2183 (“Integral numbers should not be shifted by zero or more than their number of bits-1”) doesn’t trigger for the values in enum
types when shifting by the number of bits or more. For example:
internal static class Program
{
static void Main()
{
int meow = 1 << 63; // Generates S2183.
}
enum MyEnum
{
Meow = 1 << 63 // Does not generate S2183.
}
}
To me it seems OK that it doesn’t trigger when shifting by 0 in enums, but not by the number of bits or more, as that’s most probably a bug.