mauriciabad/GradeCalc

View on GitHub

Showing 57 of 76 total issues

File script.js has 2064 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';
/* ------------------------------ START UP ------------------------------ */
var dashboard = document.getElementById('dashboard');
var editSubjectPopup = document.getElementById('edit-popup-content');
var viewSubjectPopup = document.getElementById('view-popup-content');
Severity: Major
Found in src/scripts/script.js - About 5 days to fix

    Function generateEditSubjectUIHTML has 169 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function generateEditSubjectUIHTML(id, subject, popup) {
      let exams = toNewEval(subject.evaluations);
      let evaluations = Object.keys(subject.evaluations);
      let grid = '';
      let newEvals = '';
    Severity: Major
    Found in src/scripts/script.js - About 6 hrs to fix

      Function readSubjectFromPopup has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

      function readSubjectFromPopup(popup) {
        let id = popup.querySelector('input[name="id"]').value;
      
        let newEval = {};
        let grid = popup.querySelector('.edit-popup-grid');
      Severity: Minor
      Found in src/scripts/script.js - About 5 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 editUIUpdateGrid has 140 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function editUIUpdateGrid(grid, e, popup) {
        const input = e.target;
        const elem = input.parentNode == grid ? input : input.parentNode;
        const conditionsElem = grid.parentNode.lastElementChild;
        let conditions = '';
      Severity: Major
      Found in src/scripts/script.js - About 5 hrs to fix

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

        function gradeCalcAllEqual(id, evaluation) {
          let sumUndoneExams = 0;
          let exams = [];
          let expectedMark = 0;
          for (const exam in subjects[id].evaluations[evaluation].exams) {
        Severity: Minor
        Found in src/scripts/script.js - 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

        Function evaluationTree has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

        function evaluationTree(tree, values, now) {
          switch (tree.type) {
            case 'LogicalExpression':
              switch (tree.operator) {
                case '&&':
        Severity: Minor
        Found in src/scripts/script.js - 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

        Function getAndDisplayUserSubjects has 69 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function getAndDisplayUserSubjects() {
          if (isAnonymous) {
            console.warn('To get user info you need to sign in');
            showToast(
              'Para guardar tus notas en la nube',
        Severity: Major
        Found in src/scripts/script.js - About 2 hrs to fix

          Function updateNecesaryMark has a Cognitive Complexity of 20 (exceeds 5 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 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 editUIUpdateGrid has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

          function editUIUpdateGrid(grid, e, popup) {
            const input = e.target;
            const elem = input.parentNode == grid ? input : input.parentNode;
            const conditionsElem = grid.parentNode.lastElementChild;
            let conditions = '';
          Severity: Minor
          Found in src/scripts/script.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 generateEditSubjectUIHTML has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

          function generateEditSubjectUIHTML(id, subject, popup) {
            let exams = toNewEval(subject.evaluations);
            let evaluations = Object.keys(subject.evaluations);
            let grid = '';
            let newEvals = '';
          Severity: Minor
          Found in src/scripts/script.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 isValidSubjectFromPopup has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

          function isValidSubjectFromPopup(subject) {
            // console.log(subject);
            // console.log(isEmpty(subject));
          
            let wrongValue = '';
          Severity: Minor
          Found in src/scripts/script.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 evaluationTree has 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function evaluationTree(tree, values, now) {
            switch (tree.type) {
              case 'LogicalExpression':
                switch (tree.operator) {
                  case '&&':
          Severity: Major
          Found in src/scripts/script.js - About 2 hrs to fix

            Function readSubjectFromPopup has 53 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function readSubjectFromPopup(popup) {
              let id = popup.querySelector('input[name="id"]').value;
            
              let newEval = {};
              let grid = popup.querySelector('.edit-popup-grid');
            Severity: Major
            Found in src/scripts/script.js - About 2 hrs to fix

              Function isValidSubjectFromPopup has 52 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function isValidSubjectFromPopup(subject) {
                // console.log(subject);
                // console.log(isEmpty(subject));
              
                let wrongValue = '';
              Severity: Major
              Found in src/scripts/script.js - About 2 hrs to fix

                Function gradeCalcAllEqual has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function gradeCalcAllEqual(id, evaluation) {
                  let sumUndoneExams = 0;
                  let exams = [];
                  let expectedMark = 0;
                  for (const exam in subjects[id].evaluations[evaluation].exams) {
                Severity: Minor
                Found in src/scripts/script.js - About 2 hrs to fix

                  Function generateInputs has 48 lines of code (exceeds 25 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

                    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

                      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
                        Severity
                        Category
                        Status
                        Source
                        Language