jmeas/redux-resource

View on GitHub

Showing 77 of 77 total issues

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

    if (naiveNewResources && naiveNewResources.map) {
      idList = naiveNewResources.map(r => {
        if (typeof r === 'object') {
          if (process.env.NODE_ENV !== 'production') {
            if (
Severity: Major
Found in packages/redux-resource/src/update-resources-plugin/index.js and 1 other location - About 1 day to fix
packages/redux-resource/src/request-statuses-plugin/delete.js on lines 64..105

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 298.

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 (resources && resources.map) {
    idList = resources.map(r => {
      if (typeof r === 'object') {
        if (process.env.NODE_ENV !== 'production') {
          if (
packages/redux-resource/src/update-resources-plugin/index.js on lines 105..148

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 298.

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) {
      warning(
        `A 'resources' array was not included in a Redux Resource ` +
          `"success" action with type "${action.type}. Without a 'resources' ` +
          `Array, Redux Resource will not be able to track which resources ` +
Severity: Major
Found in packages/redux-resource/src/utils/cru-reducer-helper.js and 1 other location - About 7 hrs to fix
packages/redux-resource/src/request-statuses-plugin/delete.js on lines 25..49

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 177.

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) {
      warning(
        `A 'resources' array was not included in a Redux Resource ` +
          `"success" action with type "${action.type}. Without a 'resources' ` +
          `Array, Redux Resource will not be able to track which resources ` +
packages/redux-resource/src/utils/cru-reducer-helper.js on lines 30..54

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 177.

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 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

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

        <div style={{ width: '350px', marginRight: '50px' }}>
          <h2>Your Books</h2>
          {searchStatus.pending && 'Loading your books...'}
          {searchStatus.succeeded && (
            <div>
examples/lists-and-named-requests/src/components/BooksList.js on lines 39..54

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 136.

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

        <div style={{ width: '350px' }}>
          <h2>Recently Released</h2>
          {latestStatus.pending && 'Loading recently released books...'}
          {latestStatus.succeeded && (
            <div>
examples/lists-and-named-requests/src/components/BooksList.js on lines 23..38

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 136.

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 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

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

          if (process.env.NODE_ENV !== 'production') {
            Object.defineProperty(status, 'null', {
              // eslint-disable-next-line getter-return
              get() {
                warning(
      Severity: Major
      Found in packages/redux-resource/src/utils/get-status.js and 1 other location - About 4 hrs to fix
      packages/redux-resource/src/utils/get-status.js on lines 144..161

      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 124.

      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 (process.env.NODE_ENV !== 'production') {
          Object.defineProperty(status, 'null', {
            // eslint-disable-next-line getter-return
            get() {
              warning(
      Severity: Major
      Found in packages/redux-resource/src/utils/get-status.js and 1 other location - About 4 hrs to fix
      packages/redux-resource/src/utils/get-status.js on lines 88..105

      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 124.

      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 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
              Severity
              Category
              Status
              Source
              Language