creative-connections/aurelia-bodylight-plugin

View on GitHub
src/elements/chartjs.js

Summary

Maintainability
F
1 wk
Test Coverage

Function bind has a Cognitive Complexity of 75 (exceeds 5 allowed). Consider refactoring.
Open

  bind() {
    //console.log('chartjs bind');
    if ((typeof this.refindex == 'string') && (this.refindex.indexOf(',')>0)) { this.refindices = this.refindex.split(',')}
    else {
      this.refindex = myParseInt(this.refindex, 10);
Severity: Minor
Found in src/elements/chartjs.js - About 1 day 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 attached has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

  attached() {
    //console.log('chartjs attached');
    //listening to custom event fmidata and fmireset
    const fromel = document.getElementById(this.fromid);
    if (fromel) {
Severity: Minor
Found in src/elements/chartjs.js - About 6 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

File chartjs.js has 451 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Chart from 'chart.js';
import ChartDataLabels from 'chartjs-plugin-datalabels';
import {bindable} from 'aurelia-framework';
import _ from 'lodash';

Severity: Minor
Found in src/elements/chartjs.js - About 6 hrs to fix

    Function bind has 160 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      bind() {
        //console.log('chartjs bind');
        if ((typeof this.refindex == 'string') && (this.refindex.indexOf(',')>0)) { this.refindices = this.refindex.split(',')}
        else {
          this.refindex = myParseInt(this.refindex, 10);
    Severity: Major
    Found in src/elements/chartjs.js - About 6 hrs to fix

      Function attached has 131 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        attached() {
          //console.log('chartjs attached');
          //listening to custom event fmidata and fmireset
          const fromel = document.getElementById(this.fromid);
          if (fromel) {
      Severity: Major
      Found in src/elements/chartjs.js - About 5 hrs to fix

        Function constructor has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

          constructor() {
            this.handleValueChange = e => {
              //sets data to dataset
              //apply value convert among all data
              let rawdata;
        Severity: Minor
        Found in src/elements/chartjs.js - 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 beforeDraw has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                beforeDraw: function(chart, easing) {
                  if (chart.config.options.section && chart.config.options.section.length > 0) {
                    let ctx = chart.chart.ctx;
                    let chartArea = chart.chartArea;
                    let meta = chart.getDatasetMeta(0);
        Severity: Minor
        Found in src/elements/chartjs.js - About 1 hr to fix

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

            constructor() {
              this.handleValueChange = e => {
                //sets data to dataset
                //apply value convert among all data
                let rawdata;
          Severity: Minor
          Found in src/elements/chartjs.js - About 1 hr to fix

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

              download() {
                //ask for filename
                let filename = prompt('File name (*.csv):', 'data.csv');
                if (filename) {
                  //adds csv as extension
            Severity: Minor
            Found in src/elements/chartjs.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 2 locations. Consider refactoring.
            Open

                if (this.convertors) {
                  let convertvalues = this.convertors.split(';');
                  let identity = x => x;
                  this.operation = [];
                  for (let i = 0; i < convertvalues.length; i++) {
            Severity: Major
            Found in src/elements/chartjs.js and 1 other location - About 2 days to fix
            src/elements/dygraphchart.js on lines 107..136

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

            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.min) {
                  //sets yscale min
                  if (!this.options) this.options = {};
                  if (!this.options.scales) this.options.scales = {};
                  if (!this.options.scales.yAxes) this.options.scales.yAxes = [{}]; //chartjs 2.9.4
            Severity: Major
            Found in src/elements/chartjs.js and 1 other location - About 1 day to fix
            src/elements/chartjs-xy-points.js on lines 49..56

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

            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.max) {
                  //sets yscale max
                  if (!this.options) this.options = {};
                  if (!this.options.scales) this.options.scales = {};
                  if (!this.options.scales.yAxes) this.options.scales.yAxes = [{}]; //chartjs 2.9.4
            Severity: Major
            Found in src/elements/chartjs.js and 1 other location - About 1 day to fix
            src/elements/chartjs-xy-points.js on lines 57..65

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

            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

                  if (this.operation) {
                    for (let i = 0; i < rawdata.length; i++) {
                    //if particular operation is defined
                      if (this.operation[i]) rawdata[i] = this.operation[i](rawdata[i]);
                    }
            Severity: Major
            Found in src/elements/chartjs.js and 2 other locations - About 2 hrs to fix
            src/elements/chartjs-barplot.js on lines 32..37
            src/elements/chartjs-xy-points.js on lines 29..34

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

            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 (axisopts.xAxes) axisopts.xAxes[0].display = false;
                  else axisopts.xAxes = [{display:false }];
            Severity: Minor
            Found in src/elements/chartjs.js and 1 other location - About 35 mins to fix
            src/elements/chartjs.js on lines 238..239

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

            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 (axisopts.yAxes) axisopts.yAxes[0].display = false;
                  else axisopts.yAxes = [{display:false }];
            Severity: Minor
            Found in src/elements/chartjs.js and 1 other location - About 35 mins to fix
            src/elements/chartjs.js on lines 236..237

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

            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.ylabel) {
                  axisopts.yAxes = [{
                    scaleLabel: {
                      display: true,
                      labelString: this.ylabel
            Severity: Minor
            Found in src/elements/chartjs.js and 1 other location - About 30 mins to fix
            src/elements/chartjs.js on lines 227..234

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

            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.xlabel) {
                  axisopts.xAxes = [{
                    scaleLabel: {
                      display: true,
                      labelString: this.xlabel
            Severity: Minor
            Found in src/elements/chartjs.js and 1 other location - About 30 mins to fix
            src/elements/chartjs.js on lines 219..226

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

            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