xolvio/pojo-observer

View on GitHub

Showing 10 of 28 total issues

File useObserver.spec.tsx has 570 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable max-classes-per-file,react/button-has-type,no-plusplus */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import * as React from 'react'
import {render, act} from '@testing-library/react'
import useObserver from './useObserver'
Severity: Major
Found in src/useObserver.spec.tsx - About 1 day to fix

    File pureObserver.spec.ts has 426 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* eslint-disable @typescript-eslint/ban-ts-ignore */
    import * as td from 'testdouble'
    import {pureObserver} from './useObserver'
    
    test('it reacts to a change', () => {
    Severity: Minor
    Found in src/pureObserver.spec.ts - About 6 hrs to fix

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

      function attachProxyToField(
        object,
        fieldName,
        originalField,
        callback,
      Severity: Minor
      Found in src/useObserver.ts - 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

      Function attachProxyToField has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function attachProxyToField(
        object,
        fieldName,
        originalField,
        callback,
      Severity: Major
      Found in src/useObserver.ts - About 2 hrs to fix

        File useObserver.ts has 255 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import {useCallback, useEffect, useRef, useState} from 'react'
        import {generateId} from './helpers/generateId'
        
        class EventEmitter {
          callbacks = {}
        Severity: Minor
        Found in src/useObserver.ts - About 2 hrs to fix

          Function attachProxyToArray has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function attachProxyToArray(object, fieldName, callback, id): void {
            object[fieldName].forEach((element, index) => {
              // eslint-disable-next-line @typescript-eslint/no-use-before-define
              recursivelyAttachProxy(element, index, object[fieldName], id, callback)
            })
          Severity: Minor
          Found in src/useObserver.ts - About 1 hr to fix

            Function attachProxyToArray has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            function attachProxyToArray(object, fieldName, callback, id): void {
              object[fieldName].forEach((element, index) => {
                // eslint-disable-next-line @typescript-eslint/no-use-before-define
                recursivelyAttachProxy(element, index, object[fieldName], id, callback)
              })
            Severity: Minor
            Found in src/useObserver.ts - 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 FileTree has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const FileTree: React.FC<IFileTree> = (props: Props) => {
              const {fileTree} = props
              useObserver(fileTree)
            
              function loadFiles(): void {
            Severity: Minor
            Found in example/src/components/FileTree.tsx - About 1 hr to fix

              Function recursivelyAttachProxy has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                originalField,
                fieldName,
                object,
                id,
                callback: Function
              Severity: Minor
              Found in src/useObserver.ts - About 35 mins to fix

                Function attachProxyToField has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  object,
                  fieldName,
                  originalField,
                  callback,
                  id
                Severity: Minor
                Found in src/useObserver.ts - About 35 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language