jmeas/redux-resource

View on GitHub

Showing 77 of 77 total issues

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

              Similar blocks of code found in 4 locations. Consider refactoring.
              Open

                    if (action.requestKey && typeof action.requestKey !== 'string') {
                      warning(
                        `An invalid requestKey property was included in an action with type ` +
                          `"${action.type}". The requestKey property must be a string. ` +
                          `For more information, refer to the documentation at: ` +
              Severity: Major
              Found in packages/redux-resource/src/resource-reducer.js and 3 other locations - About 1 hr to fix
              packages/redux-resource/src/resource-reducer.js on lines 92..100
              packages/redux-resource/src/resource-reducer.js on lines 112..120
              packages/redux-resource/src/resource-reducer.js on lines 122..130

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 73.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 4 locations. Consider refactoring.
              Open

                    if (action.requestName && typeof action.requestName !== 'string') {
                      warning(
                        `An invalid requestName property was included in an action with type ` +
                          `"${action.type}". The requestName property must be a string. ` +
                          `For more information, refer to the documentation at: ` +
              Severity: Major
              Found in packages/redux-resource/src/resource-reducer.js and 3 other locations - About 1 hr to fix
              packages/redux-resource/src/resource-reducer.js on lines 92..100
              packages/redux-resource/src/resource-reducer.js on lines 102..110
              packages/redux-resource/src/resource-reducer.js on lines 122..130

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 73.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 4 locations. Consider refactoring.
              Open

                    if (action.request && typeof action.request !== 'string') {
                      warning(
                        `An invalid request property was included in an action with type ` +
                          `"${action.type}". The request property must be a string. ` +
                          `For more information, refer to the documentation at: ` +
              Severity: Major
              Found in packages/redux-resource/src/resource-reducer.js and 3 other locations - About 1 hr to fix
              packages/redux-resource/src/resource-reducer.js on lines 102..110
              packages/redux-resource/src/resource-reducer.js on lines 112..120
              packages/redux-resource/src/resource-reducer.js on lines 122..130

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 73.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 4 locations. Consider refactoring.
              Open

                    if (action.list && typeof action.list !== 'string') {
                      warning(
                        `An invalid list was included in an action with type ` +
                          `"${action.type}". Lists must be strings.` +
                          `For more information, refer to the documentation at: ` +
              Severity: Major
              Found in packages/redux-resource/src/resource-reducer.js and 3 other locations - About 1 hr to fix
              packages/redux-resource/src/resource-reducer.js on lines 92..100
              packages/redux-resource/src/resource-reducer.js on lines 102..110
              packages/redux-resource/src/resource-reducer.js on lines 112..120

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 73.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              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

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    if (typeof action.mergeMeta === 'boolean') {
                      mergeMeta = action.mergeMeta;
                    } else if (typeof action.mergeMeta === 'object') {
                      mergeMeta = action.mergeMeta[resourceType];
                    } else {
                packages/redux-resource/src/update-resources-plugin/index.js on lines 45..51

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 72.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    if (typeof action.mergeResources === 'boolean') {
                      mergeResources = action.mergeResources;
                    } else if (typeof action.mergeResources === 'object') {
                      mergeResources = action.mergeResources[resourceType];
                    } else {
                packages/redux-resource/src/update-resources-plugin/index.js on lines 54..60

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 72.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                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

                  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

                      Identical blocks of code found in 2 locations. Consider refactoring.
                      Open

                          if (resources) {
                            idList = resources.map(r => {
                              if (typeof r === 'object') {
                                return r.id;
                              } else {
                      Severity: Major
                      Found in packages/redux-resource/src/utils/reducer-generator.js and 1 other location - About 1 hr to fix
                      packages/redux-resource-plugins/src/http-status-codes.js on lines 64..74

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 67.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Identical blocks of code found in 2 locations. Consider refactoring.
                      Open

                          if (resources) {
                            idList = resources.map(r => {
                              if (typeof r === 'object') {
                                return r.id;
                              } else {
                      Severity: Major
                      Found in packages/redux-resource-plugins/src/http-status-codes.js and 1 other location - About 1 hr to fix
                      packages/redux-resource/src/utils/reducer-generator.js on lines 33..43

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 67.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language