netdata/netdata

View on GitHub
src/web/gui/src/dashboard.js/charting/d3pie.js

Summary

Maintainability
F
3 wks
Test Coverage

Function d3pieChartCreate has 156 lines of code (exceeds 25 allowed). Consider refactoring.
Open

NETDATA.d3pieChartCreate = function (state, data) {

    state.element_chart.id = 'd3pie-' + state.uuid;
    // console.log('id = ' + state.element_chart.id);

Severity: Major
Found in src/web/gui/src/dashboard.js/charting/d3pie.js - About 6 hrs to fix

    File d3pie.js has 292 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    
    // d3pie
    
    NETDATA.d3pieInitialize = function (callback) {
        if (typeof netdataNoD3pie === 'undefined' || !netdataNoD3pie) {
    Severity: Minor
    Found in src/web/gui/src/dashboard.js/charting/d3pie.js - About 3 hrs to fix

      Function d3pieInitialize has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      NETDATA.d3pieInitialize = function (callback) {
          if (typeof netdataNoD3pie === 'undefined' || !netdataNoD3pie) {
      
              // d3pie requires D3
              if (!NETDATA.chartLibraries.d3.initialized) {
      Severity: Minor
      Found in src/web/gui/src/dashboard.js/charting/d3pie.js - About 2 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 d3pieInitialize has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      NETDATA.d3pieInitialize = function (callback) {
          if (typeof netdataNoD3pie === 'undefined' || !netdataNoD3pie) {
      
              // d3pie requires D3
              if (!NETDATA.chartLibraries.d3.initialized) {
      Severity: Minor
      Found in src/web/gui/src/dashboard.js/charting/d3pie.js - About 1 hr to fix

        Function d3pieSetContent has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        NETDATA.d3pieSetContent = function (state, data, index) {
            state.legendFormatValueDecimalsFromMinMax(
                data.min,
                data.max
            );
        Severity: Minor
        Found in src/web/gui/src/dashboard.js/charting/d3pie.js - About 1 hr to fix

          Function d3pieChartCreate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          NETDATA.d3pieChartCreate = function (state, data) {
          
              state.element_chart.id = 'd3pie-' + state.uuid;
              // console.log('id = ' + state.element_chart.id);
          
          
          Severity: Minor
          Found in src/web/gui/src/dashboard.js/charting/d3pie.js - About 35 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

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

          NETDATA.d3pieClearSelection = function (state, force) {
              if (typeof state.tmp.d3pie_timer !== 'undefined') {
                  NETDATA.timeout.clear(state.tmp.d3pie_timer);
                  state.tmp.d3pie_timer = undefined;
              }
          Severity: Minor
          Found in src/web/gui/src/dashboard.js/charting/d3pie.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

          NETDATA.d3pieChartCreate = function (state, data) {
          
              state.element_chart.id = 'd3pie-' + state.uuid;
              // console.log('id = ' + state.element_chart.id);
          
          
          Severity: Major
          Found in src/web/gui/src/dashboard.js/charting/d3pie.js and 1 other location - About 1 wk to fix
          src/web/gui/v1/dashboard.js on lines 4056..4229

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

          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

          NETDATA.d3pieInitialize = function (callback) {
              if (typeof netdataNoD3pie === 'undefined' || !netdataNoD3pie) {
          
                  // d3pie requires D3
                  if (!NETDATA.chartLibraries.d3.initialized) {
          Severity: Major
          Found in src/web/gui/src/dashboard.js/charting/d3pie.js and 1 other location - About 1 day to fix
          src/web/gui/v1/dashboard.js on lines 3892..3933

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

          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

          NETDATA.d3pieSetSelection = function (state, t) {
              if (state.timeIsVisible(t) !== true) {
                  return NETDATA.d3pieClearSelection(state, true);
              }
          
          
          Severity: Major
          Found in src/web/gui/src/dashboard.js/charting/d3pie.js and 1 other location - About 1 day to fix
          src/web/gui/v1/dashboard.js on lines 3989..4014

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

          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

          NETDATA.d3pieSetContent = function (state, data, index) {
              state.legendFormatValueDecimalsFromMinMax(
                  data.min,
                  data.max
              );
          Severity: Major
          Found in src/web/gui/src/dashboard.js/charting/d3pie.js and 1 other location - About 1 day to fix
          src/web/gui/v1/dashboard.js on lines 3935..3968

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

          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

          NETDATA.d3pieDateRange = function (state, data, index) {
              let dt = Math.round((data.before - data.after + 1) / data.points);
              let dt_str = NETDATA.seconds4human(dt);
          
              let before = data.result.data[index].time;
          Severity: Major
          Found in src/web/gui/src/dashboard.js/charting/d3pie.js and 1 other location - About 1 day to fix
          src/web/gui/v1/dashboard.js on lines 3970..3987

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

          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

          NETDATA.d3pieClearSelection = function (state, force) {
              if (typeof state.tmp.d3pie_timer !== 'undefined') {
                  NETDATA.timeout.clear(state.tmp.d3pie_timer);
                  state.tmp.d3pie_timer = undefined;
              }
          Severity: Major
          Found in src/web/gui/src/dashboard.js/charting/d3pie.js and 1 other location - About 1 day to fix
          src/web/gui/v1/dashboard.js on lines 4016..4032

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

          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

          NETDATA.d3pieChange = function (state, content, footer) {
              if (state.d3pie_forced_subtitle === null) {
                  //state.d3pie_instance.updateProp("header.subtitle.text", state.units_current);
                  state.d3pie_instance.options.header.subtitle.text = state.units_current;
              }
          Severity: Major
          Found in src/web/gui/src/dashboard.js/charting/d3pie.js and 1 other location - About 6 hrs to fix
          src/web/gui/v1/dashboard.js on lines 4034..4050

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

          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

          NETDATA.d3pieChartUpdate = function (state, data) {
              return NETDATA.d3pieChange(state, NETDATA.d3pieSetContent(state, data, 0), NETDATA.d3pieDateRange(state, data, 0));
          };
          Severity: Minor
          Found in src/web/gui/src/dashboard.js/charting/d3pie.js and 1 other location - About 50 mins to fix
          src/web/gui/v1/dashboard.js on lines 4052..4054

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

          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