jmeas/redux-resource

View on GitHub

Showing 38 of 77 total issues

Function crudRequest has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

function crudRequest(crudAction, options) {
  const {
    dispatch,
    xhrOptions = {},
    transformData,
Severity: Minor
Found in packages/redux-resource-xhr/src/index.js - 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 getPathParts has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

export default function getPathParts(path) {
  const parts = [];
  let i = 0;
  let nextDot, nextOpenBracket, openQuote, nextCloseBracket;

Severity: Minor
Found in packages/redux-resource/src/utils/get-path-parts.js - 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 crudRequest has 114 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function crudRequest(crudAction, options) {
  const {
    dispatch,
    xhrOptions = {},
    transformData,
Severity: Major
Found in packages/redux-resource-xhr/src/index.js - About 4 hrs to fix

    Function resourceReducer has 112 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default function resourceReducer(resourceType, options = {}) {
      const { plugins = [], initialState = {} } = options;
      const defaultInitialState = generateDefaultInitialState();
      const initial = {
        ...defaultInitialState,
    Severity: Major
    Found in packages/redux-resource/src/resource-reducer.js - About 4 hrs to fix

      Function resourceReducer has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function resourceReducer(resourceType, options = {}) {
        const { plugins = [], initialState = {} } = options;
        const defaultInitialState = generateDefaultInitialState();
        const initial = {
          ...defaultInitialState,
      Severity: Minor
      Found in packages/redux-resource/src/resource-reducer.js - 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 default has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function(state, action, { initialResourceMeta }, updatedMeta) {
        const resources = action.resources;
        const resourcesIsUndefined = typeof resources === 'undefined';
        const hasResources = resources && resources.length;
      
      
      Severity: Minor
      Found in packages/redux-resource/src/utils/cru-reducer-helper.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

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

      function delSucceed(state, action, { initialResourceMeta }) {
        const resources = action.resources;
      
        let requestKey, requestName;
        if (action.request && typeof action.request === 'string') {
      Severity: Minor
      Found in packages/redux-resource/src/request-statuses-plugin/delete.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

      Function default has 81 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function(crudAction, requestStatus) {
        return function(state, action, { initialResourceMeta } = {}) {
          const resources = action.resources;
          const mergeMeta = action.mergeMeta;
      
      
      Severity: Major
      Found in packages/redux-resource/src/utils/reducer-generator.js - About 3 hrs to fix

        Function httpStatusCodes has 77 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default function httpStatusCodes(resourceType) {
          return function(state, action) {
            const typeToCheck = action.resourceType || action.resourceName;
            if (typeToCheck !== resourceType) {
              return state;
        Severity: Major
        Found in packages/redux-resource-plugins/src/http-status-codes.js - About 3 hrs to fix

          Function default has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

          export default function(resourceSlice, filter, options) {
            if (process.env.NODE_ENV !== 'production') {
              // We use duck typing to try and differentiate between a user passing the entire state tree
              // in as `resourceSlice` (which was the original getResources API).
              // eslint-disable-next-line no-inner-declarations
          Severity: Minor
          Found in packages/redux-resource/src/utils/get-resources.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 reducer has 72 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            return function reducer(state = initial, action) {
              if (process.env.NODE_ENV !== 'production') {
                if (
                  action.type === 'REQUEST_PENDING' ||
                  action.type === 'REQUEST_IDLE' ||
          Severity: Major
          Found in packages/redux-resource/src/resource-reducer.js - About 2 hrs to fix

            Function getStatus has 68 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function getStatus(state, statusLocations, treatIdleAsPending) {
              if (!Array.isArray(statusLocations)) {
                const status = getSingleStatus(state, statusLocations, treatIdleAsPending);
            
                if (process.env.NODE_ENV !== 'production') {
            Severity: Major
            Found in packages/redux-resource/src/utils/get-status.js - About 2 hrs to fix

              Function upsertResources has 60 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export default function upsertResources(
                resources,
                newResources,
                mergeResources
              ) {
              Severity: Major
              Found in packages/redux-resource/src/utils/upsert-resources.js - About 2 hrs to fix

                Function req has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  const req = xhr(xhrOptions, (err, res, body) => {
                    const statusCode = res ? res.statusCode : null;
                    if (req.aborted) {
                      const abortedAction = {
                        ...actionDefaults,
                Severity: Major
                Found in packages/redux-resource-xhr/src/index.js - About 2 hrs to fix

                  Function default has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export default function(resourceSlice, filter, options) {
                    if (process.env.NODE_ENV !== 'production') {
                      // We use duck typing to try and differentiate between a user passing the entire state tree
                      // in as `resourceSlice` (which was the original getResources API).
                      // eslint-disable-next-line no-inner-declarations
                  Severity: Major
                  Found in packages/redux-resource/src/utils/get-resources.js - About 2 hrs to fix

                    Function createActionCreators has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const createActionCreators = (crudType, actionDefaults = {}) => {
                      const { resourceName, resourceType } = actionDefaults;
                      const typeToUse = resourceType || resourceName;
                      const uppercaseCrud =
                        typeof crudType === 'string' ? crudType.toUpperCase() : '';
                    Severity: Major
                    Found in packages/redux-resource-action-creators/src/index.js - About 2 hrs to fix

                      Function getSingleStatus has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function getSingleStatus(state, statusLocation, treatIdleAsPending) {
                        const splitPath = getPathParts(statusLocation);
                      
                        let status;
                        let currentVal = state;
                      Severity: Major
                      Found in packages/redux-resource/src/utils/get-status.js - About 2 hrs to fix

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

                          render() {
                            const { state } = this.props;
                            const searchStatus = getStatus(
                              state,
                              'books.requests.readUserBooks.status',
                        Severity: Minor
                        Found in examples/lists-and-named-requests/src/components/BooksList.js - About 1 hr to fix

                          Function reset has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function reset(resourceType, options = {}) {
                            return function(state, action) {
                              const typeToUse = action.resourceType || action.resourceName;
                              if (
                                action.type !== actionTypes.RESET_RESOURCE ||
                          Severity: Minor
                          Found in packages/redux-resource-plugins/src/reset.js - About 1 hr to fix

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

                            export default function getPathParts(path) {
                              const parts = [];
                              let i = 0;
                              let nextDot, nextOpenBracket, openQuote, nextCloseBracket;
                            
                            
                            Severity: Minor
                            Found in packages/redux-resource/src/utils/get-path-parts.js - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language