jmeas/redux-resource

View on GitHub

Showing 38 of 77 total issues

Function includedResources has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function includedResources(resourceType, options = {}) {
  return (state, action) => {
    const { initialResourceMeta } = options;
    const { includedResources, mergeMeta, mergeResources, type } = action;

Severity: Minor
Found in packages/redux-resource-plugins/src/included-resources.js - About 1 hr to fix

    Function setResourceMeta has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default function setResourceMeta(options) {
      const {
        resources,
        newMeta,
        meta,
    Severity: Minor
    Found in packages/redux-resource/src/utils/set-resource-meta.js - About 1 hr to fix

      Function upsertResources has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function upsertResources(
        resources,
        newResources,
        mergeResources
      ) {
      Severity: Minor
      Found in packages/redux-resource/src/utils/upsert-resources.js - 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 getSingleStatus has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      function getSingleStatus(state, statusLocation, treatIdleAsPending) {
        const splitPath = getPathParts(statusLocation);
      
        let status;
        let currentVal = state;
      Severity: Minor
      Found in packages/redux-resource/src/utils/get-status.js - 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 getUserBooks has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function getUserBooks() {
        return function(dispatch) {
          dispatch({
            type: actionTypes.READ_RESOURCES_PENDING,
            resourceType: 'books',

        Function selection has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function selection(resourceType) {
          return function(state, action) {
            // Ignore actions that were dispatched for another resource type
            const typeToUse = action.resourceType || action.resourceName;
            if (typeToUse !== resourceType) {
        Severity: Minor
        Found in packages/redux-resource-plugins/src/selection.js - About 1 hr to fix

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

          export default function request(uri, options, cb) {
            let params = {};
            // This handles the `xhr(options, cb)` syntax
            if (typeof uri === 'object') {
              params = uri;
          Severity: Minor
          Found in packages/redux-resource-xhr/src/xhr.js - About 1 hr to fix

            Function getStatus has a Cognitive Complexity of 11 (exceeds 5 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: Minor
            Found in packages/redux-resource/src/utils/get-status.js - 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 getLatestBooks has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function getLatestBooks() {
              return function(dispatch) {
                dispatch({
                  type: actionTypes.READ_RESOURCES_PENDING,
                  resourceType: 'books',

              Function requestStatusesPlugin has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export default function requestStatusesPlugin(resourceType, options = {}) {
                const customInitialMeta = options.initialResourceMeta || {};
                const optionsToSend = {
                  initialResourceMeta: {
                    ...initialResourceMetaState,
              Severity: Minor
              Found in packages/redux-resource/src/request-statuses-plugin/index.js - About 1 hr to fix

                Function request has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                export default function request(uri, options, cb) {
                  let params = {};
                  // This handles the `xhr(options, cb)` syntax
                  if (typeof uri === 'object') {
                    params = uri;
                Severity: Minor
                Found in packages/redux-resource-xhr/src/xhr.js - 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

                Avoid deeply nested control flow statements.
                Open

                            if (typeof r !== 'string' && typeof r !== 'number') {
                              warning(
                                `A resource without an ID was passed to an action with type ` +
                                  `${
                                    action.type
                Severity: Major
                Found in packages/redux-resource/src/update-resources-plugin/index.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                              if (
                                (!r.id && r.id !== 0) ||
                                (typeof r.id !== 'string' && typeof r.id !== 'number')
                              ) {
                                warning(
                  Severity: Major
                  Found in packages/redux-resource/src/update-resources-plugin/index.js - About 45 mins to fix

                    Function upsertMeta has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export default function upsertMeta(meta, newMeta, mergeMeta) {
                      if (!newMeta) {
                        return meta;
                      }
                    
                    
                    Severity: Minor
                    Found in packages/redux-resource/src/utils/upsert-meta.js - About 45 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

                    Function createActionCreators has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const createActionCreators = (crudType, actionDefaults = {}) => {
                      const { resourceName, resourceType } = actionDefaults;
                      const typeToUse = resourceType || resourceName;
                      const uppercaseCrud =
                        typeof crudType === 'string' ? crudType.toUpperCase() : '';
                    Severity: Minor
                    Found in packages/redux-resource-action-creators/src/index.js - About 35 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

                    Avoid too many return statements within this function.
                    Open

                        return state;
                    Severity: Major
                    Found in packages/redux-resource-plugins/src/selection.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                        return byId ? resourceArrayToObject(resourcesList) : resourcesList;
                      Severity: Major
                      Found in packages/redux-resource/src/utils/get-resources.js - About 30 mins to fix

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

                        export default function warning(message, code) {
                          // This ensures that each warning type is only logged out one time
                          if (code) {
                            if (codeCache[code]) {
                              return;
                        Severity: Minor
                        Found in packages/redux-resource/src/utils/warning.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

                        Severity
                        Category
                        Status
                        Source
                        Language