gabrielbull/react-router-server

View on GitHub

Showing 29 of 29 total issues

Function renderPass has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

const renderPass = (context, element, staticMarkup = false) => {
  context.callback = () => {
    if (context.finishedLoadingModules && !context.statesRenderPass) {
      context.statesRenderPass = true;
      context.renderResult = renderPass(context, element, staticMarkup);
Severity: Minor
Found in src/renderer/renderPass.js - About 5 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 fetchState has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

const fetchState = (mapStateToProps, mapActionsToProps) => WrappedComponent => {
  return class extends Component {
    static contextTypes = {
      reactRouterServerAsyncRenderer: () => null,
      reactRouterServerServerState: () => null,
Severity: Minor
Found in src/components/fetchState.jsx - 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

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

      if (context.fetchingStates <= 0 && context.modulesLoading <= 0) {
        context.resolve({
          html: context.renderResult,
          state: context.fetchStateResults === undefined ? null : context.fetchStateResults,
          modules: context.modules === undefined ? null : removeDuplicateModules(context.modules)
Severity: Major
Found in src/renderer/renderPass.js and 1 other location - About 3 hrs to fix
src/renderer/renderPass.js on lines 11..17

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

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 (context.fetchingStates <= 0 && context.modulesLoading <= 0) {
        context.resolve({
          html: context.renderResult,
          state: context.fetchStateResults === undefined ? null : context.fetchStateResults,
          modules: context.modules === undefined ? null : removeDuplicateModules(context.modules)
Severity: Major
Found in src/renderer/renderPass.js and 1 other location - About 3 hrs to fix
src/renderer/renderPass.js on lines 20..26

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

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 fetchState has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const fetchState = (mapStateToProps, mapActionsToProps) => WrappedComponent => {
  return class extends Component {
    static contextTypes = {
      reactRouterServerAsyncRenderer: () => null,
      reactRouterServerServerState: () => null,
Severity: Major
Found in src/components/fetchState.jsx - About 2 hrs to fix

    Function componentWillMount has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

      componentWillMount() {
        const { reactRouterServerAsyncRenderer } = this.context;
        this._componentIsMounted = true;
    
        if (isNode()) {
    Severity: Minor
    Found in src/components/Module.jsx - 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 renderPass has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const renderPass = (context, element, staticMarkup = false) => {
      context.callback = () => {
        if (context.finishedLoadingModules && !context.statesRenderPass) {
          context.statesRenderPass = true;
          context.renderResult = renderPass(context, element, staticMarkup);
    Severity: Minor
    Found in src/renderer/renderPass.js - About 1 hr to fix

      Function fetchModuleInformation has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const fetchModuleInformation = modules => {
        return new Promise((resolve) => {
          const prevWebpackJsonp = webpackJsonp;
          const finalModules = {};
          let fileLoading = 0;
      Severity: Minor
      Found in src/module/preload.js - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

          if (
            (typeof stats === 'undefined' || !stats) ||
            (!stats.modules || Object.prototype.toString.call(stats.modules) !== '[object Array]') ||
            (!stats.chunks || Object.prototype.toString.call(stats.chunks) !== '[object Array]') ||
            (!stats.entrypoints || typeof stats.entrypoints !== 'object')
        Severity: Critical
        Found in src/utils/validateStats.js - About 1 hr to fix

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

              } else {
                const result = stack.indexOf(item.info.filename);
                if (result === -1) {
                  stack.push(item.info.filename);
                  return true;
          Severity: Major
          Found in src/utils/removeDuplicateModules.js and 1 other location - About 1 hr to fix
          src/utils/removeDuplicateModules.js on lines 4..10

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

          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

          export const fetch = (module, systemImport) => {
            const key = signature(module, systemImport);
            if (key !== null && typeof pool[key] !== 'undefined') return pool[key];
            return null;
          }
          Severity: Major
          Found in src/module/cache.js and 1 other location - About 1 hr to fix
          src/module/preload.js on lines 6..10

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

          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

          export const fetch = (module, systemImport) => {
            const key = signature(module, systemImport);
            if (key !== null && typeof pool[key] !== 'undefined') return pool[key];
            return null;
          }
          Severity: Major
          Found in src/module/preload.js and 1 other location - About 1 hr to fix
          src/module/cache.js on lines 23..27

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

          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 (item.info.type === 'webpack') {
                const result = stack.indexOf(item.info.id);
                if (result === -1) {
                  stack.push(item.info.id);
                  return true;
          Severity: Major
          Found in src/utils/removeDuplicateModules.js and 1 other location - About 1 hr to fix
          src/utils/removeDuplicateModules.js on lines 10..16

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

          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 componentWillMount has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            componentWillMount() {
              const { reactRouterServerAsyncRenderer } = this.context;
              this._componentIsMounted = true;
          
              if (isNode()) {
          Severity: Minor
          Found in src/components/Module.jsx - About 1 hr to fix

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

                if (this.props.context.fetchingStates === undefined) this.props.context.fetchingStates = 1;
                else this.props.context.fetchingStates++;
            Severity: Major
            Found in src/components/AsyncRenderer.jsx and 1 other location - About 1 hr to fix
            src/components/AsyncRenderer.jsx on lines 67..68

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

            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 (this.props.context.modulesLoading === undefined) this.props.context.modulesLoading = 1;
                else this.props.context.modulesLoading++;
            Severity: Major
            Found in src/components/AsyncRenderer.jsx and 1 other location - About 1 hr to fix
            src/components/AsyncRenderer.jsx on lines 49..50

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

            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 (indexOfBackslash === -1 || indexOfSlash > indexOfBackslash) {
                separator = '/';
                paths = paths.map(path => path.replace(/^\.\//, '/').replace(/\/$/, '').replace(/^\//, ''));
              } else {
            Severity: Major
            Found in src/utils/join.js and 1 other location - About 1 hr to fix
            src/utils/join.js on lines 8..11

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

            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

              } else {
                separator = '\\';
                paths = paths.map(path => path.replace(/^\.\\/, '\\').replace(/\\$/, '').replace(/^\\/, ''));
              }
            Severity: Major
            Found in src/utils/join.js and 1 other location - About 1 hr to fix
            src/utils/join.js on lines 5..8

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

            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

            export const exists = (module, systemImport) => {
              const key = signature(module, systemImport);
              return key !== null && typeof pool[key] !== 'undefined';
            }
            Severity: Minor
            Found in src/module/cache.js and 1 other location - About 45 mins to fix
            src/module/preload.js on lines 11..14

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

            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 extractModule has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            function extractModule(module, stats) {
              if (module.info.type === 'webpack') {
                const match = findModule(module, stats.chunks);
                return match ? parseWebpack(match, stats.publicPath || '') : match;
              } else if (module.info.type === 'systemImportTransformer') {
            Severity: Minor
            Found in src/stats/extractModules.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

            Severity
            Category
            Status
            Source
            Language