nus-mtp/sashimi-note

View on GitHub

Showing 330 of 330 total issues

Function default has 88 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function(navInstance) {
  // Event handlers
  this.eventFn = {
    gesture: {
      dragstart(event) {

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

        requestOpenDatabase.onsuccess = function onSuccess(event) {
          const tableNames = event.target.result.objectStoreNames;
          if (tableNames.contains(tableName) === false) {
            requestOpenDatabase.result.close();
            resolve(false);
    Severity: Major
    Found in sashimi-webapp/src/database/create/entitiesCreator.js and 1 other location - About 3 hrs to fix
    sashimi-webapp/src/database/retrieve/query.js on lines 56..65

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

    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

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

          requestOpenDatabase.onsuccess = function onSuccess(event) {
            const tableNames = event.target.result.objectStoreNames;
            if (tableNames.contains(tableName) === false) {
              requestOpenDatabase.result.close();
              resolve(false);
    Severity: Major
    Found in sashimi-webapp/src/database/retrieve/query.js and 1 other location - About 3 hrs to fix
    sashimi-webapp/src/database/create/entitiesCreator.js on lines 12..21

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

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

    function hideShowBlock(state, startLine, endLine, silent) {
      let nextLine; // next line counter, to keep track of line number
      let token;  // token for use to pass into renderer to generate HTML
      let category = ''; // variable to store conditional hiding for different document types
      let hasCategory = false;

      Function regexHelper has 83 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function regexHelper(diff, exp, act) {
        const ignoredAttr = ['id', 'marker-end', 'x1', 'x2', 'x', 'y1', 'y2', 'y', 'width',
          'height', 'd', 'dy', 'r', 'style', 'viewBox', 'transform', 'points'];
        const missedArray = [];
      
      
      Severity: Major
      Found in sashimi-webapp/test/unit/specs/logic/diagramsRenderer.spec.js - About 3 hrs to fix

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

                  sqlCommands.changeFileName(7, 'new')
                  .then(() =>
                    sqlCommands.loadFilesFromFolder(5)
                    .then(filesData =>
                      expect(filesData).to.deep.equal([editedFile])
        sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 644..654

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

        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

                  sqlCommands.changeFilePath(3, '/root/documentary/')
                  .then(() =>
                    sqlCommands.loadFilesFromFolder(1)
                    .then(filesData =>
                      expect(filesData).to.deep.equal([editedFile])
        sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 553..563

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

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

        DocumentNavigator.prototype.addDomStyling = function addDomStyling() {
          // Reset parent height to force DOM relayout
          // [1] Initialise layout properties
          const containerReference = this.el.container;
          const containerRefStyle = domUtils.getComputedStyle(containerReference);
        Severity: Major
        Found in sashimi-webapp/src/logic/inputHandler/DocumentNavigator/index.js - About 3 hrs to fix

          Function AMgetSymbol has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

          function AMgetSymbol(str) {
          // return maximal initial substring of str that appears in names
          // return null if there is none
            let k = 0; // new pos
            let j = 0; // old pos
          Severity: Minor
          Found in sashimi-webapp/src/logic/documentPackager/plugins/ASCIIMathTeXImg.js - About 3 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 AMTremoveBrackets has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

          function AMTremoveBrackets(node) {
            let st;
            if (node.charAt(0)==='{' && node.charAt(node.length-1)==='}') {
              let leftchop = 0;
          
          
          Severity: Minor
          Found in sashimi-webapp/src/logic/documentPackager/plugins/ASCIIMathTeXImg.js - About 3 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

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

              it('should handle generation of diagram pre tags for drawing diagrams', (done) => {
                documentPackager.getHtmlData(diagramsInput).then((output) => {
                  const base64Output = base64(output);
                  expect(base64Output).to.equal(diagramsBase64Output);
                  done();
          sashimi-webapp/test/unit/specs/logic/documentPackager.spec.js on lines 77..86
          sashimi-webapp/test/unit/specs/logic/documentPackager.spec.js on lines 99..108
          sashimi-webapp/test/unit/specs/logic/documentPackager.spec.js on lines 110..119

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

          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 4 locations. Consider refactoring.
          Open

              it('should handle mathematical formula typed in LaTeX', (done) => {
                documentPackager.getHtmlData(katexInput).then((output) => {
                  const base64Output = base64(output);
                  expect(base64Output).to.equal(katexOutput);
                  done();
          sashimi-webapp/test/unit/specs/logic/documentPackager.spec.js on lines 99..108
          sashimi-webapp/test/unit/specs/logic/documentPackager.spec.js on lines 110..119
          sashimi-webapp/test/unit/specs/logic/documentPackager.spec.js on lines 141..150

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

          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 4 locations. Consider refactoring.
          Open

              it('should handle code syntax highlighting', (done) => {
                documentPackager.getHtmlData(highlightjsInput).then((output) => {
                  const base64Output = base64(output);
                  expect(base64Output).to.equal(highlightjsOutput);
                  done();
          sashimi-webapp/test/unit/specs/logic/documentPackager.spec.js on lines 77..86
          sashimi-webapp/test/unit/specs/logic/documentPackager.spec.js on lines 99..108
          sashimi-webapp/test/unit/specs/logic/documentPackager.spec.js on lines 141..150

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

          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 4 locations. Consider refactoring.
          Open

              it('should handle block ASCIIMath syntax', (done) => {
                documentPackager.getHtmlData(asciiMathBlockInput).then((output) => {
                  const base64Output = base64(output);
                  expect(base64Output).to.equal(asciiMathBlockOutput);
                  done();
          sashimi-webapp/test/unit/specs/logic/documentPackager.spec.js on lines 77..86
          sashimi-webapp/test/unit/specs/logic/documentPackager.spec.js on lines 110..119
          sashimi-webapp/test/unit/specs/logic/documentPackager.spec.js on lines 141..150

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

          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 diagramsRenderer.spec.js has 292 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import domCompare from 'dom-compare';
          import DiagramsRenderer from 'src/logic/renderer/diagrams';
          import documentPackager from 'src/logic/documentPackager';
          import diagramsInput from './reference/diagrams/diagramsInput.txt';
          import diagramsRenderedOutput from './reference/diagrams/diagramsRenderedOutput.txt';
          Severity: Minor
          Found in sashimi-webapp/test/unit/specs/logic/diagramsRenderer.spec.js - About 3 hrs to fix

            Function default has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

            export default function(navInstance) {
              // Event handlers
              this.eventFn = {
                gesture: {
                  dragstart(event) {

            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 changeSingleFolderPath(folderId, newPath) {
              return new Promise((resolve, reject) =>
                alasql.promise([stringManipulator.stringConcat('UPDATE ', constants.ENTITIES_FOLDER,
                                                               ' SET ', constants.HEADER_FOLDER_PATH,
                                                               ' = "', newPath,
            Severity: Major
            Found in sashimi-webapp/src/database/sql-related/sqlCommands.js and 1 other location - About 2 hrs to fix
            sashimi-webapp/src/database/sql-related/sqlCommands.js on lines 100..110

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

            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 changeSingleFolderName(folderId, newFolderName) {
              return new Promise((resolve, reject) =>
                alasql.promise([stringManipulator.stringConcat('UPDATE ', constants.ENTITIES_FOLDER,
                                                               ' SET ', constants.HEADER_FOLDER_FOLDER_NAME,
                                                               ' = "', newFolderName,
            Severity: Major
            Found in sashimi-webapp/src/database/sql-related/sqlCommands.js and 1 other location - About 2 hrs to fix
            sashimi-webapp/src/database/sql-related/sqlCommands.js on lines 88..98

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

            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 3 locations. Consider refactoring.
            Open

                it('should handle conditional hiding data', (done) => {
                  documentPackager.getHtmlData(conditionalInput).then((output) => {
                    expect(output).to.equal(newlineFilter(conditionalOutput));
                    done();
                  })
            sashimi-webapp/test/unit/specs/logic/documentPackager.spec.js on lines 121..129
            sashimi-webapp/test/unit/specs/logic/documentPackager.spec.js on lines 131..139

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

            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 getCurrentFolderPath(folderId) {
              return new Promise((resolve, reject) =>
                alasql.promise([stringManipulator.stringConcat('SELECT ', constants.HEADER_FOLDER_PATH,
                                                               ' FROM ', constants.ENTITIES_FOLDER,
                                                               ' WHERE ', constants.HEADER_FOLDER_FOLDER_ID,
            Severity: Major
            Found in sashimi-webapp/src/database/sql-related/sqlCommands.js and 1 other location - About 2 hrs to fix
            sashimi-webapp/src/database/sql-related/sqlCommands.js on lines 28..37

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

            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