omise/omise-node

View on GitHub

Showing 5 of 14 total issues

Function resourceActions has 114 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports.resourceActions = function(name, actions, options) {
  const path = resourcePath(name);
  return _.pick({
    create: function(data, callback) {
      return api.post(_makeOptions(options, path(), data), callback);
Severity: Major
Found in lib/apiResources.js - About 4 hrs to fix

    Function resourceActions has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports.resourceActions = function(name, actions, options) {
      const path = resourcePath(name);
      return _.pick({
        create: function(data, callback) {
          return api.post(_makeOptions(options, path(), data), callback);
    Severity: Minor
    Found in lib/apiResources.js - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function _responseHandler has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function _responseHandler(req) {
      return new Promise(function(resolve, reject) {
        req.on('response', function(res) {
          let resp = '';
          res.setEncoding('utf8');
    Severity: Minor
    Found in lib/api.js - About 1 hr to fix

      Function _nestedPathOptions has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function _nestedPathOptions(opts, pathObj, resource, id, data) {
      Severity: Minor
      Found in lib/apiResources.js - About 35 mins to fix

        Function log has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        logger.log = function(level, message) {
          const levels = ['error', 'warn', 'info'];
          if (levels.indexOf(level) >= levels.indexOf(logger.debugLevel)) {
            if (typeof message !== 'string') {
              message = JSON.stringify(message);
        Severity: Minor
        Found in lib/logger.js - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Severity
        Category
        Status
        Source
        Language