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 S3878: Arrays should not be created for params parameters #6666

Merged
merged 40 commits into from Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
05a79ca
RSPEC baseline
CristianAmbrosini Jan 23, 2023
ca10a13
Packaging test
CristianAmbrosini Jan 23, 2023
c67118e
Rule file creation, baseline
CristianAmbrosini Jan 23, 2023
9acb038
First batch of test cases
CristianAmbrosini Jan 24, 2023
6f0f2e5
First rule sketch with test cases (cs/vb)
CristianAmbrosini Jan 24, 2023
08d227d
Common code to baseclass
CristianAmbrosini Jan 24, 2023
eebe4d4
Move semanticModel queries after syntax checks
CristianAmbrosini Jan 24, 2023
044fd0d
Add test case
CristianAmbrosini Jan 24, 2023
0916ce7
Fix some code smell
CristianAmbrosini Jan 24, 2023
c556aa3
Update the list of expected issues
CristianAmbrosini Jan 25, 2023
cdc92e9
Add support for ObjectCreationExpression
CristianAmbrosini Jan 25, 2023
41b040c
Add VB test cases
CristianAmbrosini Jan 25, 2023
c4f07c6
Defensive checks and fix ITs for ObjectCreation
CristianAmbrosini Jan 25, 2023
1f4ecab
Fix code smell
CristianAmbrosini Jan 25, 2023
27b74e9
Shared method
CristianAmbrosini Jan 25, 2023
5ba1351
Cheching method parameter to fix FN/FP
CristianAmbrosini Jan 25, 2023
a2db8b6
Fixed CSharp constructor named argument FP
CristianAmbrosini Jan 26, 2023
469aacd
Small fix
CristianAmbrosini Jan 26, 2023
fa8491c
Rule rewriting, semplifications
CristianAmbrosini Jan 26, 2023
ee448f6
Removed unused helper class
CristianAmbrosini Jan 26, 2023
f7b83b1
Added Indexer(CS) and Properties(VB) FN
CristianAmbrosini Jan 27, 2023
5517d4f
Fix UT
CristianAmbrosini Jan 27, 2023
89d245f
Second round of comments
CristianAmbrosini Jan 27, 2023
58a200e
Fix ITs
CristianAmbrosini Jan 27, 2023
e6b7386
Moving stuff to the base class
CristianAmbrosini Jan 27, 2023
3b890f5
ParamsInvocationKinds
CristianAmbrosini Jan 27, 2023
86f80c5
Code smell fix
CristianAmbrosini Jan 27, 2023
055c76d
Addressed more PR comments
CristianAmbrosini Jan 27, 2023
fcc244f
More restrictive access modifier
CristianAmbrosini Jan 27, 2023
1b4ed98
Add support for implicit object creation expression
CristianAmbrosini Jan 29, 2023
b6e651e
CSharp9 test case with TopLevelStatements
CristianAmbrosini Jan 30, 2023
a9c6530
Removed switch default case
CristianAmbrosini Jan 30, 2023
6bcca9e
Add test case for ArgumentException
CristianAmbrosini Jan 30, 2023
926be7c
Standalone ThrowsException tests
CristianAmbrosini Jan 30, 2023
51095bb
Increased precision for VB
CristianAmbrosini Jan 31, 2023
0e31460
Add coverage for CS ImplicitArrayCreation
CristianAmbrosini Jan 31, 2023
5e61ae9
Fix UTs
CristianAmbrosini Jan 31, 2023
cfab8c1
Fix ITs
CristianAmbrosini Jan 31, 2023
d5ce51b
Stylistic fix + Noncompliant CS empty array
CristianAmbrosini Feb 1, 2023
500870c
Addressed PR comments
CristianAmbrosini Feb 1, 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
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -12,7 +12,7 @@ languages in [SonarQube](http://www.sonarqube.org/), [SonarCloud](https://sonarc

## Features

* [370+ C# rules](https://rules.sonarsource.com/csharp) and [170+ VB.​NET rules](https://rules.sonarsource.com/vbnet)
* [380+ C# rules](https://rules.sonarsource.com/csharp) and [170+ VB.​NET rules](https://rules.sonarsource.com/vbnet)
* Metrics (cognitive complexity, duplications, number of lines etc.)
* Import of [test coverage reports](https://community.sonarsource.com/t/9871) from Visual Studio Code Coverage, dotCover, OpenCover, Coverlet, Altcover.
* Import of third party Roslyn Analyzers results
Expand Down
@@ -0,0 +1,342 @@
{
"issues": [
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
martin-strecker-sonarsource marked this conversation as resolved.
Show resolved Hide resolved
martin-strecker-sonarsource marked this conversation as resolved.
Show resolved Hide resolved
"region": {
"startLine": 6583,
"startColumn": 71,
"endLine": 6583,
"endColumn": 102
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
martin-strecker-sonarsource marked this conversation as resolved.
Show resolved Hide resolved
"region": {
"startLine": 6881,
"startColumn": 47,
"endLine": 6881,
"endColumn": 94
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
martin-strecker-sonarsource marked this conversation as resolved.
Show resolved Hide resolved
"region": {
"startLine": 6882,
"startColumn": 47,
"endLine": 6882,
"endColumn": 130
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
martin-strecker-sonarsource marked this conversation as resolved.
Show resolved Hide resolved
"region": {
"startLine": 6883,
"startColumn": 47,
"endLine": 6883,
"endColumn": 130
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
martin-strecker-sonarsource marked this conversation as resolved.
Show resolved Hide resolved
"region": {
"startLine": 6884,
"startColumn": 47,
"endLine": 6884,
"endColumn": 132
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
martin-strecker-sonarsource marked this conversation as resolved.
Show resolved Hide resolved
"region": {
"startLine": 6885,
"startColumn": 47,
"endLine": 6885,
"endColumn": 79
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
martin-strecker-sonarsource marked this conversation as resolved.
Show resolved Hide resolved
"region": {
"startLine": 7017,
"startColumn": 47,
"endLine": 7017,
"endColumn": 93
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
martin-strecker-sonarsource marked this conversation as resolved.
Show resolved Hide resolved
"region": {
"startLine": 7018,
"startColumn": 47,
"endLine": 7018,
"endColumn": 94
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
"region": {
"startLine": 7019,
"startColumn": 47,
"endLine": 7019,
"endColumn": 83
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
"region": {
"startLine": 7020,
"startColumn": 47,
"endLine": 7020,
"endColumn": 83
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
"region": {
"startLine": 7021,
"startColumn": 47,
"endLine": 7021,
"endColumn": 80
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
"region": {
"startLine": 7022,
"startColumn": 47,
"endLine": 7022,
"endColumn": 84
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
"region": {
"startLine": 7023,
"startColumn": 47,
"endLine": 7023,
"endColumn": 80
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
"region": {
"startLine": 7024,
"startColumn": 47,
"endLine": 7024,
"endColumn": 82
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
"region": {
"startLine": 7025,
"startColumn": 47,
"endLine": 7025,
"endColumn": 80
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
"region": {
"startLine": 7026,
"startColumn": 47,
"endLine": 7026,
"endColumn": 97
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
"region": {
"startLine": 7027,
"startColumn": 47,
"endLine": 7027,
"endColumn": 101
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
"region": {
"startLine": 7028,
"startColumn": 47,
"endLine": 7028,
"endColumn": 97
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
martin-strecker-sonarsource marked this conversation as resolved.
Show resolved Hide resolved
"region": {
"startLine": 7107,
"startColumn": 43,
"endLine": 7107,
"endColumn": 137
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
martin-strecker-sonarsource marked this conversation as resolved.
Show resolved Hide resolved
"region": {
"startLine": 7109,
"startColumn": 47,
"endLine": 7109,
"endColumn": 141
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
martin-strecker-sonarsource marked this conversation as resolved.
Show resolved Hide resolved
"region": {
"startLine": 7111,
"startColumn": 43,
"endLine": 7111,
"endColumn": 75
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
martin-strecker-sonarsource marked this conversation as resolved.
Show resolved Hide resolved
"region": {
"startLine": 7193,
"startColumn": 47,
"endLine": 7193,
"endColumn": 96
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
"region": {
"startLine": 7194,
"startColumn": 47,
"endLine": 7194,
"endColumn": 130
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
"region": {
"startLine": 7195,
"startColumn": 47,
"endLine": 7195,
"endColumn": 130
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
"region": {
"startLine": 7196,
"startColumn": 47,
"endLine": 7196,
"endColumn": 134
}
}
},
{
"id": "S3878",
"message": "Remove this array creation and simply pass the elements.",
"location": {
"uri": "sources\Ember-MM\Ember%20Media%20Manager\frmMain.vb",
"region": {
"startLine": 7197,
"startColumn": 47,
"endLine": 7197,
"endColumn": 79
}
}
}
]
}