ethanhann/Diagrammatica

View on GitHub
src/js/line.js

Summary

Maintainability
F
1 wk
Test Coverage

Function LineBase has 433 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function LineBase(selection, data) {
    var self = this;
    self.data = data;
    selection = this.selection = isD3Selection(selection) ? selection : d3.select(selection);
    var chart = this.chart = new ChartBase(selection, 'line');
Severity: Major
Found in src/js/line.js - About 2 days to fix

    File line.js has 669 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    /* global d3: false, ChartBase, tooltip, isD3Selection: false, Preview */
    /* exported line */
    
    function LineBase(selection, data) {
    Severity: Major
    Found in src/js/line.js - About 1 day to fix

      Function line has 191 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var line = function (selection, data) {
          var lineBase = new LineBase(selection, data);
          var chart = lineBase.chart;
          var config = chart.config;
          var preview = lineBase.preview;
      Severity: Major
      Found in src/js/line.js - About 7 hrs to fix

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

        function LineBase(selection, data) {
            var self = this;
            self.data = data;
            selection = this.selection = isD3Selection(selection) ? selection : d3.select(selection);
            var chart = this.chart = new ChartBase(selection, 'line');
        Severity: Minor
        Found in src/js/line.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 update has 128 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function update(newData) {
                data = !check.undefined(newData) ? newData : data;
                // Rescale
                chart.xScale.domain([
                    d3.min(data, function (series) {
        Severity: Major
        Found in src/js/line.js - About 5 hrs to fix

          Function renderTooltip has 89 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              var renderTooltip = this.renderTooltip = function (data) {
                  hoverLine.attr('y2', config.paddedHeight());
                  tooltipRectangleGroup.selectAll('.tooltip-rect').remove();
                  var xValueSet = d3.set(data.map(function (d) {
                      return d.data;
          Severity: Major
          Found in src/js/line.js - About 3 hrs to fix

            Function renderLegend has 67 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                var renderLegend = this.renderLegend = function (data) {
                    var newdata = data;
                    var legendItems = legendGroup.selectAll('g')
                        .data(data)
                        .enter()
            Severity: Major
            Found in src/js/line.js - About 2 hrs to fix

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

                  var resizeYAxis = function (selectedSeries) {
                      chart.yScale.domain([
                          d3.min(selectedSeries, function (series) {
                              return d3.min(series.data, function (t) {
                                  return t.y;
              Severity: Minor
              Found in src/js/line.js - About 1 hr to fix

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

                    chart.yScale.domain([
                        d3.min(data, function (series) {
                            return d3.min(series.data, function (d) {
                                return d.y;
                            });
                Severity: Major
                Found in src/js/line.js and 2 other locations - About 3 hrs to fix
                src/js/line.js on lines 44..55
                src/js/line.js on lines 351..362

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

                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

                    chart.xScale.domain([
                        d3.min(data, function (series) {
                            return d3.min(series.data, function (d) {
                                return d.x;
                            });
                Severity: Major
                Found in src/js/line.js and 2 other locations - About 3 hrs to fix
                src/js/line.js on lines 56..67
                src/js/line.js on lines 351..362

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

                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

                        chart.yScale.domain([
                            d3.min(selectedSeries, function (series) {
                                return d3.min(series.data, function (t) {
                                    return t.y;
                                });
                Severity: Major
                Found in src/js/line.js and 2 other locations - About 3 hrs to fix
                src/js/line.js on lines 44..55
                src/js/line.js on lines 56..67

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

                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

                        series.selectAll('.dots')
                            .data(function (d) {
                                d.data.map(function (p) {
                                    p.name = d.name;
                                });
                Severity: Major
                Found in src/js/line.js and 1 other location - About 2 hrs to fix
                src/js/line.js on lines 170..177

                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

                    var dots = series.selectAll('dots')
                        .data(function (d) {
                            d.data.map(function (p) {
                                p.name = d.name;
                            });
                Severity: Major
                Found in src/js/line.js and 1 other location - About 2 hrs to fix
                src/js/line.js on lines 603..611

                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

                    preview.range.append('text')
                        .attr('id', 'fromDate')
                        .text(textTimeFormat(preview.westDate()))
                        .attr('transform', 'translate(0,-5)')
                        .style('text-anchor', 'start')
                Severity: Major
                Found in src/js/line.js and 1 other location - About 1 hr to fix
                src/js/line.js on lines 109..114

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

                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

                    preview.range.append('text')
                        .attr('id', 'toDate')
                        .text(textTimeFormat(preview.eastDate()))
                        .attr('transform', 'translate(0,-5)')
                        .style('text-anchor', 'end')
                Severity: Major
                Found in src/js/line.js and 1 other location - About 1 hr to fix
                src/js/line.js on lines 103..108

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

                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

                        dots.transition()
                            .duration(config.transitionDuration)
                            .attr('cy', function (d) {
                                return chart.yScale(d.y);
                            })
                Severity: Major
                Found in src/js/line.js and 1 other location - About 1 hr to fix
                src/js/line.js on lines 302..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 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

                                dots.transition()
                                    .duration(config.transitionDuration)
                                    .attr('cy', function (d) {
                                        return chart.yScale(d.y);
                                    })
                Severity: Major
                Found in src/js/line.js and 1 other location - About 1 hr to fix
                src/js/line.js on lines 394..399

                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

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

                            d3.min(data, function (series) {
                                return d3.min(series.data, function (d) {
                                    return d.y * 0.9;
                                });
                            }),
                Severity: Minor
                Found in src/js/line.js and 1 other location - About 40 mins to fix
                src/js/line.js on lines 517..521

                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

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

                            d3.max(data, function (series) {
                                return d3.max(series.data, function (d) {
                                    return d.y * 1.1;
                                });
                            })
                Severity: Minor
                Found in src/js/line.js and 1 other location - About 40 mins to fix
                src/js/line.js on lines 512..516

                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

                    var brushLineGenerator = this.brushLineGenerator = d3.svg.line()
                        .x(function (d) {
                            return chart.xScale(d.x);
                        })
                        .y(function (d) {
                Severity: Minor
                Found in src/js/line.js and 1 other location - About 35 mins to fix
                src/js/line.js on lines 29..35

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

                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

                    var lineGenerator = this.lineGenerator = d3.svg.line()
                        .x(function (d) {
                            return chart.xScale(d.x);
                        })
                        .y(function (d) {
                Severity: Minor
                Found in src/js/line.js and 1 other location - About 35 mins to fix
                src/js/line.js on lines 36..42

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

                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