- Operating system: Windows 10 Pro, 22H2, 19045.5011
- Visual Studio version: Community 2022, 17.11.5
- SonarLint plugin version: 8.6.0.10679
- Programming language you’re coding in: C#
- Is connected mode used: No
There are at least a pair of SonarLint rules that are not being shown for Unity engine projects (checked in two of them) on files that are inside an “Editor” folder, but that are shown for other files. The rules I’ve found are “S1449” and “S1698”; I don’t know if it’s relevant, but those rules seem to be disabled by default, and I had added them as warnings to an “.editorconfig” file:
[*]
dotnet_diagnostic.S1449.severity = warning
dotnet_diagnostic.S1698.severity = warning
This is some code that shows the issue; the exact same code in different folders has different warnings shown:
public class _TEST_
{
enum Stuff
{
Zero,
One
}
class MyClass // S1206 shown on all files.
{
public override bool Equals(object obj)
{
return true;
}
}
public bool Whatever()
{
int meow; // S1481 shown on all files.
Stuff something = Stuff.One;
string text;
switch (something)
{
case Stuff.Zero: // S2583 shown on all files.
text = "0";
break;
case Stuff.One: // S2589 and S3458 shown on all files.
default:
text = "1";
break;
}
MyClass a = new();
MyClass b = new();
return a == b // S1698 not shown for files in "Editor" folder.
&& text.IndexOf("a") == 0; // S1449 not shown for files in "Editor" folder.
}
}