cattr-app/frontend-application

View on GitHub
app/core/helpers/httpInterceptor.js

Summary

Maintainability
A
1 hr
Test Coverage

Function setLoading has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const setLoading = value => {
    if (value) {
        if (pendingRequests === 0) Vue.prototype.$Loading.start();
        pendingRequests++;
    } else {
Severity: Minor
Found in app/core/helpers/httpInterceptor.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 responseErrorInterceptor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const responseErrorInterceptor = error => {
    setLoading(false);

    if (!has(error, 'response.status') || (error.request.responseType === 'blob' && error.request.status === 404)) {
        return Promise.reject(error);
Severity: Minor
Found in app/core/helpers/httpInterceptor.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

Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
Open

import Vue from 'vue';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace 'axios' with "axios"
Open

import axios from 'axios';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
Open

import Vue from 'vue';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
Open

import Vue from 'vue';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
Open

import Vue from 'vue';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
Open

import Vue from 'vue';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ··
Open

    } else {
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
Open

import Vue from 'vue';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace 'vue' with "vue"
Open

import Vue from 'vue';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ··
Open

    if (value) {
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ········ with ····
Open

        if (pendingRequests === 0) Vue.prototype.$Loading.start();
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
Open

import Vue from 'vue';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
Open

import Vue from 'vue';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
Open

import Vue from 'vue';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
Open

import Vue from 'vue';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
Open

import Vue from 'vue';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
Open

import Vue from 'vue';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace '@/store' with "@/store"
Open

import store from '@/store';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Definition for rule 'vue/attributes-order' was not found
Open

import Vue from 'vue';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace 'lodash/has' with "lodash/has"
Open

import has from 'lodash/has';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
Open

import Vue from 'vue';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
Open

import Vue from 'vue';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
Open

import Vue from 'vue';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
Open

import Vue from 'vue';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ····
Open

        pendingRequests++;
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
Open

import Vue from 'vue';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
Open

import Vue from 'vue';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
Open

import Vue from 'vue';
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ····
Open

        }, 300);
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ···· with ··
Open

    setLoading(false);
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ············ with ······
Open

            break;
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ····
Open

        case 503:
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ··········:·'Internal·server·error' with :·"Internal·server·error"
Open

                    : 'Internal server error',
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ··
Open

    }
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ····
Open

        return config;
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ··
Open

    }
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ··
Open

    switch (error.response.status) {
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ············ with ······
Open

            Vue.prototype.$Notify.error({
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ··
Open

    // Generate cancel token source
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ··
Open

    return config;
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ········ with ····
Open

        setTimeout(() => {
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ···· with ··
Open

    }
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ········ with ····
Open

        default:
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ···················· with ··········
Open

                    ? error.response.data.error.message
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace 'access_token' with "access_token"
Open

const getAuthToken = () => localStorage.getItem('access_token');
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ··
Open

    setLoading(false);
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ··
Open

    return response;
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ············store.getters['user/loggedIn']·&&·store.dispatch('user/forceUserExit',·'Data·reset' with ······store.getters["user/loggedIn"]·&&⏎········store.dispatch("user/forceUserExit",·"Data·reset"
Open

            store.getters['user/loggedIn'] && store.dispatch('user/forceUserExit', 'Data reset');
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ····
Open

        case 401:
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ············ with ······
Open

            break;
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ················message:·has(error,·'response.data.error.message' with ········message:·has(error,·"response.data.error.message"
Open

                message: has(error, 'response.data.error.message')
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ················duration:·5000, with ········duration:·5000
Open

                duration: 5000,
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ······
Open

            });
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ··}, with }
Open

    },
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ············store.getters['user/loggedIn']·&&·store.dispatch('user/forceUserExit' with ······store.getters["user/loggedIn"]·&&⏎········store.dispatch("user/forceUserExit"
Open

            store.getters['user/loggedIn'] && store.dispatch('user/forceUserExit', error.response.data.message);
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ··
Open

    axios.isCancel(error) ? setLoading(false) : Vue.prototype.$Loading.error();
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ··
Open

    }
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ····
Open

        axios.interceptors.request.use(authInterceptor);
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ··
Open

    return config;
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ··
Open

    // Set cancel token on this request
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ···· with ··)·{⏎
Open

        return Promise.reject(error);
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ················title:·'Error' with ········title:·"Error"
Open

                title: 'Error',
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ······
Open

            if (pendingRequests > 0) pendingRequests--;
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ············ with ······
Open

            if (pendingRequests < 1) Vue.prototype.$Loading.finish();
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ··
Open

    setup() {
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ··if·(!has(error,·'response.status')·||·(error.request.responseType·===·'blob'·&&·error.request.status·===·404))·{ with if·(⏎····!has(error,·"response.status")·||⏎····(error.request.responseType·===·"blob"·&&·error.request.status·===·404)
Open

    if (!has(error, 'response.status') || (error.request.responseType === 'blob' && error.request.status === 404)) {
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ···· with ··
Open

    return config;
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ··
Open

    let source = axios.CancelToken.source();
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ········ with ····
Open

        axios.interceptors.request.use(pendingRequestsInterceptor);
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ··
Open

    return Promise.reject(error);
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ··
Open

    if (config.ignoreCancel) {
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ··
Open

    return Promise.reject(error);
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Delete ··
Open

    setLoading(true);
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ··config.headers['Authorization' with config.headers["Authorization"
Open

    config.headers['Authorization'] = `Bearer ${getAuthToken()}`;
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ···· with ··
Open

    config.cancelToken = source.token;
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ····store.commit('httpRequest/addCancelToken' with ··store.commit("httpRequest/addCancelToken"
Open

    store.commit('httpRequest/addCancelToken', source);
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Replace ····axios.interceptors.response.use(responseInterceptor,·responseErrorInterceptor); with axios.interceptors.response.use(⏎······responseInterceptor,⏎······responseErrorInterceptor
Open

        axios.interceptors.response.use(responseInterceptor, responseErrorInterceptor);
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

Insert );⏎
Open

        axios.interceptors.request.use(requestInterceptor, requestErrorInterceptor);
Severity: Minor
Found in app/core/helpers/httpInterceptor.js by eslint

For more information visit Source: http://eslint.org/docs/rules/

There are no issues that match your filters.

Category
Status