mauriciabad/GradeCalc

View on GitHub

Showing 76 of 76 total issues

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

function toNewEval(evaluations) {
  let newEval = {};
  for (const evaluation in evaluations) {
    for (const exam in evaluations[evaluation].exams) {
      if (!newEval[exam]) newEval[exam] = {};
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

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

window.confetti = function (root)




Severity: Minor
Found in lib/confetti.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

Avoid deeply nested control flow statements.
Open

            if (
              subjects[id].necesaryMarks[evaluation][exam] !== undefined &&
              subjects[id].necesaryMarks[evaluation][exam] <
                identifiers.types[type].value
            ) {
Severity: Major
Found in src/scripts/script.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                      if (!subjects[id]) subjects[id] = {};
    Severity: Major
    Found in src/scripts/script.js - About 45 mins to fix

      Function displayNecesaryMark has a Cognitive Complexity of 8 (exceeds 5 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 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

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

      function toNewEvalNeeeeeeeeew(evaluations) {
        var evaluationNew = {};
        for (let evaluation in evaluations) {
          if (evaluations[evaluation].exams) return evaluations;
          evaluationNew[evaluation] = {};
      Severity: Minor
      Found in src/scripts/script.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

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

      function uploadToDB(db, ref, value) {
        if (!isAnonymous) {
          let obj = {};
          if (ref) {
            if (
      Severity: Minor
      Found in src/scripts/script.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

      Function generateBar has a Cognitive Complexity of 8 (exceeds 5 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 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

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

      function updateFinalMark(id, confetti = true) {
        for (const evaluation in subjects[id].evaluations) {
          subjects[id].finalMark[evaluation] = 0;
          for (const exam in subjects[id].evaluations[evaluation].exams) {
            if (!isUndone(id, exam))
      Severity: Minor
      Found in src/scripts/script.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

      Avoid deeply nested control flow statements.
      Open

                if (canPass === false) {
                  subjects[id].necesaryMarks[evaluation][exam] = null;
                } else {
                  subjects[id].necesaryMarks[evaluation][exam] = Math.max(
                    0,
      Severity: Major
      Found in src/scripts/script.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                  if (exam && examType && weight) {
                    if (!newEval[evaluation]) newEval[evaluation] = {};
                    if (!newEval[evaluation].exams) newEval[evaluation].exams = {};
                    if (!newEval[evaluation].exams[exam])
                      newEval[evaluation].exams[exam] = {};
        Severity: Major
        Found in src/scripts/script.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                            if (!userInfo.subjects[id]) userInfo.subjects[id] = {};
          Severity: Major
          Found in src/scripts/script.js - About 45 mins to fix

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

            function addSubjects() {
              showLoader('Cargando tus asignaturas', 'dashboard');
              document.getElementById('search-subject-input').value = '';
            
              for (let id in subjectsToAdd) {
            Severity: Minor
            Found in src/scripts/script.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

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

            function findIdentifiersTree(tree, identifiers, types, id, evaluation) {
            Severity: Minor
            Found in src/scripts/script.js - About 35 mins to fix

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

              function completeSubject(...subjects) {
                let subject = Object.assign(
                  {
                    evaluations: {},
                    grades: {},
              Severity: Minor
              Found in src/scripts/script.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 editGridFadeOrUnfade has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              function editGridFadeOrUnfade(grid, element, check = ['exam', 'evaluation']) {
                for (const type of check) {
                  if (
                    element.dataset[type] != undefined &&
                    parseInt(element.dataset[type]) < parseInt(grid.dataset[type + 's'])
              Severity: Minor
              Found in src/scripts/script.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 saveEditSubject has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              function saveEditSubject() {
                let newSubject = readSubjectFromPopup(editSubjectPopup);
                let id = newSubject.id;
              
                if (newSubject.shortName != subjects[id].shortName)
              Severity: Minor
              Found in src/scripts/script.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 findIdentifiersTree has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              function findIdentifiersTree(tree, identifiers, types, id, evaluation) {
                switch (tree.type) {
                  case 'LogicalExpression':
                  case 'BinaryExpression':
                    if (
              Severity: Minor
              Found in src/scripts/script.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

              Avoid too many return statements within this function.
              Open

                return true;
              Severity: Major
              Found in src/scripts/script.js - About 30 mins to fix

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

                      appendElement(
                        grid,
                        `<input style="grid-row: ${
                          2 + parseInt(grid.dataset.exams)
                        }; grid-column: 2;" class="edit-new-exam" type="text"   name="examType"   value="" data-exam="${
                Severity: Minor
                Found in src/scripts/script.js and 2 other locations - About 30 mins to fix
                src/scripts/script.js on lines 1608..1615
                src/scripts/script.js on lines 1624..1631

                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

                Severity
                Category
                Status
                Source
                Language