Skip to content

Coverage is not reported to SonarQube for arrow methods with switch expression #3614

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

Closed
pavel-mikula-sonarsource opened this issue Sep 16, 2020 · 2 comments
Assignees
Labels
Area: SQ Plugin Java plugin related issues.

Comments

@pavel-mikula-sonarsource
Copy link
Contributor

Description

Commits https://github.com/SonarSource/sonar-security/commit/1992fc358f3a13dc2507b8d9f73dbd666c62bea6#diff-57cab5d80bb97473841c562f5d5f0151 with UcfgHelper.ToUcfgMethodId and https://github.com/SonarSource/sonar-security/commit/406fbd25cefdfa07f0f4b00deae1fb498f06e558#diff-c2287e8d7be5c41185e26e6f04f2152e AutoPropertyUcfgBuilder.CreateInstructions introduced refactoring from body method with switch statement to arrow method returning a switch expression.

Methods appears to have zero line coverage on all lines. They are 100% covered according to coverage.opencover.xml. The first one is actually visited 2580 times :)

@pavel-mikula-sonarsource pavel-mikula-sonarsource added the Area: SQ Plugin Java plugin related issues. label Sep 16, 2020
@pavel-mikula-sonarsource pavel-mikula-sonarsource added this to the 8.14 milestone Sep 16, 2020
@costin-zaharia-sonarsource
Copy link
Member

costin-zaharia-sonarsource commented Sep 17, 2020

coverlet-coverage/coverlet#936 seems to be the source for this.

@costin-zaharia-sonarsource
Copy link
Member

The issue can be easily reproducible with the following snippet:

public static int Compute(object x)
{
    return x switch
    {
        int number => number,
        string value => value.Length,
        _ => -1
    };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: SQ Plugin Java plugin related issues.
Projects
None yet
Development

No branches or pull requests

2 participants