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 S3532: default clauses with comments should not be reported #992

Closed
HamsterExAstris opened this issue Nov 25, 2017 · 1 comment
Closed
Assignees
Labels
Type: Bug Exceptions and blocking issues during analysis.
Milestone

Comments

@HamsterExAstris
Copy link

Description

Rule S131 ('"switch" statements should end with a "default" clause') triggers on a switch statement when a default case does not exist. Adding a clause that "contain(s) a suitable comment as to why no action is taken" is supposed to be a valid resolution for S131 per its descriptive text.

Rule S3532 ('Empty "default" clauses should be removed') triggers on a switch statement when a default case has no actual code. Even if there is a comment (per S131's resolution suggestions), this rule will still trigger.

Repro steps

Run the SonarQube scanner against the attached solution.

SonarQubeSwitching.zip

Expected behavior

When the default case contains a comment, S3532 is not triggered.

Actual behavior

A default case containing a comment but no other code triggers rule S3532.

Known workarounds

None.

Related information

  • SonarC# 5.10.1, though I don't see either of these rules as having been updated in a subsequent release
  • Visual Studio 2015
  • Scanner for MSBuild, 2.3.2.573
@valhristov valhristov changed the title S3532 should not consider default clauses with comments to be empty Fix S3532: default clauses with comments should not be reported Nov 27, 2017
@valhristov valhristov added Type: Bug Exceptions and blocking issues during analysis. Area: Rules labels Nov 27, 2017
@valhristov valhristov added this to the 6.8 milestone Nov 27, 2017
@valhristov
Copy link
Contributor

Thanks for pointing this problem, we will fix it in the near future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Exceptions and blocking issues during analysis.
Projects
None yet
Development

No branches or pull requests

3 participants