zordius/reservice

View on GitHub

Showing 7 of 7 total issues

Function serviceMiddleware has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

export const serviceMiddleware = store => next => (action) => {
  if (action.type === ACTION_SET_REQUEST) {
    if (store.req) {
      throw new ReserviceError('Try to dispatch settleRequest(req) twice!');
    }
Severity: Minor
Found in src.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 src.js has 275 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { createAction } from 'redux-actions';
import yfetch from 'yfetch';
import debug from 'debug';

export const ACTION_TYPE_RESERVICE = 'CALL_RESERVICE';
Severity: Minor
Found in src.js - About 2 hrs to fix

    Function serviceMiddleware has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const serviceMiddleware = store => next => (action) => {
      if (action.type === ACTION_SET_REQUEST) {
        if (store.req) {
          throw new ReserviceError('Try to dispatch settleRequest(req) twice!');
        }
    Severity: Minor
    Found in src.js - About 1 hr to fix

      Function createMiddlewareByServiceList has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const createMiddlewareByServiceList = (serviceList) => {
        // no serviceList error
        if (!serviceList) {
          throw new ReserviceError('No serviceList for service middleware! Check the serviceList in your createMiddlewareByServiceList(serviceList)');
        }
      Severity: Minor
      Found in src.js - About 1 hr to fix

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

        const resultAction = (action, payload) => {
          const error = payload instanceof Error;
          const { type, reservice = {}, meta } = action;
          const name = reservice.name || type;
          const ret = {
        Severity: Minor
        Found in src.js - About 1 hr to fix

          Avoid too many return statements within this function.
          Open

            return executeServiceAtServer(action, store.req || new ReserviceError('Access request without dispatching settleRequest(req) action!'))
            .then(handle, handle);
          Severity: Major
          Found in src.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return executeServiceAtServer(action, req)
                .then(handle, handle);
            Severity: Major
            Found in src.js - About 30 mins to fix
              Severity
              Category
              Status
              Source
              Language