WikiEducationFoundation/WikiEduDashboard

View on GitHub
app/assets/javascripts/components/timeline/timeline.jsx

Summary

Maintainability
F
4 days
Test Coverage
A
92%

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

  render() {
    if (this.props.loading) {
      return <Loading />;
    }

Severity: Major
Found in app/assets/javascripts/components/timeline/timeline.jsx - About 1 day to fix

    File timeline.jsx has 424 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React from 'react';
    import createReactClass from 'create-react-class';
    import PropTypes from 'prop-types';
    import { HTML5Backend } from 'react-dnd-html5-backend';
    import { DndProvider } from 'react-dnd';
    Severity: Minor
    Found in app/assets/javascripts/components/timeline/timeline.jsx - About 6 hrs to fix

      Function render has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

        render() {
          if (this.props.loading) {
            return <Loading />;
          }
      
      
      Severity: Minor
      Found in app/assets/javascripts/components/timeline/timeline.jsx - 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 _handleMoveBlock has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

        _handleMoveBlock(moveUp, blockId) {
          for (let i = 0; i < this.props.weeks.length; i += 1) {
            const week = this.props.weeks[i];
            const blocks = this.getBlocksInWeek(week.id);
            for (let j = 0; j < blocks.length; j += 1) {
      Severity: Minor
      Found in app/assets/javascripts/components/timeline/timeline.jsx - 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 weekNav has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          const weekNav = weekNavInfo.map((weekInfo, navIndex) => {
            let navClassName = 'week-nav__item';
            if (navIndex === 0) {
              navClassName += ' is-current';
            }
      Severity: Minor
      Found in app/assets/javascripts/components/timeline/timeline.jsx - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                    if (moveUp) {
                      const toWeekBlocks = this.getBlocksInWeek(toWeek.id);
                      atIndex = toWeekBlocks.length;
                    }
        Severity: Major
        Found in app/assets/javascripts/components/timeline/timeline.jsx - About 45 mins to fix

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

                if (this.props.editableTitles) {
                  editWeekTitles = (
                    <div className="edit-week-titles">
                      <h5>{I18n.t('timeline.edit_titles')}</h5>
                      <p className="muted">{I18n.t('timeline.edit_titles_info')}</p>
          Severity: Major
          Found in app/assets/javascripts/components/timeline/timeline.jsx and 1 other location - About 2 hrs to fix
          app/assets/javascripts/components/timeline/timeline.jsx on lines 329..342

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

          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.reorderable) {
                  reorderableControls = (
                    <div className="reorderable-controls">
                      <h5>{I18n.t('timeline.arrange_timeline')}</h5>
                      <p className="muted">{I18n.t('timeline.arrange_timeline_instructions')}</p>
          Severity: Major
          Found in app/assets/javascripts/components/timeline/timeline.jsx and 1 other location - About 2 hrs to fix
          app/assets/javascripts/components/timeline/timeline.jsx on lines 345..358

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

          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 {
                  editWeekTitles = (
                    <div className="edit-week-titles">
                      <button className="button border button--block" onClick={this.props.enableEditTitles}>{I18n.t('timeline.edit_titles')}</button>
                    </div>
          Severity: Major
          Found in app/assets/javascripts/components/timeline/timeline.jsx and 1 other location - About 1 hr to fix
          app/assets/javascripts/components/timeline/timeline.jsx on lines 336..342

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

          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 if (this.props.editableBlockIds.length === 0) {
                  reorderableControls = (
                    <div className="reorderable-controls">
                      <button className="button border button--block" onClick={this.props.enableReorderable}>{I18n.t('timeline.arrange_timeline')}</button>
                    </div>
          Severity: Major
          Found in app/assets/javascripts/components/timeline/timeline.jsx and 1 other location - About 1 hr to fix
          app/assets/javascripts/components/timeline/timeline.jsx on lines 352..358

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

          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 3 locations. Consider refactoring.
          Open

              const resetTitlesButton = (
                <button className="button button--clear button--block" onClick={this.props.resetTitles}>
                  {I18n.t('timeline.reset_titles')}
                </button>
              );
          Severity: Major
          Found in app/assets/javascripts/components/timeline/timeline.jsx and 2 other locations - About 45 mins to fix
          app/assets/javascripts/components/timeline/timeline.jsx on lines 295..299
          app/assets/javascripts/components/timeline/timeline.jsx on lines 300..304

          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

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

              const cancelChangesButton = (
                <button className="button button--clear button--block" onClick={this.props.cancelGlobalChanges}>
                  {I18n.t('timeline.discard_all_changes')}
                </button>
              );
          Severity: Major
          Found in app/assets/javascripts/components/timeline/timeline.jsx and 2 other locations - About 45 mins to fix
          app/assets/javascripts/components/timeline/timeline.jsx on lines 295..299
          app/assets/javascripts/components/timeline/timeline.jsx on lines 305..309

          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

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

              const saveChangesButton = (
                <button className="button dark button--block" onClick={this.props.saveGlobalChanges}>
                  {I18n.t('timeline.save_all_changes')}
                </button>
              );
          Severity: Major
          Found in app/assets/javascripts/components/timeline/timeline.jsx and 2 other locations - About 45 mins to fix
          app/assets/javascripts/components/timeline/timeline.jsx on lines 300..304
          app/assets/javascripts/components/timeline/timeline.jsx on lines 305..309

          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

          There are no issues that match your filters.

          Category
          Status