nus-mtp/sashimi-note

View on GitHub

Showing 330 of 330 total issues

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

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

        function hasClass(element, selector) {
          const className = ` ${selector} `;
          if ((` ${element.className} `).replace(/[\n\t\r]/g, ' ').indexOf(className) > -1) {
            return true;
          }
        sashimi-webapp/src/helpers/domUtils.js on lines 44..50

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

        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

          hasClass(element, selector) {
            const className = ` ${selector} `;
            if ((` ${element.className} `).replace(/[\n\t\r]/g, ' ').indexOf(className) > -1) {
              return true;
            }
        Severity: Major
        Found in sashimi-webapp/src/helpers/domUtils.js and 1 other location - About 1 hr to fix
        sashimi-webapp/src/logic/inputHandler/SlidesNavigator/index.js on lines 7..13

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

        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

                  return expect(fileManagerData).to.deep.equal([{
                    organization_id: 1,
                    folder_id: 0,
                    file_id: 1,
                    file_name: 'Features',
        sashimi-webapp/test/unit/specs/database/create/initDataGenerator.spec.js on lines 41..51

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

        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

              expect(userData).to.deep.equal([{
                organization_id: 1,
                folder_id: 0,
                file_id: 1,
                file_name: 'Features',
        sashimi-webapp/test/unit/specs/database/create/entitiesCreator.spec.js on lines 204..214

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

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

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

                  tableCreator.endCreateTable()
                  .then(() => {
                    isUsed = false;
                    done();
                  })
          sashimi-webapp/test/unit/specs/database/create/tableCreator.spec.js on lines 129..134
          sashimi-webapp/test/unit/specs/database/create/tableCreator.spec.js on lines 153..158
          sashimi-webapp/test/unit/specs/database/create/tableCreator.spec.js on lines 179..184

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

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

                    tableCreator.endCreateTable()
                    .then(() => {
                      isUsed = false;
                      done();
                    })
          sashimi-webapp/test/unit/specs/database/create/tableCreator.spec.js on lines 105..110
          sashimi-webapp/test/unit/specs/database/create/tableCreator.spec.js on lines 153..158
          sashimi-webapp/test/unit/specs/database/create/tableCreator.spec.js on lines 179..184

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

          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

                return alasql.promise([stringManipulator.stringConcat('SELECT * FROM ', constants.ENTITIES_FILE_MANAGER,
                                                                      ' WHERE ', constants.HEADER_FILE_MANAGER_FOLDER_ID,
                                                                      ' = ', folderId)])
                .then(data => resolve(getArray(data)))
                .catch(sqlError => reject(sqlError));
          Severity: Major
          Found in sashimi-webapp/src/database/sql-related/sqlCommands.js and 1 other location - About 1 hr to fix
          sashimi-webapp/src/database/sql-related/sqlCommands.js on lines 355..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 68.

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

                    tableCreator.endCreateTable()
                    .then(() => {
                      isUsed = false;
                      done();
                    })
          sashimi-webapp/test/unit/specs/database/create/tableCreator.spec.js on lines 105..110
          sashimi-webapp/test/unit/specs/database/create/tableCreator.spec.js on lines 129..134
          sashimi-webapp/test/unit/specs/database/create/tableCreator.spec.js on lines 179..184

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

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

                    tableCreator.endCreateTable()
                    .then(() => {
                      isUsed = false;
                      done();
                    })
          sashimi-webapp/test/unit/specs/database/create/tableCreator.spec.js on lines 105..110
          sashimi-webapp/test/unit/specs/database/create/tableCreator.spec.js on lines 129..134
          sashimi-webapp/test/unit/specs/database/create/tableCreator.spec.js on lines 153..158

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

          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

                alasql.promise([stringManipulator.stringConcat('SELECT * FROM ', constants.ENTITIES_FILE_MANAGER,
                                                               ' WHERE ', constants.HEADER_FILE_MANAGER_FILE_ID,
                                                               ' = ', fileId)])
                .then(data => resolve(getArray(data)))
                .catch(sqlError => reject(sqlError));
          Severity: Major
          Found in sashimi-webapp/src/database/sql-related/sqlCommands.js and 1 other location - About 1 hr to fix
          sashimi-webapp/src/database/sql-related/sqlCommands.js on lines 377..381

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

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

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

            function getChildFile(queue, parentID) {
              parentID = (parentID == null) ? NO_PARENT_ID: parentID;
              const index = queue.findIndex(dbFileObj => dbFileObj.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 66..70

            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

                      return expect(folderData).to.deep.equal([{
                        folder_id: 0,
                        parent_folder_id: -1,
                        permission_index: 1,
                        organization_id: 1,
            sashimi-webapp/test/unit/specs/database/create/initDataGenerator.spec.js on lines 58..67

            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

            Severity
            Category
            Status
            Source
            Language