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

Add C#9 tests for S1186, S1116, S2291 , S2197, S4035, S4220 #3749

Merged
merged 7 commits into from
Nov 16, 2020

Conversation

andrei-epure-sonarsource
Copy link
Contributor

Related to #3668

Copy link
Member

Choose a reason for hiding this comment

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

LGTM! Just a few minor comments.

[TestCategory("Rule")]
public void EmptyMethod_CSharp9()
{
Verifier.VerifyAnalyzer(@"TestCases\EmptyMethod.CSharp9.cs",

Choose a reason for hiding this comment

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

It was intended to use this instead of VerifyAnalyzerFromCSharp9Console?

{
public string Prop
{
init { }

Choose a reason for hiding this comment

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

Shouldn't this be a FN since it's not an auto-implemented property?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the current rule only looks at methods, so it's the same behavior as for set.
I've opened #3753 to do it

Choose a reason for hiding this comment

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

Shouldn't we mark both as FNs then?

SomeStaticEvent?.Invoke(this, e); // Noncompliant {{Make the sender on this static event invocation null.}}
SomeStaticEvent?.Invoke(null, null); // Noncompliant {{Use 'EventArgs.Empty' instead of null as the event args of this event invocation.}}
SomeStaticEvent?.Invoke(this, null); // Noncompliant
// Noncompliant@-1

Choose a reason for hiding this comment

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

Should we add some cases with direct invocation like below?

SomeEvent(null, e);
SomeStaticEvent(null, null);

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

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

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@andrei-epure-sonarsource andrei-epure-sonarsource merged commit 530c8f4 into master Nov 16, 2020
@andrei-epure-sonarsource andrei-epure-sonarsource deleted the andrei/cs9-uts-10 branch November 16, 2020 10:42
Corniel pushed a commit to Corniel/sonar-csharp that referenced this pull request Nov 30, 2020
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.

2 participants