mauriciabad/GradeCalc

View on GitHub

Showing 76 of 76 total issues

Function generateInputs has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

function generateInputs(id) {
  let html = '';
  let types = {};

  for (const examName in subjects[id].evaluations[
Severity: Minor
Found in src/scripts/script.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 generateBar has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function generateBar(id) {
  let weight = 0;
  let barHTML = '';
  for (const exam in subjects[id].evaluations[subjects[id].selectedEvaluation]
    .exams) {
Severity: Minor
Found in src/scripts/script.js - About 1 hr to fix

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

    function getInput(id, exam) {
      let elem = document.getElementById('in-' + id + exam);
      if (!elem) {
        createSubjectCardCollapsed(id);
        elem = document.getElementById('in-' + id + exam);
    Severity: Major
    Found in src/scripts/script.js and 1 other location - About 1 hr to fix
    src/scripts/script.js on lines 1009..1016

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

    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 getBarElem(id, exam) {
      let elem = document.getElementById('bar-' + id + exam);
      if (!elem) {
        createSubjectCardCollapsed(id);
        elem = document.getElementById('bar-' + id + exam);
    Severity: Major
    Found in src/scripts/script.js and 1 other location - About 1 hr to fix
    src/scripts/script.js on lines 1000..1007

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

    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 generateEditSubjectUI(id, subject = subjects[id]) {
      let html = generateEditSubjectUIHTML(id, subject, 'edit');
    
      editSubjectPopup.innerHTML = html;
    
    
    Severity: Major
    Found in src/scripts/script.js and 1 other location - About 1 hr to fix
    src/scripts/script.js on lines 554..563

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

    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 generateViewSubjectUI(id, subject) {
      let html = generateEditSubjectUIHTML(id, subject, 'view');
    
      viewSubjectPopup.innerHTML = html;
    
    
    Severity: Major
    Found in src/scripts/script.js and 1 other location - About 1 hr to fix
    src/scripts/script.js on lines 565..574

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

    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 (
                tree['left'].type != 'Identifier' ||
                tree['right'].type != 'Literal'
              ) {
                return null;
    Severity: Major
    Found in src/scripts/script.js and 1 other location - About 1 hr to fix
    src/scripts/script.js on lines 1250..1260

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

    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 round(n, d = 2) {
      return isNaN(n) || n === '' || n == undefined
        ? undefined
        : Math.floor(Math.round(n * 10 ** d)) / 10 ** d;
    }
    Severity: Major
    Found in src/scripts/script.js and 1 other location - About 1 hr to fix
    src/scripts/subject.js on lines 128..130

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

    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

      round(n, d = 2) {
        return (isNaN(n) || n === '' || n == undefined) ? undefined : Math.floor(Math.round(n * (10 ** d))) / (10 ** d);
      }
    Severity: Major
    Found in src/scripts/subject.js and 1 other location - About 1 hr to fix
    src/scripts/script.js on lines 1074..1078

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

    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 (
                tree['left'].type != 'Identifier' ||
                tree['right'].type != 'Literal' ||
                identifierCategory(tree['left'].name) != 'evaluations'
              ) {
    Severity: Major
    Found in src/scripts/script.js and 1 other location - About 1 hr to fix
    src/scripts/script.js on lines 1239..1247

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

    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 editGridFade has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    function editGridFade(grid, type, n) {
      let removed = false;
      for (let element of grid.querySelectorAll(`*[data-${type}]`)) {
        if (parseInt(element.dataset[type]) == n) {
          element.classList.add(`edit-new-${type}`);
    Severity: Minor
    Found in src/scripts/script.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 displayNecesaryMark has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function displayNecesaryMark(id) {
      let card = getCard(id);
      let barUndone = card.getElementsByClassName('scolN');
      let inUndone = card.getElementsByClassName('scolN2');
    
    
    Severity: Minor
    Found in src/scripts/script.js - About 1 hr to fix

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

      function editGridFade(grid, type, n) {
        let removed = false;
        for (let element of grid.querySelectorAll(`*[data-${type}]`)) {
          if (parseInt(element.dataset[type]) == n) {
            element.classList.add(`edit-new-${type}`);
      Severity: Minor
      Found in src/scripts/script.js - About 1 hr to fix

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

        function completeSubject(...subjects) {
          let subject = Object.assign(
            {
              evaluations: {},
              grades: {},
        Severity: Minor
        Found in src/scripts/script.js - About 1 hr to fix

          Function updateNecesaryMark has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function updateNecesaryMark(id) {
            let evaluation = subjects[id].selectedEvaluation;
            let identifiers = getConditionIdentifiers(id, evaluation);
            for (const exam in subjects[id].necesaryMarks[evaluation]) {
              subjects[id].necesaryMarks[evaluation][exam] = undefined;
          Severity: Minor
          Found in src/scripts/script.js - About 1 hr to fix

            Function autoUpdate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function autoUpdate(id) {
              if (
                subjects[id].evaluation != undefined ||
                subjects[id].evaluations == undefined
              ) {
            Severity: Minor
            Found in src/scripts/script.js - About 1 hr to fix

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

              function autoUpdate(id) {
                if (
                  subjects[id].evaluation != undefined ||
                  subjects[id].evaluations == undefined
                ) {
              Severity: Minor
              Found in src/scripts/script.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 shape has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              var shape = function shape(element) {
                var list = [
                // Square
                function (e) {
                  var size = Math.round((Math.random() + 0.5) * 10) + 'px';
              Severity: Minor
              Found in lib/confetti.js - About 1 hr to fix

                Function gradeCalcAllEqual has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  gradeCalcAllEqual(evaluation = this.selectedEvaluation) {
                    const passMark = this.evaluations[evaluation].passMark || 5;
                    let sumUndoneExams = 0;
                    let exams = [];
                    let currentFinalMark = 0;
                Severity: Minor
                Found in src/scripts/subject.js - About 55 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 editGridUnfade has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                function editGridUnfade(grid, type, n) {
                  for (let element of grid.querySelectorAll(`*[data-${type}='${n}'`)) {
                    if (
                      (element.dataset.evaluation == undefined ||
                        parseInt(element.dataset.evaluation) <
                Severity: Minor
                Found in src/scripts/script.js - About 55 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