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 S2190 FN: Support indexer, conversion operator and event declaration #8464

Conversation

sagi1623
Copy link
Contributor

Fixes #6642
Fixes #6643
Fixes #6644

@pavel-mikula-sonarsource pavel-mikula-sonarsource changed the title FN S2190: No issues raised if recursion is inside indexer, conversion operator or event declaration Fix S2190 FN: Support indexer, conversion operator and event declaration Dec 14, 2023
@cristian-ambrosini-sonarsource
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@cristian-ambrosini-sonarsource
Copy link
Contributor

Can you please increase the coverage and fix the 3 issues?

@sagi1623
Copy link
Contributor Author

I fixed the code smells and opened an issue for the rest of the FPs that remain in the file. Regarding the coverage I could not come up with any valid or invalid code snippet that would cover the cases, however I would rather leave it there as defensive coding than to create AD0001s if anything changes in Roslyn.

@cristian-ambrosini-sonarsource
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link

sonarcloud bot commented Jan 15, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

sonarcloud bot commented Jan 15, 2024

Quality Gate Failed Quality Gate failed

Failed conditions

85.5% Coverage on New Code (required ≥ 95%)

See analysis details on SonarCloud

Copy link
Contributor

Choose a reason for hiding this comment

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

Left few ideas to bump the coverage

OperationKindEx.Binary =>
IBinaryOperationWrapper.FromOperation(operation).OperatorMethod,
OperationKindEx.Decrement =>
IIncrementOrDecrementOperationWrapper.FromOperation(operation).OperatorMethod,

Choose a reason for hiding this comment

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

It's weird because this line is tested in InfiniteRecursion.CSharp11.cs through:

public class Decrement : IDecrementOperators<Decrement>
{
    public static Decrement operator --(Decrement val) => --val; // Noncompliant
}

same for Unary:

public class BitWise : IBitwiseOperators<BitWise, BitWise, BitWise>
{
    public static BitWise operator ~(BitWise value) => ~value; // Noncompliant
    public static BitWise operator &(BitWise left, BitWise right) => left & right; // Noncompliant
    public static BitWise operator |(BitWise left, BitWise right) => left | right; // Noncompliant
    public static BitWise operator ^(BitWise left, BitWise right) => left ^ right; // Noncompliant
}

but the code coverage tool is not detecting those lines as covered.

@mary-georgiou-sonarsource mary-georgiou-sonarsource force-pushed the AraGimLeg/InfiniteRecursion branch 3 times, most recently from e1a8872 to a687f6d Compare June 3, 2024 12:12
@mary-georgiou-sonarsource
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mary-georgiou-sonarsource
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mary-georgiou-sonarsource
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mary-georgiou-sonarsource
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@CristianAmbrosini CristianAmbrosini left a comment

Choose a reason for hiding this comment

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

LGTM! Feel free to rebase and merge

@CristianAmbrosini
Copy link
Contributor

@sagi1623 Freedom! Finally 😄

Revert "apply comments and codestyle fixes"

This reverts commit 35c6c8f.

minor cleanup

revert accidental change
@mary-georgiou-sonarsource
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mary-georgiou-sonarsource
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mary-georgiou-sonarsource
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link

sonarcloud bot commented Jun 7, 2024

Quality Gate Passed Quality Gate passed for 'Sonar .NET Java Plugin'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

sonarcloud bot commented Jun 7, 2024

@mary-georgiou-sonarsource mary-georgiou-sonarsource merged commit 1413694 into SonarSource:master Jun 7, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants