Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Rule S2094: Classes should not be empty #6754

Merged
merged 39 commits into from Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0fea5f9
Initial scaffolding
zsolt-kolbay-sonarsource Feb 10, 2023
30a7384
Add more C# test cases
zsolt-kolbay-sonarsource Feb 13, 2023
6f8ab44
Rename ClassAndRecordDeclaration
zsolt-kolbay-sonarsource Feb 13, 2023
fde4a50
Add VB test cases
zsolt-kolbay-sonarsource Feb 13, 2023
e87c429
Fix member check
zsolt-kolbay-sonarsource Feb 13, 2023
3ea7553
Add VB test case for inheritance
zsolt-kolbay-sonarsource Feb 13, 2023
cff2177
Add exceptions for special base classes
zsolt-kolbay-sonarsource Feb 13, 2023
ddfe3c3
Refactor SyntaxFacade methods
zsolt-kolbay-sonarsource Feb 13, 2023
7e732f2
Add type name to rule message
zsolt-kolbay-sonarsource Feb 13, 2023
d28148b
Update Sarif files
zsolt-kolbay-sonarsource Feb 14, 2023
a13ef28
Fix Java test cases
zsolt-kolbay-sonarsource Feb 14, 2023
1905bc3
Update VB.NET rule description
zsolt-kolbay-sonarsource Feb 14, 2023
c0e7b29
Refactor IsEmpty method and SyntaxFacade
zsolt-kolbay-sonarsource Feb 15, 2023
948cbc0
Add System.Exception to list of ignored subclasses
zsolt-kolbay-sonarsource Feb 15, 2023
8434811
Replace property constants
zsolt-kolbay-sonarsource Feb 15, 2023
b68c4be
Add test cases for abstract classes
zsolt-kolbay-sonarsource Feb 15, 2023
cfb5601
Add test cases for generic classes and records
zsolt-kolbay-sonarsource Feb 15, 2023
8998fc3
Add more compliant test cases
zsolt-kolbay-sonarsource Feb 15, 2023
ed3d55e
Update RSPEC
zsolt-kolbay-sonarsource Feb 15, 2023
d7498d4
More test cases for records
zsolt-kolbay-sonarsource Feb 15, 2023
4cf60e2
Test case for method override
zsolt-kolbay-sonarsource Feb 15, 2023
5734036
Update Sarif files
zsolt-kolbay-sonarsource Feb 15, 2023
d7d96d6
Refactoring
zsolt-kolbay-sonarsource Feb 15, 2023
6e7b536
Add exceptions to partial classes and records
zsolt-kolbay-sonarsource Feb 15, 2023
e2aac49
Update Sarif files
zsolt-kolbay-sonarsource Feb 15, 2023
361928a
Update RSPEC
zsolt-kolbay-sonarsource Feb 15, 2023
b49f0b7
Merge branch 'master' into Zsolt/S2094-empty-class
zsolt-kolbay-sonarsource Feb 15, 2023
536ac80
Sync with master
zsolt-kolbay-sonarsource Feb 15, 2023
f411c97
startsWith -> equals
zsolt-kolbay-sonarsource Feb 15, 2023
e6d4c76
Test commit
zsolt-kolbay-sonarsource Feb 15, 2023
a2e6541
Revert previous
zsolt-kolbay-sonarsource Feb 15, 2023
273cb70
Refactor Java test cases
zsolt-kolbay-sonarsource Feb 16, 2023
55a3b32
fixMeTagTrackingIssues -> fixMeIssues
zsolt-kolbay-sonarsource Feb 17, 2023
fd745ab
Add test case for empty abstract classes
zsolt-kolbay-sonarsource Feb 17, 2023
dd7d9fe
Update test cases
zsolt-kolbay-sonarsource Feb 17, 2023
1a6a36d
Refactor rule class
zsolt-kolbay-sonarsource Feb 17, 2023
7c58e15
Refactor C# Rule
zsolt-kolbay-sonarsource Feb 18, 2023
04df5d7
Fix UT
zsolt-kolbay-sonarsource Feb 21, 2023
089b333
Remove type check
zsolt-kolbay-sonarsource Feb 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,17 @@
{
"issues": [
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\Ember-MM\Ember.Plugins\PluginActionContext.cs",
"region": {
"startLine": 6,
"startColumn": 18,
"endLine": 6,
"endColumn": 37
}
}
}
]
}
108 changes: 108 additions & 0 deletions analyzers/its/expected/Net5/Net5--net5.0-S2094.json
@@ -0,0 +1,108 @@
{
"issues": [
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\Net5\Net5\ModuleInitializers.cs",
andrei-epure-sonarsource marked this conversation as resolved.
Show resolved Hide resolved
"region": {
"startLine": 3,
"startColumn": 18,
"endLine": 3,
"endColumn": 36
}
}
},
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\Net5\Net5\ParameterValidation.cs",
"region": {
"startLine": 3,
"startColumn": 18,
"endLine": 3,
"endColumn": 37
}
}
},
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\Net5\Net5\RelaxRefPartialOrder.cs",
"region": {
"startLine": 3,
"startColumn": 26,
"endLine": 3,
"endColumn": 46
}
}
},
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\Net5\Net5\S2330.cs",
"region": {
"startLine": 5,
"startColumn": 32,
"endLine": 5,
"endColumn": 37
}
}
},
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\Net5\Net5\S3240.cs",
"region": {
"startLine": 5,
"startColumn": 24,
"endLine": 5,
"endColumn": 29
}
}
},
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\Net5\Net5\S3247.cs",
"region": {
"startLine": 8,
"startColumn": 15,
"endLine": 8,
"endColumn": 24
}
}
},
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\Net5\Net5\S3453.cs",
"region": {
"startLine": 22,
"startColumn": 26,
"endLine": 22,
"endColumn": 34
}
}
},
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\Net5\Net5\StaticLambdas.cs",
"region": {
"startLine": 3,
"startColumn": 18,
"endLine": 3,
"endColumn": 31
}
}
}
]
}
17 changes: 17 additions & 0 deletions analyzers/its/expected/Net7/Net7--net7.0-S2094.json
@@ -0,0 +1,17 @@
{
"issues": [
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\Net7\Net7\features\WarningWave7.cs",
"region": {
"startLine": 5,
"startColumn": 22,
"endLine": 5,
"endColumn": 35
}
}
}
]
}
199 changes: 199 additions & 0 deletions analyzers/its/expected/akka.net/Akka--netstandard2.0-S2094.json
@@ -0,0 +1,199 @@
{
"issues": [
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\akka.net\src\core\Akka\Actor\ActorSelection.cs",
"region": {
"startLine": 388,
"startColumn": 27,
"endLine": 388,
"endColumn": 47
}
}
},
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\akka.net\src\core\Akka\Actor\FSM.cs",
"region": {
"startLine": 202,
"startColumn": 31,
"endLine": 202,
"endColumn": 37
}
}
},
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\akka.net\src\core\Akka\Event\LoggerInitialized.cs",
"region": {
"startLine": 15,
"startColumn": 18,
"endLine": 15,
"endColumn": 35
}
}
},
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\akka.net\src\core\Akka\Event\Logging.cs",
"region": {
"startLine": 18,
"startColumn": 18,
"endLine": 18,
"endColumn": 44
}
}
},
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\akka.net\src\core\Akka\IO\Dns.cs",
"region": {
"startLine": 62,
"startColumn": 31,
"endLine": 62,
"endColumn": 38
}
}
},
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\akka.net\src\core\Akka\IO\Inet.cs",
"region": {
"startLine": 229,
"startColumn": 31,
"endLine": 229,
"endColumn": 43
}
}
},
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\akka.net\src\core\Akka\IO\Tcp.cs",
"region": {
"startLine": 56,
"startColumn": 33,
"endLine": 56,
"endColumn": 48
}
}
},
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\akka.net\src\core\Akka\IO\Tcp.cs",
"region": {
"startLine": 87,
"startColumn": 22,
"endLine": 87,
"endColumn": 29
}
}
},
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\akka.net\src\core\Akka\IO\Tcp.cs",
"region": {
"startLine": 738,
"startColumn": 22,
"endLine": 738,
"endColumn": 27
}
}
},
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\akka.net\src\core\Akka\IO\Udp.cs",
"region": {
"startLine": 37,
"startColumn": 33,
"endLine": 37,
"endColumn": 48
}
}
},
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\akka.net\src\core\Akka\IO\Udp.cs",
"region": {
"startLine": 107,
"startColumn": 31,
"endLine": 107,
"endColumn": 38
}
}
},
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\akka.net\src\core\Akka\IO\UdpConnected.cs",
"region": {
"startLine": 95,
"startColumn": 31,
"endLine": 95,
"endColumn": 38
}
}
},
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\akka.net\src\core\Akka\Pattern\BackoffOptions.cs",
"region": {
"startLine": 243,
"startColumn": 27,
"endLine": 243,
"endColumn": 38
}
}
},
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\akka.net\src\core\Akka\Routing\Listeners.cs",
"region": {
"startLine": 37,
"startColumn": 27,
"endLine": 37,
"endColumn": 42
}
}
},
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\akka.net\src\core\Akka\Routing\RouterMsg.cs",
"region": {
"startLine": 31,
"startColumn": 27,
"endLine": 31,
"endColumn": 50
}
}
}
]
}
@@ -0,0 +1,30 @@
{
"issues": [
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\akka.net\src\benchmark\Akka.Benchmarks\IO\TcpOperationsBenchmarks.cs",
"region": {
"startLine": 76,
"startColumn": 22,
"endLine": 76,
"endColumn": 43
}
}
},
{
"id": "S2094",
"message": "Remove this empty class, or add members to it.",
"location": {
"uri": "sources\akka.net\src\benchmark\Akka.Benchmarks\IO\TcpOperationsBenchmarks.cs",
"region": {
"startLine": 77,
"startColumn": 22,
"endLine": 77,
"endColumn": 48
}
}
}
]
}