Skip to content

Conversation

@dpobel
Copy link
Contributor

@dpobel dpobel commented Oct 12, 2016

@ezrobot
Copy link

ezrobot commented Oct 12, 2016

yuidoc reports the following documentation warnings:

YUIDoc found 1 lint errors in your docs
#1 replacing incorrect tag: parma with param  src/services/ContentService.js:563

*
* @method loadUserDrafts
* @param userId {String} target user identifier (e.g. "/api/ezp/v2/user/users/14")
* @parma [headers] {Object} additional headers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should specify it acts as callback if callback is not set for bc, same below :)

Copy link
Contributor Author

@dpobel dpobel Oct 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the [ and ] around headers means the parameter is not mandatory so that's kind of implied but to be honest, the documentation was not really my main purpose here :-)
That said, this is a good point because we could also do the same thing by keeping 2 parameters on the method and allowing the first one to be an option object:

/**
  * bla bla
  *
  * @param {String|Object} options the userId or an object containing the userId and others options
  * @param {String} options.userId
  * @param {Object} options.headers additional headers
  * @param {Function} callback
  */
ContentService.prototype.loadUserDrafts = function (options, callback) {
    var userId = options, headers = {};

    if ( typeof options === "object" ) {
        userId = options.userId;
        headers = options.headers || headers;
    }
    // ...
};

and I'm not really sure which approach is the best

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jul 1, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@dpobel dpobel closed this Dec 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants