src/api/Api.js

Summary

Maintainability
D
1 day
Test Coverage

Function request has 135 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    request(method, url, data, options = {}) {
        checkType(method, 'string', 'Request type')
        checkType(url, 'string', 'Url')
        const api = this
        let requestUrl = url
Severity: Major
Found in src/api/Api.js - About 5 hrs to fix

    Function request has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        request(method, url, data, options = {}) {
            checkType(method, 'string', 'Request type')
            checkType(url, 'string', 'Url')
            const api = this
            let requestUrl = url
    Severity: Minor
    Found in src/api/Api.js - About 3 hrs 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

    File Api.js has 279 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * @module api
     */
    import 'isomorphic-fetch'
    import { checkType } from '../lib/check'
    Severity: Minor
    Found in src/api/Api.js - About 2 hrs to fix

      Function getOptions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              function getOptions(defaultHeaders, mergeOptions, requestData) {
                  const resultOptions = Object.assign(
                      {},
                      api.defaultFetchOptions,
                      mergeOptions
      Severity: Minor
      Found in src/api/Api.js - About 1 hr to fix

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

            update(url, data, useMergeStrategy = false, options = {}) {
                let payload = data
        
                // Ensure that headers are defined and are treated without case sensitivity
                const requestOptions = {
        Severity: Minor
        Found in src/api/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 constructor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            constructor(fetchImpl) {
                // Optionally provide fetch to the constructor so it can be mocked during testing
                if (typeof fetchImpl === 'function') {
                    this.fetch = fetchImpl.bind(
                        typeof window !== 'undefined' ? window : global
        Severity: Minor
        Found in src/api/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 post has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            post(url, data, options = {}) {
                const requestUrl = getUrl(this.baseUrl, url)
                let payload = data
        
                // Ensure that headers are defined and are treated without case sensitivity
        Severity: Minor
        Found in src/api/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