phpmyadmin/phpmyadmin

View on GitHub
resources/js/src/table/chart.ts

Summary

Maintainability
F
3 days
Test Coverage

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

function queryChart (data, columnNames, settings) {
    if ($('#querychart').length === 0) {
        return;
    }

Severity: Minor
Found in resources/js/src/table/chart.ts - 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

File chart.ts has 362 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import $ from 'jquery';
import { AJAX } from '../modules/ajax.ts';
import { Functions } from '../modules/functions.ts';
import { ajaxRemoveMessage, ajaxShowMessage } from '../modules/ajax-message.ts';
import { escapeHtml } from '../modules/functions/escape.ts';
Severity: Minor
Found in resources/js/src/table/chart.ts - About 4 hrs to fix

    Function queryChart has 109 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function queryChart (data, columnNames, settings) {
        if ($('#querychart').length === 0) {
            return;
        }
    
    
    Severity: Major
    Found in resources/js/src/table/chart.ts - About 4 hrs to fix

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

      function onXAxisChange () {
          var $xAxisSelect = $('#chartXAxisSelect');
          currentSettings.mainAxis = parseInt(($xAxisSelect.val() as string), 10);
          if (dateTimeCols.indexOf(currentSettings.mainAxis) !== -1) {
              document.getElementById('timelineChartType').classList.remove('d-none');
      Severity: Minor
      Found in resources/js/src/table/chart.ts - 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

      Avoid deeply nested control flow statements.
      Open

                          if (settings.type === 'timeline') { // first column is date type
                              newRow.push(extractDate(row[col]));
                          } else if (settings.type === 'scatter') {
                              newRow.push(parseFloat(row[col]));
                          } else { // first column is string type
      Severity: Major
      Found in resources/js/src/table/chart.ts - About 45 mins to fix

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

        function extractDate (dateString) {
            var matches;
            var match;
            var dateTimeRegExp = /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/;
            var dateRegExp = /[0-9]{4}-[0-9]{2}-[0-9]{2}/;
        Severity: Minor
        Found in resources/js/src/table/chart.ts - 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

            if (dateTimeCols.indexOf(currentSettings.mainAxis) !== -1) {
                document.getElementById('timelineChartType').classList.remove('d-none');
            } else {
                document.getElementById('timelineChartType').classList.add('d-none');
                if (currentSettings.type === 'timeline') {
        Severity: Major
        Found in resources/js/src/table/chart.ts and 1 other location - About 4 hrs to fix
        resources/js/src/table/chart.ts on lines 217..225

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

        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 (numericCols.indexOf(currentSettings.mainAxis) !== -1) {
                document.getElementById('scatterChartType').classList.remove('d-none');
            } else {
                document.getElementById('scatterChartType').classList.add('d-none');
                if (currentSettings.type === 'scatter') {
        Severity: Major
        Found in resources/js/src/table/chart.ts and 1 other location - About 4 hrs to fix
        resources/js/src/table/chart.ts on lines 207..215

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

        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

            $('#chartValueColumnSelect').on('change', function () {
                currentSettings.valueColumn = parseInt(($(this).val() as string), 10);
                drawChart();
            });
        Severity: Major
        Found in resources/js/src/table/chart.ts and 1 other location - About 1 hr to fix
        resources/js/src/table/chart.ts on lines 359..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 62.

        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

            $('#chartSeriesColumnSelect').on('change', function () {
                currentSettings.seriesColumn = parseInt(($(this).val() as string), 10);
                drawChart();
            });
        Severity: Major
        Found in resources/js/src/table/chart.ts and 1 other location - About 1 hr to fix
        resources/js/src/table/chart.ts on lines 365..368

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

        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

            $('#xAxisLabelInput').on('keyup', function () {
                currentSettings.xaxisLabel = $(this).val();
                drawChart();
            });
        Severity: Minor
        Found in resources/js/src/table/chart.ts and 1 other location - About 55 mins to fix
        resources/js/src/table/chart.ts on lines 377..380

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

        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

            $('#yAxisLabelInput').on('keyup', function () {
                currentSettings.yaxisLabel = $(this).val();
                drawChart();
            });
        Severity: Minor
        Found in resources/js/src/table/chart.ts and 1 other location - About 55 mins to fix
        resources/js/src/table/chart.ts on lines 371..374

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

        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