nus-mtp/sashimi-note

View on GitHub

Showing 330 of 330 total issues

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

      expect(userData).to.deep.equal([{
        folder_id: 0,
        parent_folder_id: -1,
        permission_index: 1,
        organization_id: 1,
sashimi-webapp/test/unit/specs/database/create/entitiesCreator.spec.js on lines 220..229

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

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 getChildFolder(queue, parentID) {
  parentID = (parentID == null) ? NO_PARENT_ID: parentID;
  const index = queue.findIndex(dbFolderObj => dbFolderObj.parent_folder_id === parentID);
  return removeElementAtIndex(queue, index);
}
Severity: Major
Found in sashimi-webapp/src/logic/filemanager/operations/core.js and 1 other location - About 1 hr to fix
sashimi-webapp/src/logic/filemanager/operations/core.js on lines 53..57

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

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 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, '<');

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

                  dataAdd.createNewFolder(1, '/root/', 0)
                  .then(() =>
                    sqlCommands.getMaxFolderId()
                    .then(maxFileId =>
                      expect(maxFileId).to.equal(1)
            sashimi-webapp/test/unit/specs/database/data-modifier/dataAdd.spec.js on lines 125..140

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

            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

              addFileToMap: function addFileToMap(fileID, fileObj) {
                if (!isID(fileID)) {
                  throw new Error(ERROR_NOT_ID);
                }
                if (!isFile(fileObj)) {
            Severity: Major
            Found in sashimi-webapp/src/logic/filemanager/data/idmap.js and 1 other location - About 1 hr to fix
            sashimi-webapp/src/logic/filemanager/data/idmap.js on lines 69..77

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

            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

              addFolderToMap: function addFolderToMap(folderID, folderObj) {
                if (!isID(folderID)) {
                  throw new Error(ERROR_NOT_ID);
                }
                if (!isFolder(folderObj)) {
            Severity: Major
            Found in sashimi-webapp/src/logic/filemanager/data/idmap.js and 1 other location - About 1 hr to fix
            sashimi-webapp/src/logic/filemanager/data/idmap.js on lines 53..61

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

            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

                  dataAdd.createNewFile(1, '/root/', 0)
                  .then(() =>
                    sqlCommands.getMaxFileId()
                    .then(maxFileId =>
                      expect(maxFileId).to.equal(2)
            sashimi-webapp/test/unit/specs/database/data-modifier/dataAdd.spec.js on lines 148..163

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

            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

                  query.isTableExistsInDatabase(constants.ENTITIES_FILE_MANAGER)
                  .then(isFileTableFirstInitialize =>
                    createFileManagerTable(isFileTableFirstInitialize)
                    .then(isSuccess => isSuccess)
                    .catch(sqlError => reject(sqlError))
            Severity: Major
            Found in sashimi-webapp/src/database/storage.js and 1 other location - About 1 hr to fix
            sashimi-webapp/src/database/storage.js on lines 66..79

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

            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

            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

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

                      } else if (st==='\\rbrace}') {
                        node = `{${node.substr(leftchop)}`;
                        node = `${node.substr(0, node.length-14)}}`;
                      }
                sashimi-webapp/src/logic/documentPackager/plugins/ASCIIMathTeXImg.js on lines 440..446

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

                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 (st==='\\right)}' || st==='\\right]}' || st==='\\right.}') {
                        node = `{${node.substr(leftchop)}`;
                        node = `${node.substr(0, node.length-8)}}`;
                      } else if (st==='\\rbrace}') {
                        node = `{${node.substr(leftchop)}`;
                sashimi-webapp/src/logic/documentPackager/plugins/ASCIIMathTeXImg.js on lines 443..446

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

                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 AMTremoveBrackets has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function AMTremoveBrackets(node) {
                  let st;
                  if (node.charAt(0)==='{' && node.charAt(node.length-1)==='}') {
                    let leftchop = 0;
                
                

                  Function searchElement has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function searchElement(scrollDocument = document) {
                    const x = scrollDocument.defaultView.innerWidth/2;
                    const yLimit = (scrollDocument.defaultView.innerHeight * 0.25); // Search only the top 25% of the window
                    const offsetTop = 50;
                    for (let i = offsetTop; i < yLimit + offsetTop; i += 1) {
                  Severity: Minor
                  Found in sashimi-webapp/src/logic/inputHandler/scrollSync/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

                  Severity
                  Category
                  Status
                  Source
                  Language