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

Conversation

cristian-ambrosini-sonarsource
Copy link
Contributor

Fixes #6657

@@ -0,0 +1,31 @@
<p>There’s no point in creating an array solely for the purpose of passing it as a params (<code>...</code>) argument; params keyword allow to pass a

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a params (...) argument

This refers to varargs in java. This needs to be adopted. Make sure it is fixed in the RSpec PR.

@@ -0,0 +1,30 @@
<p>There’s no point in creating an array solely for the purpose of passing it as a ParamArray (<code>...</code>) argument; ParamArray keyword allow to

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Copy link
Contributor

@martin-strecker-sonarsource martin-strecker-sonarsource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only minor changes. I think you are done! Good job. Please have a look at the code smell as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default cases need to be added back and the new test case for the exception should be standalone.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can improve precision in C# and VB a bit. There are some confusing cases with VB array initializers that need some more effort.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VB behavior looks good now. Most remaining work is more stylistic. I'm not sure about removing one restriction in C#.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some pattern magic left.

@sonarcloud
Copy link

sonarcloud bot commented Feb 1, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented Feb 1, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

92.2% 92.2% Coverage
0.0% 0.0% Duplication

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @pavel-mikula-sonarsource please merge. Code coverage can not be improved because the default case is untestable. It is there for defensive coding.

@pavel-mikula-sonarsource pavel-mikula-sonarsource merged commit 49f172c into master Feb 1, 2023
@pavel-mikula-sonarsource pavel-mikula-sonarsource deleted the cristian/S3878 branch February 1, 2023 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New rule S3878: Arrays should not be created for params parameters
4 participants