dimitri-koenig/simple-vertec-api

View on GitHub
lib/simple-vertec-api.js

Summary

Maintainability
C
1 day
Test Coverage

File simple-vertec-api.js has 303 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import _ from 'lodash';
import SimpleXmlConverter from 'simple-xml-converter';
import ParamsInjector from 'simple-parameter-injector';
import xmlDigester from 'xml-digester';
import q from 'bluebird';
Severity: Minor
Found in lib/simple-vertec-api.js - About 3 hrs to fix

    SimpleVertecApi has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class SimpleVertecApi {
        constructor(xmlUrl, authUrl, username, password, verbose, defaultRequestOptions) { // eslint-disable-line max-params
            vertecXmlUrl = xmlUrl;
            vertecAuthUrl = authUrl;
            vertecUsername = username;
    Severity: Minor
    Found in lib/simple-vertec-api.js - About 2 hrs to fix

      Function doRequest has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          doRequest(xmlString) {
              let requestOptions = _.extend({
                  uri: vertecXmlUrl,
                  method: 'POST',
                  headers: {
      Severity: Major
      Found in lib/simple-vertec-api.js - About 2 hrs to fix

        Function save has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            save() {
                let saveData = [];
        
                if (arguments.length === 1 && _.isArray(arguments[0])) {
                    saveData = arguments[0];
        Severity: Minor
        Found in lib/simple-vertec-api.js - About 1 hr to fix

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

              log() {
                  /* istanbul ignore next: makes no sense to test this */
                  if (this.verbose === true) {
                      let content;
                      for (let i = 0; i < arguments.length; i++) {
          Severity: Minor
          Found in lib/simple-vertec-api.js - About 55 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

          Function buildSelectObject has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              buildSelectObject() {
                  let query = arguments[0];
                  let params = arguments.length === 3 ? arguments[1] : null;
                  let fields = arguments.length === 3 ? arguments[2] : arguments[1];
          
          
          Severity: Minor
          Found in lib/simple-vertec-api.js - About 45 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

          Function getAuthToken has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              getAuthToken() {
                  if (this.authTokenPromise) {
                      return this.authTokenPromise;
                  }
          
          
          Severity: Minor
          Found in lib/simple-vertec-api.js - About 35 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

          Function requestRetryStrategy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              requestRetryStrategy(err, response) {
                  let check = (err !== null)
                      || !_.isObject(response)
                      || (response.statusCode > 400)
                      || (response.statusCode === 400 && (!_.isString(response.body) || (_.isString(response.body) && response.body.indexOf('token') === -1))) // we'll handle invalid tokens somewhere else
          Severity: Minor
          Found in lib/simple-vertec-api.js - About 35 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

          There are no issues that match your filters.

          Category
          Status