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

require-returns-check: false-positive with break in switch in other switch #923

Closed
regseb opened this issue Oct 22, 2022 · 2 comments
Closed

Comments

@regseb
Copy link

regseb commented Oct 22, 2022

Expected behavior

If a switch contains another switch with a break, the require-returns-check rule shouldn't report an error.

Actual behavior

If a switch contains another switch with a break, the require-returns-check rule report an error.

ESLint Config (in package.json)

{
    "name": "testcase",
    "version": "1.0.0",
    "private": true,
    "dependencies": {
        "eslint": "8.26.0",
        "eslint-plugin-jsdoc": "39.3.17"
    },
    "eslintConfig": {
        "plugins": ["jsdoc"],
        "rules": {
            "jsdoc/require-returns-check": 2
        }
    }
}

ESLint sample

/**
 * @returns Baz.
 */
function foo() {
    switch (true) {
        default:
            switch (true) {
                default: break;
            }
            return "baz";
    }
};

Environment

  • Node version: v18.11.0
  • ESLint version 8.26.0
  • eslint-plugin-jsdoc version: 39.3.17

Additional info

The problem started in version 39.3.15.
Maybe the require-returns-check rule thinks that the break applies to the highest switch.

@brettz9
Copy link
Collaborator

brettz9 commented Oct 22, 2022

Thanks for the report. This should be fixed now, but just be aware the code for checking all branches is fresh and is somewhat involved, so there may be some other areas needing improvement.

@gajus
Copy link
Owner

gajus commented Oct 22, 2022

🎉 This issue has been resolved in version 39.3.18 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label Oct 22, 2022
crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this issue Oct 24, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) | devDependencies | patch | [`39.3.14` -> `39.3.21`](https://renovatebot.com/diffs/npm/eslint-plugin-jsdoc/39.3.14/39.3.21) |

---

### Release Notes

<details>
<summary>gajus/eslint-plugin-jsdoc</summary>

### [`v39.3.21`](https://github.com/gajus/eslint-plugin-jsdoc/releases/tag/v39.3.21)

[Compare Source](gajus/eslint-plugin-jsdoc@v39.3.20...v39.3.21)

##### Bug Fixes

-   **`require-param`:** do not cache by comment node; fixes [#&#8203;901](gajus/eslint-plugin-jsdoc#901) ([867edc3](gajus/eslint-plugin-jsdoc@867edc3))

### [`v39.3.20`](https://github.com/gajus/eslint-plugin-jsdoc/releases/tag/v39.3.20)

[Compare Source](gajus/eslint-plugin-jsdoc@v39.3.19...v39.3.20)

##### Bug Fixes

-   **`require-returns-check`:** allow for missing catch or finalizer and missing case contents; fixes [#&#8203;924](gajus/eslint-plugin-jsdoc#924) ([4fabdd6](gajus/eslint-plugin-jsdoc@4fabdd6))

### [`v39.3.19`](https://github.com/gajus/eslint-plugin-jsdoc/releases/tag/v39.3.19)

[Compare Source](gajus/eslint-plugin-jsdoc@v39.3.18...v39.3.19)

##### Bug Fixes

-   **`require-param`:** be tolerant if `this` is not included as `[@param](https://github.com/param)`; fixes [#&#8203;919](gajus/eslint-plugin-jsdoc#919) ([c1f21f8](gajus/eslint-plugin-jsdoc@c1f21f8))

### [`v39.3.18`](https://github.com/gajus/eslint-plugin-jsdoc/releases/tag/v39.3.18)

[Compare Source](gajus/eslint-plugin-jsdoc@v39.3.17...v39.3.18)

##### Bug Fixes

-   **`require-returns-check`:** check child nodes of consequents; fixes [#&#8203;923](gajus/eslint-plugin-jsdoc#923) ([dc1f875](gajus/eslint-plugin-jsdoc@dc1f875))

### [`v39.3.17`](https://github.com/gajus/eslint-plugin-jsdoc/releases/tag/v39.3.17)

[Compare Source](gajus/eslint-plugin-jsdoc@v39.3.16...v39.3.17)

##### Bug Fixes

-   **`require-returns-check`:** throw statements to be exempted from final check if elsewhere in function; fixes [#&#8203;892](gajus/eslint-plugin-jsdoc#892) ([87c1c2a](gajus/eslint-plugin-jsdoc@87c1c2a))

### [`v39.3.16`](https://github.com/gajus/eslint-plugin-jsdoc/releases/tag/v39.3.16)

[Compare Source](gajus/eslint-plugin-jsdoc@v39.3.15...v39.3.16)

##### Bug Fixes

-   **`check-param-names`:** tolerate documented "this" param; fixes [#&#8203;919](gajus/eslint-plugin-jsdoc#919) ([5d20bdf](gajus/eslint-plugin-jsdoc@5d20bdf))

### [`v39.3.15`](https://github.com/gajus/eslint-plugin-jsdoc/releases/tag/v39.3.15)

[Compare Source](gajus/eslint-plugin-jsdoc@v39.3.14...v39.3.15)

##### Bug Fixes

-   **`require-returns-check`:** checks that all branches of final node return; fixes [#&#8203;892](gajus/eslint-plugin-jsdoc#892) ([bdd6af2](gajus/eslint-plugin-jsdoc@bdd6af2))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yNDEuOCIsInVwZGF0ZWRJblZlciI6IjMyLjI0MS4xMCJ9-->

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1600
Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants