aceberg/ExerciseDiary

View on GitHub

Showing 19 of 19 total issues

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

function weightChart(id, dates, ws, wcolor, xticks) {
    
    const ctx = document.getElementById(id);

    if (wChart){
Severity: Major
Found in internal/web/public/js/weight-chart.js and 1 other location - About 6 hrs to fix
internal/web/public/js/stats.js on lines 58..95

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

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

function statsChart(id, dates, ws, wcolor, xticks) {
    
    const ctx = document.getElementById(id);

    if (sChart){
Severity: Major
Found in internal/web/public/js/stats.js and 1 other location - About 6 hrs to fix
internal/web/public/js/weight-chart.js on lines 17..54

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

Function makeChart has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function makeChart(heat, hcolor, sets) {
    let ldata = lowerData(heat);
    var ctx = document.getElementById('matrix-chart').getContext('2d');
    window.myMatrix = new Chart(ctx, {
        type: 'matrix',
Severity: Major
Found in internal/web/public/js/heatmap.js - About 3 hrs to fix

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

        if (sets) {
            let len = sets.length;
            for (let i = 0 ; i < len; i++) {
                if (sets[i].Date == date) {
                    addExercise(sets[i].Name, sets[i].Weight, sets[i].Reps);
    Severity: Major
    Found in internal/web/public/js/index.js and 1 other location - About 2 hrs to fix
    internal/web/public/js/index.js on lines 84..91

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

    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 (exs) {
            let len = exs.length;
            for (let i = 0 ; i < len; i++) {
                if (exs[i].Group == gr) {
                    addExercise(exs[i].Name, exs[i].Weight, exs[i].Reps);
    Severity: Major
    Found in internal/web/public/js/index.js and 1 other location - About 2 hrs to fix
    internal/web/public/js/index.js on lines 30..37

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

    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 (arrayLength > move) {
            start = arrayLength - move;
            end = start + step;
        } else {
            sOffset = sOffset - 1;
    Severity: Major
    Found in internal/web/public/js/stats.js and 1 other location - About 2 hrs to fix
    internal/web/public/js/weight.js on lines 28..38

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

    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 (arrayLength > move) {
            start = arrayLength - move;
            end = start + step;
        } else {
            offset = offset - 1;
    Severity: Major
    Found in internal/web/public/js/weight.js and 1 other location - About 2 hrs to fix
    internal/web/public/js/stats.js on lines 31..41

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

    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

    function addSet(i, date, reps, weight) {
    
        html_code = '<tr><td style="opacity: 45%;">'+i+'.</td><td>'+date+'</td><td>'+reps+'</td><td>'+weight+'</td></tr>';
    
        document.getElementById('stats-table').insertAdjacentHTML('beforeend', html_code);
    Severity: Major
    Found in internal/web/public/js/stats.js and 1 other location - About 1 hr to fix
    internal/web/public/js/weight.js on lines 9..14

    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 2 locations. Consider refactoring.
    Open

    function addWeight(i, date, weight, id) {
    
        html_code = '<tr><td style="opacity: 45%;">'+i+'.</td><td>'+date+'</td><td>'+weight+'</td><td><a href="/weight/?del='+id+'"><button class="btn del-set-button" title="Delete" ><i class="bi bi-x-square"></i></button></a></td></tr>';
    
        document.getElementById('weightList').insertAdjacentHTML('beforeend', html_code);
    Severity: Major
    Found in internal/web/public/js/weight.js and 1 other location - About 1 hr to fix
    internal/web/public/js/stats.js on lines 4..9

    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

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

    function setStatsPage(sets, hcolor, off, step) {
        let start = 0, end = 0;
        let dates = [], ws = [], reps = [], exs = []; 
    
        let ex = document.getElementById("ex-value").value;
    Severity: Minor
    Found in internal/web/public/js/stats.js - About 1 hr to fix

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

      function statsChart(id, dates, ws, wcolor, xticks) {
          
          const ctx = document.getElementById(id);
      
          if (sChart){
      Severity: Minor
      Found in internal/web/public/js/stats.js - About 1 hr to fix

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

        function weightChart(id, dates, ws, wcolor, xticks) {
            
            const ctx = document.getElementById(id);
        
            if (wChart){
        Severity: Minor
        Found in internal/web/public/js/weight-chart.js - About 1 hr to fix

          Function setStatsPage has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          function setStatsPage(sets, hcolor, off, step) {
              let start = 0, end = 0;
              let dates = [], ws = [], reps = [], exs = []; 
          
              let ex = document.getElementById("ex-value").value;
          Severity: Minor
          Found in internal/web/public/js/stats.js - About 1 hr 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 setWeights has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function setWeights(weights, wcolor, off, step) {
              let start = 0, end = 0;
              let dates = [], ws = [];
          
              offset = offset + off;
          Severity: Minor
          Found in internal/web/public/js/weight.js - About 1 hr to fix

            Function statsChart has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function statsChart(id, dates, ws, wcolor, xticks) {
            Severity: Minor
            Found in internal/web/public/js/stats.js - About 35 mins to fix

              Function weightChart has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              function weightChart(id, dates, ws, wcolor, xticks) {
              Severity: Minor
              Found in internal/web/public/js/weight-chart.js - About 35 mins to fix

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

                function setWeights(weights, wcolor, off, step) {
                    let start = 0, end = 0;
                    let dates = [], ws = [];
                
                    offset = offset + off;
                Severity: Minor
                Found in internal/web/public/js/weight.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 setFormContent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                function setFormContent(sets, date) {
                    window.sessionStorage.setItem("today", date);
                    document.getElementById('todayEx').innerHTML = "";
                    document.getElementById("formDate").value = date;
                    document.getElementById("realDate").value = date;
                Severity: Minor
                Found in internal/web/public/js/index.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

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

                function addAllGroup(exs, gr) {
                
                    // console.log('GR =', gr);
                    // console.log('SETS =', exs);
                
                
                Severity: Minor
                Found in internal/web/public/js/index.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

                Severity
                Category
                Status
                Source
                Language