jscs-dev / jscs-jsdoc

JsDoc validation rules for jscs
MIT License
99 stars 35 forks source link

AssertionError with missing braces and multi-line description in @returns tag #185

Open pabigot opened 8 years ago

pabigot commented 8 years ago

Reproduced with node-jscs, but from the stack trace I think the issue lies here.

The following source code:

/**
 * Description.
 *
 * @param {integer} v - value v
 *
 * @param {integer} w - value w
 *
 * @returns string - `v`
 * plus `w` as a string
 */
function f(v, w) {
  return (v + w).toString(16);
}

when processed with a .jscsrc holding:

{
  "preset": "google"
}

produces for me:

Error running rule jsDoc: This is an issue with JSCS and not your codebase.
Please file an issue (with the stack trace below) at: https://github.com/jscs-dev/node-jscs/issues/new
AssertionError: Unable to add an error, `column` should be a positive number but -1 given
    at Object.Errors._validateInput (/tmp/foo/node_modules/jscs/lib/errors.js:73:9)
    at Object.Errors.add (/tmp/foo/node_modules/jscs/lib/errors.js:46:14)
    at addError (/tmp/foo/node_modules/jscs/node_modules/jscs-jsdoc/lib/rules/validate-jsdoc.js:166:28)
    at /tmp/foo/node_modules/jscs/node_modules/jscs-jsdoc/lib/rules/validate-jsdoc.js:181:25
    at Object.requireReturnTypes (/tmp/foo/node_modules/jscs/node_modules/jscs-jsdoc/lib/rules/validate-jsdoc/require-return-types.js:17:9)
    at /tmp/foo/node_modules/jscs/node_modules/jscs-jsdoc/lib/rules/validate-jsdoc.js:145:27
    at Array.forEach (native)
    at DocComment.<anonymous> (/tmp/foo/node_modules/jscs/node_modules/jscs-jsdoc/lib/rules/validate-jsdoc.js:144:46)
    at Array.forEach (native)
    at DocComment.forEachTag [as iterate] (/tmp/foo/node_modules/jscs/node_modules/jscs-jsdoc/lib/jsdoc.js:86:19) at lib/foo.js :
     1 |/**
--------^
     2 | * Description.
     3 | *

1 code style error found.

Putting the missing braces around the type in the @returns statement fixes this, as does joining the two lines of the @returns description into one line, if that helps track down the origin of the problem.

qfox commented 8 years ago

Thanks for report. Looking at it.