reactjs/redux

View on GitHub
src/combineReducers.ts

Summary

Maintainability
C
1 day
Test Coverage

Function combineReducers has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

export default function combineReducers(reducers: {
  [key: string]: Reducer<any, any, any>
}) {
  const reducerKeys = Object.keys(reducers)
  const finalReducers: { [key: string]: Reducer<any, any, any> } = {}
Severity: Minor
Found in src/combineReducers.ts - About 4 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 combineReducers has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function combineReducers(reducers: {
  [key: string]: Reducer<any, any, any>
}) {
  const reducerKeys = Object.keys(reducers)
  const finalReducers: { [key: string]: Reducer<any, any, any> } = {}
Severity: Major
Found in src/combineReducers.ts - About 2 hrs to fix

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

      return function combination(
        state: StateFromReducersMapObject<typeof reducers> = {},
        action: Action
      ) {
        if (shapeAssertionError) {
    Severity: Minor
    Found in src/combineReducers.ts - About 1 hr to fix

      Function getUnexpectedStateShapeWarningMessage has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function getUnexpectedStateShapeWarningMessage(
        inputState: object,
        reducers: { [key: string]: Reducer<any, any, any> },
        action: Action,
        unexpectedKeyCache: { [key: string]: true }
      Severity: Minor
      Found in src/combineReducers.ts - About 1 hr to fix

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

        function assertReducerShape(reducers: {
          [key: string]: Reducer<any, any, any>
        }) {
          Object.keys(reducers).forEach(key => {
            const reducer = reducers[key]
        Severity: Minor
        Found in src/combineReducers.ts - About 1 hr to fix

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

          function getUnexpectedStateShapeWarningMessage(
            inputState: object,
            reducers: { [key: string]: Reducer<any, any, any> },
            action: Action,
            unexpectedKeyCache: { [key: string]: true }
          Severity: Minor
          Found in src/combineReducers.ts - 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

          There are no issues that match your filters.

          Category
          Status