nus-mtp/sashimi-note

View on GitHub

Showing 117 of 330 total issues

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

function AMTparseIexpr(str) {
  let sym2;
  let node;
  let result;
  str = AMremoveCharsAndBlanks(str, 0);
Severity: Minor
Found in sashimi-webapp/src/logic/documentPackager/plugins/ASCIIMathTeXImg.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 sqlCommands has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

export default function sqlCommands() {
  this.linkDatabaseToIndexedDB = function linkDatabaseToIndexedDB(databaseName) {
    return new Promise((resolve, reject) => {
      databaseName = resolveSQLInjection(databaseName);
      const databaseRequestStr = stringManipulator.stringConcat(
Severity: Minor
Found in sashimi-webapp/src/database/sql-related/sqlCommands.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 changeFolderName has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  this.changeFolderName = function changeFolderName(folderId, newFolderName) {
    return new Promise((resolve, reject) => {
      let prevFolderPath;
      let thisFolderPath;
      let newFolderPath;
Severity: Major
Found in sashimi-webapp/src/database/sql-related/sqlCommands.js - About 2 hrs to fix

    Function addEventListeners has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    DocumentNavigator.prototype.addEventListeners = function addEventListeners() {
      this.eventInstance = {
        pointers: {},
        numPointers: 0,
        state: {
    Severity: Minor
    Found in sashimi-webapp/src/logic/inputHandler/DocumentNavigator/index.js - About 1 hr to fix

      Function AMprocessNodeR has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function AMprocessNodeR(n, linebreaks) {
        let mtch;
        let str;
        let arr;
        let frg;

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

          scrollTo(destination, duration = 200, callback) {
            // Handle case where this code is used in an iframe element
            let viewerDoc = this.getDocument(destination);
            let viewWindow = this.getWindow(destination);
            if (typeof destination === 'number') {
        Severity: Minor
        Found in sashimi-webapp/src/helpers/elementUtils.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 AMTparseIexpr has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function AMTparseIexpr(str) {
          let sym2;
          let node;
          let result;
          str = AMremoveCharsAndBlanks(str, 0);

          Function scrollTo has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            scrollTo(destination, duration = 200, callback) {
              // Handle case where this code is used in an iframe element
              let viewerDoc = this.getDocument(destination);
              let viewWindow = this.getWindow(destination);
              if (typeof destination === 'number') {
          Severity: Minor
          Found in sashimi-webapp/src/helpers/elementUtils.js - About 1 hr to fix

            Function deleteFolder has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              this.deleteFolder = function deleteFolder(folderId) {
                return new Promise((resolve, reject) => {
                  let thisFolderPath;
                  let foldersToDelete;
                  let filesToDelete;
            Severity: Minor
            Found in sashimi-webapp/src/database/sql-related/sqlCommands.js - About 1 hr to fix

              Function AMposition has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

              function AMposition(arr, str, n) {
              // return position >=n where str appears or would be inserted
              // assumes arr is sorted
                let i;
                if (n===0) {

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

              function searchFrom(frameDoc, direction) {
                const x = frameDoc.defaultView.innerWidth/2;
                const yLimit = frameDoc.defaultView.innerHeight;
                const interval = 10;
              
              
              Severity: Minor
              Found in sashimi-webapp/src/logic/inputHandler/SlidesNavigator/index.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 stringManipulation has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export default function stringManipulation() {
                this.stringConcat = function stringConcat(...stringToConcat) {
                  return stringToConcat.join('');
                };
              
              
              Severity: Minor
              Found in sashimi-webapp/src/database/stringManipulation.js - About 1 hr to fix

                Function addStyle has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  addStyle(frameElement, styleUrl) {
                    return new Promise((resolve, reject) => {
                      const frameDoc = this.getDocument(frameElement);
                      const styleElement = constructStyleLink(frameDoc, styleUrl);
                
                
                Severity: Minor
                Found in sashimi-webapp/src/helpers/documentBuilder.js - About 1 hr to fix

                  Function shouldPageBreak has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const shouldPageBreak = function shouldPageBreak(eleHeightArray, index, page) {
                    const BREAK_PAGE = true;
                    const DO_NOTHING = false;
                  
                    const element = eleHeightArray[index].ele;
                  Severity: Minor
                  Found in sashimi-webapp/src/logic/renderer/core.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 sqlArray has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export default function sqlArray() {
                    this.initializeAlasqlArray = function initializeAlasqlArray() {
                      if (!isAlasqlArrayInitialized) {
                        sqlObject = {};
                        isAlasqlArrayInitialized = constants.CONST_ALASQL_CREATION_INITIALIZED;
                  Severity: Minor
                  Found in sashimi-webapp/src/database/generated-data/sqlArray.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 creationOfTables has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function creationOfTables() {
                    return new Promise((resolve, reject) => {
                      query.isTableExistsInDatabase(constants.ENTITIES_USER)
                      .then(isUserTableFirstInitialize =>
                        createUserTable(isUserTableFirstInitialize)
                  Severity: Minor
                  Found in sashimi-webapp/src/database/storage.js - About 1 hr to fix

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

                      updateReferenceFrame: function updateReferenceFrame(pageRenderer) {
                        const rf = pageRenderer.referenceFrame;
                        rf.innerHTML = pageRenderer.sourceHTML;
                    
                        const pPPFs = pageRenderer.postProcessPromiseFns;
                    Severity: Minor
                    Found in sashimi-webapp/src/logic/renderer/core.js - About 1 hr to fix

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

                      function AMparseMath(str) {
                       // DLMOD to remove  , which editor adds on multiple spaces
                        str = str.replace(/( |\u00a0| )/g, '');
                        str = str.replace(/>/g, '>');
                        str = str.replace(/&lt;/g, '<');

                        Consider simplifying this complex logical expression.
                        Open

                                if (st==='^' || st==='_' || st==='/' || st==='|' || st===','
                                   || (symbol.input.length===1 && symbol.input.match(/\w/) && st!=='(')) {
                                  return [`{${AMTgetTeXsymbol(symbol)}}`, str];
                                } else {
                                  node = `{${AMTgetTeXsymbol(symbol)}{${result[0]}}}`;
                        Severity: Critical
                        Found in sashimi-webapp/src/logic/documentPackager/plugins/ASCIIMathTeXImg.js - About 1 hr to fix

                          Consider simplifying this complex logical expression.
                          Open

                              if ((n.nodeType!==8 || linebreaks) &&
                              n.parentNode.nodeName!=='form' && n.parentNode.nodeName!=='FORM' &&
                              n.parentNode.nodeName!=='textarea' && n.parentNode.nodeName!=='TEXTAREA' &&
                              n.parentNode.nodeName!=='pre' && n.parentNode.nodeName!=='PRE') {
                                str = n.nodeValue;
                          Severity: Critical
                          Found in sashimi-webapp/src/logic/documentPackager/plugins/ASCIIMathTeXImg.js - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language