vshushkov/redux-models

View on GitHub
src/index.js

Summary

Maintainability
C
1 day
Test Coverage
A
100%

File index.js has 309 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { combineReducers } from 'redux';
import isFunction from 'lodash/isFunction';
import isArray from 'lodash/isArray';
import isEqual from 'lodash/isEqual';
import isEmpty from 'lodash/isEmpty';
Severity: Minor
Found in src/index.js - About 3 hrs to fix

    Function createDefaultMethodReducer has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    function createDefaultMethodReducer({ types }) {
      const [start, success, failure, reset] = types;
    
      return function defaultMethodReducer(state = [], action) {
        if (action.type === reset) {
    Severity: Minor
    Found in src/index.js - About 2 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

    Function defaultMethodReducer has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      return function defaultMethodReducer(state = [], action) {
        if (action.type === reset) {
          return [];
        }
    
    
    Severity: Minor
    Found in src/index.js - About 1 hr to fix

      Function createModel has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function createModel(options = {}) {
        let {
          typePrefix,
          modelState,
          modelsState,
      Severity: Minor
      Found in src/index.js - About 1 hr to fix

        Function createReducers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function createReducers({
          typePrefix,
          modelName,
          methods,
          reducer,
        Severity: Minor
        Found in src/index.js - About 25 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