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 returning false errors #924

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

require-returns-check returning false errors #924

rpastro opened this issue Oct 22, 2022 · 2 comments

Comments

@rpastro
Copy link

rpastro commented Oct 22, 2022

Expected behavior

There should be no jsdoc/require-returns-check errors reported for the functions below. This was working correctly with eslint-plugin-jsdoc v39.3.14.

/**
 * Return a V1 style query identifier.
 *
 * @param {string} id - The query identifier.
 * @returns {string} V1 style query identifier.
 */
function v1QueryId(id) {
    switch (id.substring(0, 4)) {
        case 'addq':
        case 'aliq':
        case 'locq':
            return id.substring(3);
        case 'lost':
            return id.substring(4);
        default:
            return id;
    }
}

/**
 * Parses the required header fields for the given SIP message.
 *
 * @param {string} logPrefix - The log prefix.
 * @param {string} sipMessage - The SIP message.
 * @param {string[]} headers - The header fields to be parsed.
 * @returns {object} Object with parsed header fields.
 */
function parseSipHeaders(logPrefix, sipMessage, headers) {
    try {
        return esappSip.parseHeaders(sipMessage, headers);
    } catch (err) {
        logger.error(logPrefix, `Failed to parser SIP header(s): ${headers}. ${err}\nMessage:${sipMessage}`);
        return {};
    }
}

Actual behavior

After upgrading to v39.3.19 both functions above return a jsdoc/require-returns-check error.

/test/common.js
  125:1  error  JSDoc @returns declaration present but return expression not available in function  jsdoc/require-returns-check

/test/eventWriter.js
  46:1  error  JSDoc @returns declaration present but return expression not available in function  jsdoc/require-returns-check

ESLint Config

    "rules":   {
        "jsdoc/require-returns-check": 2
    }

Environment

  • Node version: 18.11.0
  • ESLint version: 8.26.0
  • eslint-plugin-jsdoc version: 39.3.19
@gajus
Copy link
Owner

gajus commented Oct 23, 2022

🎉 This issue has been resolved in version 39.3.20 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label Oct 23, 2022
@brettz9
Copy link
Collaborator

brettz9 commented Oct 23, 2022

Thanks for the report. Some changes needed to be made in an earlier release as the rule was not catching missing return statements from certain branches of execution (if at least one valid return was present). The new logic may still have some gaps, so feel free to report any other such issues. Thanks!

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