nus-mtp/sashimi-note

View on GitHub

Showing 330 of 330 total issues

Function AMTparseExpr has a Cognitive Complexity of 155 (exceeds 5 allowed). Consider refactoring.
Open

function AMTparseExpr(str, rightbracket) {
  let symbol;
  let node;
  let result;
  let i;
Severity: Minor
Found in sashimi-webapp/src/logic/documentPackager/plugins/ASCIIMathTeXImg.js - About 3 days 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

File ASCIIMathTeXImg.js has 888 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
ASCIIMathTeXImg.js
Based on ASCIIMathML, Version 1.4.7 Aug 30, 2005, (c) Peter Jipsen http://www.chapman.edu/~jipsen
Modified with TeX conversion for IMG rendering Sept 6, 2006 (c) David Lippman http://www.pierce.ctc.edu/dlippman
  Updated to match ver 2.2 Mar 3, 2014
Severity: Major
Found in sashimi-webapp/src/logic/documentPackager/plugins/ASCIIMathTeXImg.js - About 2 days to fix

    Function sqlCommands has 315 lines of code (exceeds 25 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: Major
    Found in sashimi-webapp/src/database/sql-related/sqlCommands.js - About 1 day to fix

      File sqlCommands.spec.js has 673 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import SqlCommands from 'src/database/sql-related/sqlCommands';
      import SqlArray from 'src/database/generated-data/sqlArray';
      import StringManipulator from 'src/database/stringManipulation';
      import exceptions from 'src/database/exceptions';
      import defaultFeatureFile from 'src/../static/data/features.txt';

        Function AMTparseSexpr has a Cognitive Complexity of 71 (exceeds 5 allowed). Consider refactoring.
        Open

        function AMTparseSexpr(str) { // parses str and returns [node,tailstr]
          let symbol;
          let node;
          let result;
          let i;
        Severity: Minor
        Found in sashimi-webapp/src/logic/documentPackager/plugins/ASCIIMathTeXImg.js - About 1 day 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

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

        function cascadeChangeFilePath(index, prevBasePath, newBasePath, fileArr) {
          return new Promise((resolve, reject) => {
            if (index >= fileArr.length) {
              resolve(true);
            }
        Severity: Major
        Found in sashimi-webapp/src/database/sql-related/sqlCommands.js and 1 other location - About 1 day to fix
        sashimi-webapp/src/database/sql-related/sqlCommands.js on lines 112..135

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

        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 cascadeChangeFolderPath(index, prevBasePath, newBasePath, folderArr) {
          return new Promise((resolve, reject) => {
            if (index >= folderArr.length) {
              resolve(true);
            }
        Severity: Major
        Found in sashimi-webapp/src/database/sql-related/sqlCommands.js and 1 other location - About 1 day to fix
        sashimi-webapp/src/database/sql-related/sqlCommands.js on lines 63..86

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

        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

        File sqlCommands.js has 528 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import StringManipulator from 'src/database/stringManipulation';
        import constants from 'src/database/constants';
        import DateTime from 'src/database/generated-data/dateTime';
        import exceptions from 'src/database/exceptions';
        
        
        Severity: Major
        Found in sashimi-webapp/src/database/sql-related/sqlCommands.js - About 1 day to fix

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

                        } else if (subpos[pos[i]].length===1) { // var subarr = newFrag.substr(pos[i]+8,pos[i+1]-pos[i]-16).split(',');
                          subarr = [newFrag.substr(pos[i]+8, pos[i+1]-pos[i]-16)];
                        } else {
                          subarr = [newFrag.substring(pos[i]+8, subpos[pos[i]][1])];
                          for (let j=2; j<subpos[pos[i]].length; j+=1) {
          sashimi-webapp/src/logic/documentPackager/plugins/ASCIIMathTeXImg.js on lines 676..684

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

          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

              it('should handle drawing of flow charts', (done) => {
                // Clears Maps
                textActual.clear();
                textExpected.clear();
                // Retrieve HTML string from getHtmlData
          sashimi-webapp/test/unit/specs/logic/diagramsRenderer.spec.js on lines 386..409

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

          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

              it('should handle drawing of mermaid diagrams', (done) => {
                // Clears Maps
                textActual.clear();
                textExpected.clear();
                // Retrieve HTML string from getHtmlData
          sashimi-webapp/test/unit/specs/logic/diagramsRenderer.spec.js on lines 336..359

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

          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 (subpos[pos[i]].length===1) {
                            subarr = [newFrag.substr(pos[i]+7, pos[i+1]-pos[i]-15)];
                          } else {
                            subarr = [newFrag.substring(pos[i]+7, subpos[pos[i]][1])];
                            for (let j=2; j<subpos[pos[i]].length; j+=1) {
          sashimi-webapp/src/logic/documentPackager/plugins/ASCIIMathTeXImg.js on lines 685..693

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

          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

                  it('throw an exception for invalid file name', (done) => {
                    sqlCommands.changeFileName(7, '"')
                    .catch(sqlErr =>
                      expect(sqlErr.name).to.equal('InvalidRename')
                    )
          sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 585..604

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

          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

                  it('throw an exception for invalid folder name', (done) => {
                    sqlCommands.changeFolderName(6, '"')
                    .catch(sqlErr =>
                      expect(sqlErr.name).to.equal('InvalidRename')
                    )
          sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 565..584

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

          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

            describe('getFolderFromMap()', () => {
              it('should throw an error if folder ID is null', () => {
                expect(() => {
                  idMap.getFolderFromMap(null);
                }).to.throw(Error);
          sashimi-webapp/test/unit/specs/logic/filemanager/operations/idmap.spec.js on lines 39..54

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

          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

            static searchString(searchString) {
              return new Promise((resolve, reject) => {
                const fileAndFolderArray = [];
          
                initPromiseSequence()
          Severity: Major
          Found in sashimi-webapp/src/database/retrieve/query.js and 1 other location - About 7 hrs to fix
          sashimi-webapp/src/database/retrieve/query.js on lines 93..107

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

          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

            describe('getFileFromMap()', () => {
              it('should throw an error if file ID is null', () => {
                expect(() => {
                  idMap.getFileFromMap(null);
                }).to.throw(Error);
          sashimi-webapp/test/unit/specs/logic/filemanager/operations/idmap.spec.js on lines 57..72

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

          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

            static loadFolder(folderId) {
              return new Promise((resolve, reject) => {
                const fileAndFolderArray = [];
          
                initPromiseSequence()
          Severity: Major
          Found in sashimi-webapp/src/database/retrieve/query.js and 1 other location - About 7 hrs to fix
          sashimi-webapp/src/database/retrieve/query.js on lines 77..91

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

          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

            getFile: function getFile(id) {
              let fileID = INVALID_ID;
          
              if (typeof id === 'string') {
                if (id.match(NUMBER_ONLY) == null) {
          Severity: Major
          Found in sashimi-webapp/src/logic/filemanager/operations/core.js and 1 other location - About 6 hrs to fix
          sashimi-webapp/src/logic/filemanager/operations/core.js on lines 186..210

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

          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

            getFolder: function getFolder(id) {
              let folderID = INVALID_ID;
          
              if (typeof id === 'string') {
                if (id.match(NUMBER_ONLY) == null) {
          Severity: Major
          Found in sashimi-webapp/src/logic/filemanager/operations/core.js and 1 other location - About 6 hrs to fix
          sashimi-webapp/src/logic/filemanager/operations/core.js on lines 154..178

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

          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