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

feat: Detect useless break #48

Merged
merged 1 commit into from
Aug 1, 2024
Merged

feat: Detect useless break #48

merged 1 commit into from
Aug 1, 2024

Conversation

notJoon
Copy link
Contributor

@notJoon notJoon commented Aug 1, 2024

Description

Add new lint rule to detect useless break statement in switch and select (go specific) clauses.

Details

This lint works as follows:

  1. It traverses the AST of the given file.
  2. For each switch or select statement encountered:
    • It examines each case clause.
    • If the last statement in a case clause is an unabled break, it's flagged as useless.
  3. Each useless break detected is reported.

Covered Scenarios

  • No useless breaks
  • Useless breaks in switch statements
  • Useless breaks in select statements
  • Labeled breaks (which are not considered useless)

@notJoon notJoon added the A-lint Adding or updating lint label Aug 1, 2024
@notJoon notJoon merged commit 3fad018 into main Aug 1, 2024
3 checks passed
@notJoon notJoon deleted the useless-break branch August 1, 2024 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Adding or updating lint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant