onejgordon/flow-dashboard

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

Summary

Maintainability
D
2 days
Test Coverage

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

    render() {
        let {user} = this.props;
        let {snapshots, form, dimensions, loading} = this.state;
        let data = this.get_data();
        if (data == null) return <div></div>
Severity: Major
Found in src/js/components/analysis/AnalysisSnapshot.js - About 5 hrs to fix

    File AnalysisSnapshot.js has 335 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    var React = require('react');
    import {Link} from 'react-router';
    import {Line, Bar, Doughnut} from "react-chartjs-2";
    import connectToStores from 'alt-utils/lib/connectToStores';
    var api = require('utils/api');
    Severity: Minor
    Found in src/js/components/analysis/AnalysisSnapshot.js - About 4 hrs to fix

      Function generate_averages_dataset has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          generate_averages_dataset(snapshots, dim) {
              let {form} = this.state;
              let sb = form.segment_by;
              if (dim == null) dim = sb;
              let dimension_metric_aves = {};
      Severity: Minor
      Found in src/js/components/analysis/AnalysisSnapshot.js - About 1 hr to fix

        Function get_data has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            get_data() {
                let {form, dimensions, snapshots} = this.state;
                let {segment_by} = form;
                let segment_var = dimensions[segment_by];
                if (segment_var) {
        Severity: Minor
        Found in src/js/components/analysis/AnalysisSnapshot.js - About 1 hr to fix

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

              constructor(props) {
                  super(props);
                  this.state = {
                      snapshots: [],
                      dimensions: {},
          Severity: Minor
          Found in src/js/components/analysis/AnalysisSnapshot.js - About 1 hr to fix

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

                render() {
                    let {user} = this.props;
                    let {snapshots, form, dimensions, loading} = this.state;
                    let data = this.get_data();
                    if (data == null) return <div></div>
            Severity: Minor
            Found in src/js/components/analysis/AnalysisSnapshot.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

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

                                            <div className="col-sm-4">
                                                <Select onChange={this.changeHandlerVal.bind(this, 'form', 'metric')} value={form.metric} options={this.metric_opts} simpleValue />
                                            </div>
            Severity: Major
            Found in src/js/components/analysis/AnalysisSnapshot.js and 2 other locations - About 1 hr to fix
            src/js/components/analysis/AnalysisSnapshot.js on lines 292..294
            src/js/components/analysis/AnalysisSnapshot.js on lines 295..297

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

            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

                                            <div className="col-sm-4">
                                                <Select onChange={this.changeHandlerVal.bind(this, 'form', 'segment_by')} value={form.segment_by} options={this.segment_opts} simpleValue />
                                            </div>
            Severity: Major
            Found in src/js/components/analysis/AnalysisSnapshot.js and 2 other locations - About 1 hr to fix
            src/js/components/analysis/AnalysisSnapshot.js on lines 295..297
            src/js/components/analysis/AnalysisSnapshot.js on lines 298..300

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

            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

                                            <div className="col-sm-4">
                                                <Select onChange={this.changeHandlerVal.bind(this, 'form', 'x_axis')} value={form.x_axis} options={this.x_axis_opts} simpleValue />
                                            </div>
            Severity: Major
            Found in src/js/components/analysis/AnalysisSnapshot.js and 2 other locations - About 1 hr to fix
            src/js/components/analysis/AnalysisSnapshot.js on lines 292..294
            src/js/components/analysis/AnalysisSnapshot.js on lines 298..300

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

            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