onejgordon/flow-dashboard

View on GitHub
src/js/components/analysis/AnalysisJournals.js

Summary

Maintainability
F
3 days
Test Coverage

File AnalysisJournals.js has 459 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var React = require('react');
var util = require('utils/util');
import {AutoComplete, FlatButton,
    Checkbox, DropDownMenu, MenuItem} from 'material-ui';
var AppConstants = require('constants/AppConstants');
Severity: Minor
Found in src/js/components/analysis/AnalysisJournals.js - About 7 hrs to fix

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

        render() {
            let {journal_tag_segment, journal_segments, map_showing } = this.state
            let {loaded} = this.props;
            if (!loaded) return null;
            let _journals_segmented
    Severity: Major
    Found in src/js/components/analysis/AnalysisJournals.js - About 4 hrs to fix

      Function render_annual_viewer has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          render_annual_viewer() {
              let {form, annual_viewer_journals, data_ranges} = this.state
              let options = this.numeric_questions().map((q) => {
                  return {value: q.name, label: q.text}
              })
      Severity: Minor
      Found in src/js/components/analysis/AnalysisJournals.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 render_annual_viewer has 76 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          render_annual_viewer() {
              let {form, annual_viewer_journals, data_ranges} = this.state
              let options = this.numeric_questions().map((q) => {
                  return {value: q.name, label: q.text}
              })
      Severity: Major
      Found in src/js/components/analysis/AnalysisJournals.js - About 3 hrs to fix

        Function journal_data has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            journal_data() {
                let {chart_enabled_questions, questions, journal_tag_segment} = this.state;
                let {journals} = this.props;
                let labels = [];
                let chart_questions = questions.filter((q) => {
        Severity: Minor
        Found in src/js/components/analysis/AnalysisJournals.js - About 1 hr to fix

          Function handle_tag_selected has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              handle_tag_selected(chosenRequest, index) {
                  let {tags, journal_segments, questions} = this.state;
                  let {journals} = this.props;
                  let tag = tags[index];
                  let aggregate = {};
          Severity: Minor
          Found in src/js/components/analysis/AnalysisJournals.js - About 1 hr to fix

            Function fetch_annual_journals has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                fetch_annual_journals() {
                    let {form} = this.state
                    let open_ended_numeric = this.numeric_questions().filter((q) => q.response_type == 'number_oe')
                    if (!form.annual_viewer_key) {
                        let qs = this.numeric_questions()
            Severity: Minor
            Found in src/js/components/analysis/AnalysisJournals.js - About 1 hr to fix

              Function constructor has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  constructor(props) {
                      super(props);
                      let user = props.user;
                      let questions = [];
                      if (user) questions = get(user, 'settings.journals.questions', []);
              Severity: Minor
              Found in src/js/components/analysis/AnalysisJournals.js - About 1 hr to fix

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

                    journal_data() {
                        let {chart_enabled_questions, questions, journal_tag_segment} = this.state;
                        let {journals} = this.props;
                        let labels = [];
                        let chart_questions = questions.filter((q) => {
                Severity: Minor
                Found in src/js/components/analysis/AnalysisJournals.js - About 25 mins to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

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

                    toggle_series(series) {
                        let {chart_enabled_questions} = this.state;
                        util.toggleInList(chart_enabled_questions, series);
                        this.setState({chart_enabled_questions});
                    }
                Severity: Major
                Found in src/js/components/analysis/AnalysisJournals.js and 1 other location - About 1 hr to fix
                src/js/components/ProjectViewer.js on lines 136..140

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

                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

                        let chart_enabled = questions.filter((q) => {
                            return q.chart_default;
                        }).map((q) => {return q.name;});
                Severity: Minor
                Found in src/js/components/analysis/AnalysisJournals.js and 1 other location - About 40 mins to fix
                src/js/components/Analysis.js on lines 23..25

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

                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

                                      filter={(searchText, key) => searchText !== '' && key.toLowerCase().indexOf(searchText.toLowerCase()) !== -1 }
                Severity: Minor
                Found in src/js/components/analysis/AnalysisJournals.js and 1 other location - About 40 mins to fix
                src/js/components/TaskWidget.js on lines 299..299

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

                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