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

VB.NET HasExactlyNArguments method considers null argument list and 0 arguments the same. #7458

Merged
merged 4 commits into from
Jun 20, 2023

Conversation

mary-georgiou-sonarsource
Copy link
Contributor

@mary-georgiou-sonarsource mary-georgiou-sonarsource commented Jun 16, 2023

In VB.NET a method can be called by invocation, for example, d.Dispose(), but it can be called also without the parentheses via member access d.Dispose.
So having an argument list with 0 arguments and having no argument list at all is the same thing in VB.NET context.

@mary-georgiou-sonarsource mary-georgiou-sonarsource marked this pull request as draft June 16, 2023 13:40
@mary-georgiou-sonarsource mary-georgiou-sonarsource changed the title VB.NET HasExactlyNArguments method considers null and 0 arguments the same. VB.NET HasExactlyNArguments method consider null argument list and 0 arguments the same. Jun 16, 2023
@mary-georgiou-sonarsource mary-georgiou-sonarsource marked this pull request as ready for review June 19, 2023 08:12
@mary-georgiou-sonarsource mary-georgiou-sonarsource marked this pull request as draft June 19, 2023 08:12
@mary-georgiou-sonarsource mary-georgiou-sonarsource added the Area: C# C# rules related issues. label Jun 19, 2023
@mary-georgiou-sonarsource mary-georgiou-sonarsource added Area: VB.NET VB.NET rules related issues. Type: Improvement and removed Area: C# C# rules related issues. labels Jun 19, 2023
Copy link
Contributor

@pavel-mikula-sonarsource pavel-mikula-sonarsource left a comment

Choose a reason for hiding this comment

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

Let's delete some code. Try both variants to see the idea and choose what will seem nicer

Copy link
Contributor

@pavel-mikula-sonarsource pavel-mikula-sonarsource left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 34 to 35
? count == 0
: invocation.ArgumentList.Arguments.Count == count;
Copy link
Contributor

Choose a reason for hiding this comment

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

Whitespace

Suggested change
? count == 0
: invocation.ArgumentList.Arguments.Count == count;
? count == 0
: invocation.ArgumentList.Arguments.Count == count;

@@ -30,7 +30,9 @@ internal static class InvocationExpressionSyntaxExtensions
invocation.ArgumentList.Arguments.GetSymbolsOfKnownType(knownType, semanticModel);

internal static bool HasExactlyNArguments(this InvocationExpressionSyntax invocation, int count) =>
invocation?.ArgumentList != null && invocation.ArgumentList.Arguments.Count == count;
invocation?.ArgumentList == null
Copy link
Contributor

Choose a reason for hiding this comment

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

Better null check

Suggested change
invocation?.ArgumentList == null
invocation?.ArgumentList is null

@mary-georgiou-sonarsource mary-georgiou-sonarsource marked this pull request as ready for review June 19, 2023 09:22
@mary-georgiou-sonarsource mary-georgiou-sonarsource changed the title VB.NET HasExactlyNArguments method consider null argument list and 0 arguments the same. VB.NET HasExactlyNArguments method considers null argument list and 0 arguments the same. Jun 19, 2023
@sonarcloud
Copy link

sonarcloud bot commented Jun 19, 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 Jun 19, 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

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@mary-georgiou-sonarsource mary-georgiou-sonarsource merged commit 6c51f93 into master Jun 20, 2023
22 checks passed
@mary-georgiou-sonarsource mary-georgiou-sonarsource deleted the mary/update-hasNArguments branch June 20, 2023 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: VB.NET VB.NET rules related issues.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants