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

Fix S3415 FP/FN: Support named arguments #6759

Merged
merged 28 commits into from Mar 8, 2023
Merged

Conversation

Tim-Pohlmann
Copy link
Contributor

Fixes #6630

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like the duality of

    public IMethodSymbol MethodSymbol { get; }
    private SymbolInfo? MethodSymbolInfo { get; }

in the class. Let's discuss if we can get rid of it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. Most comments are cosmetic.

Copy link
Contributor

Choose a reason for hiding this comment

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

Minor changes only.

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM

@martin-strecker-sonarsource
Copy link
Contributor

@martin-strecker-sonarsource
Copy link
Contributor

One final thing: there are 10 code smells. Can you please have a look? A few of them seem to be valid.

@Tim-Pohlmann
Copy link
Contributor Author

One final thing: there are 10 code smells. Can you please have a look? A few of them seem to be valid.

@martin-strecker-sonarsource I fixed one (even though I personally prefer switch over ternary operators) but the others seem to be false positives:

  • Remove array type (S3257): The type is not redundant. It will not compile without it.
  • Magic number (S109): 2 is just the number of arguments here. I don't think making it a constant makes sense.
  • Repeated use of string literal (S1192): While the literals are technically the same, they do not represent the same concept (parameters of different methods that just happen to have the same name) and thus should not be consolidated into a variable.
  • Nested type argument (S4017): This might be valid, but I cannot come up with a way to improve the code in a meaningful way.

Copy link
Contributor

Choose a reason for hiding this comment

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

There is a typo that should be fixed.

KnownAssertParameters knownParameters) =>
container.Is(knownParameters.AssertClass)
&& CSharpFacade.Instance.MethodParameterLookup(argumentList, symbol) is var parameterLookup
&& parameterLookup.TryGetSyntax(knownParameters.ExpectedParamterName, out var expectedArguments)

Choose a reason for hiding this comment

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

Typo

Suggested change
&& parameterLookup.TryGetSyntax(knownParameters.ExpectedParamterName, out var expectedArguments)
&& parameterLookup.TryGetSyntax(knownParameters.ExpectedParameterName, out var expectedArguments)

&& semanticModel.GetConstantValue(expected).HasValue is false
&& parameterLookup.TryGetSyntax(knownParameters.ActualParameterName, out var actualArguments)
&& actualArguments.FirstOrDefault() is { } actual
&& semanticModel.GetConstantValue(actual).HasValue is true

Choose a reason for hiding this comment

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

Suggested change
&& semanticModel.GetConstantValue(actual).HasValue is true
&& semanticModel.GetConstantValue(actual).HasValue

@sonarcloud
Copy link

sonarcloud bot commented Mar 6, 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 Mar 6, 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

98.9% 98.9% 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

@Tim-Pohlmann Tim-Pohlmann merged commit d73c2cc into master Mar 8, 2023
@Tim-Pohlmann Tim-Pohlmann deleted the Tim/Fix-3415-FP branch March 8, 2023 08:03
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.

Fix S3415 FP/FN: Support named arguments
2 participants