Increase the complexity score threshold at which a function is flagged

I would like to be able to increase the complexity score threshold at which a function is flagged.

Reason:
Sometimes it flags a function which I feel is perfectly reasonable but I don’t like to have to see the warning every time I run.

For example, I have one function that I have done my best to simplify. I don’t want to split it up any further but still I get the warning that complexity is 9. I feel its the best it can be and I’d like to not see the warning when I run validate.

Here is example code of the function. I finally figured out to create the “Log()” function to get complexity down to an 8,

function Log() {
  if(exports.debug) log.log.apply(null, arguments);
}

// sync method for GET/POST/PUT requests.
async function _syncReq(method, url, headers, body={}, caller) {
    Log('=', 'HTTP REQUEST -> URL:', method.toUpperCase(), url, body)
    try { 
      let res = await _asyncRequest(method, url, headers, body)
      Log(res)
      if(res.headers['content-type'].includes('text/html')) {
        // HTML in response. Some kind of syntax error.
        throw( { msg_history: `Likely API syntax error (HTML in Response) in ${method} ${url}.`, call_history:'_syncReq'} )
      }
      delete res.headers  // Not useful in debug. Cut down on log clutter 
      Log('HTTP Response -> Status:',res.status, 'res.attempts:', res.attempts)
      let response=JSON.parse(res.response)
      Log(response, '=', '=')
      return response
    } catch(e) { 
      Log("Error with", method.toUpperCase(), url, e)
      e.caller = caller + "-> syncReq"
      throw( e )
    }
}

This topic was automatically closed after 365 days. New replies are no longer allowed.