reactjs/redux

View on GitHub

Showing 33 of 118 total issues

Function createStore has 177 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function createStore<
  S,
  A extends Action,
  Ext extends {} = {},
  StateExt extends {} = {},
Severity: Major
Found in src/createStore.ts - About 7 hrs to fix

    Function createStore has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

    export function createStore<
      S,
      A extends Action,
      Ext extends {} = {},
      StateExt extends {} = {},
    Severity: Minor
    Found in src/createStore.ts - About 6 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 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

    File todos.spec.js has 312 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import todos from './todos'
    import * as types from '../constants/ActionTypes'
    
    describe('todos reducer', () => {
      it('should handle initial state', () => {
    Severity: Minor
    Found in examples/todomvc/src/reducers/todos.spec.js - About 3 hrs to fix

      Function Home has 78 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function Home() {
        const context = useDocusaurusContext()
        const { siteConfig = {} } = context
        return (
          <Layout
      Severity: Major
      Found in website/src/pages/index.js - About 3 hrs to fix

        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

          File createStore.ts has 256 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import $$observable from './utils/symbol-observable'
          
          import type {
            Store,
            StoreEnhancer,
          Severity: Minor
          Found in src/createStore.ts - About 2 hrs to fix

            Function App has 53 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function App() {
              return (
                <div className="App">
                  <header className="App-header">
                    <img
            Severity: Major
            Found in examples/counter/src/App.js - About 2 hrs to fix

              Function App has 53 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function App() {
                return (
                  <div className="App">
                    <header className="App-header">
                      <img
              Severity: Major
              Found in examples/counter-ts/src/App.tsx - About 2 hrs to fix

                Function Counter has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function Counter() {
                  const count = useSelector(selectCount)
                  const dispatch = useDispatch()
                  const [incrementAmount, setIncrementAmount] = useState('2')
                
                
                Severity: Major
                Found in examples/counter/src/features/counter/Counter.js - About 2 hrs to fix

                  Function Counter has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function Counter() {
                    const count = useAppSelector(selectCount)
                    const dispatch = useAppDispatch()
                    const [incrementAmount, setIncrementAmount] = useState('2')
                  
                  
                  Severity: Major
                  Found in examples/counter-ts/src/features/counter/Counter.tsx - About 2 hrs to fix

                    Function Errors has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function Errors() {
                      const location = useLocation()
                      const context = useDocusaurusContext()
                      const { siteConfig = {} } = context
                      const errorCode = new URLSearchParams(location.search).get('code')
                    Severity: Minor
                    Found in website/src/pages/errors.js - About 1 hr 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 render has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            render() {
                              const { todo, completeTodo, deleteTodo } = this.props
                          
                              let element
                              if (this.state.editing) {
                          Severity: Minor
                          Found in examples/todomvc/src/components/TodoItem.js - About 1 hr to fix

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

                              function subscribe(listener: () => void) {
                                if (typeof listener !== 'function') {
                                  throw new Error(
                                    `Expected the listener to be a function. Instead, received: '${kindOf(
                                      listener
                            Severity: Minor
                            Found in src/createStore.ts - About 1 hr to fix

                              Function dispatch has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                function dispatch(action: A) {
                                  if (!isPlainObject(action)) {
                                    throw new Error(
                                      `Actions must be plain objects. Instead, the actual type was: '${kindOf(
                                        action
                              Severity: Minor
                              Found in src/createStore.ts - About 1 hr to fix

                                Function render has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  render() {
                                    const { selectedSubreddit, posts, isFetching, lastUpdated } = this.props
                                    const isEmpty = posts.length === 0
                                    return (
                                      <div>
                                Severity: Minor
                                Found in examples/async/src/containers/App.js - About 1 hr to fix

                                  Function todos has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  export default function todos(state = initialState, action) {
                                    switch (action.type) {
                                      case ADD_TODO:
                                        return [
                                          ...state,
                                  Severity: Minor
                                  Found in examples/todomvc/src/reducers/todos.js - About 1 hr to fix

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

                                    function setup(id, counter, childIds, parentId) {
                                      const actions = {
                                        increment: jest.fn(),
                                        removeChild: jest.fn(),
                                        deleteNode: jest.fn(),
                                    Severity: Minor
                                    Found in examples/tree-view/src/containers/Node.spec.js - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language