nus-mtp/sashimi-note

View on GitHub

Showing 330 of 330 total issues

Function stringManipulation has a Cognitive Complexity of 10 (exceeds 5 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

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

  getFolder: function getFolder(id) {
    let folderID = INVALID_ID;

    if (typeof id === 'string') {
      if (id.match(NUMBER_ONLY) == null) {
Severity: Minor
Found in sashimi-webapp/src/logic/filemanager/operations/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 AMstrarr2docFrag has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function AMstrarr2docFrag(arr, linebreaks) {
  const newFrag=document.createDocumentFragment();
  let expr = false;
  for (let i=0; i<arr.length; i+=1) {
    if (expr) newFrag.appendChild(AMparseMath(arr[i]));

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

const addElementToPage = function addElementToPage(page, book, eleArray, index) {
  const element = eleArray[index];
  try {
    if (shouldPageBreak(eleArray, index, page)) {
      // Create a new page if page should be broken here
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 print has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  print(markdownData) {
    const printFrame = window.open(frame.url, frame.target, frame.feature);
    documentBuilder.rebuild(printFrame);
    documentBuilder.addStyles(printFrame, [
      '/styles/markdown-pages.css',
Severity: Minor
Found in sashimi-webapp/src/logic/inputHandler/DocumentPrinter/core.js - About 1 hr to fix

    Function hideShowInline has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function hideShowInline(state, silent) {
      const max = state.posMax;
      const start = state.pos;
      let found;
    
    

      Function getReferenceFrame has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      PageRenderer.prototype.getReferenceFrame = function getReferenceFrame() {
        const idOfReferenceFrame = defaultConfig.prefix.reference + this.renderDomId;
        let referenceFrame = this.ownerDocument.getElementById(idOfReferenceFrame);
      
        // Create a new reference frame if doesn't exist
      Severity: Minor
      Found in sashimi-webapp/src/logic/renderer/index.js - About 1 hr to fix

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

                alasql.promise([stringManipulator.stringConcat('UPDATE ', constants.ENTITIES_FILE_MANAGER,
                                                              ' SET ', constants.HEADER_FILE_MANAGER_PATH,
                                                              ' = "', newPath,
                                                              '" WHERE ', constants.HEADER_FILE_MANAGER_FILE_ID,
                                                              ' = ', fileId)])
        Severity: Major
        Found in sashimi-webapp/src/database/sql-related/sqlCommands.js and 2 other locations - About 1 hr to fix
        sashimi-webapp/src/database/sql-related/sqlCommands.js on lines 505..510
        sashimi-webapp/src/database/sql-related/sqlCommands.js on lines 513..518

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

        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

                return alasql.promise([stringManipulator.stringConcat('UPDATE ', constants.ENTITIES_FILE_MANAGER,
                                                                      ' SET ', constants.HEADER_FILE_MANAGER_LAST_MODIFIED_DATE,
                                                                      ' = "', currentDateTime,
                                                                      '" WHERE ', constants.HEADER_FILE_MANAGER_FILE_ID,
                                                                      ' = ', fileId)])
        Severity: Major
        Found in sashimi-webapp/src/database/sql-related/sqlCommands.js and 2 other locations - About 1 hr to fix
        sashimi-webapp/src/database/sql-related/sqlCommands.js on lines 427..432
        sashimi-webapp/src/database/sql-related/sqlCommands.js on lines 505..510

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

        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

              return alasql.promise([stringManipulator.stringConcat('UPDATE ', constants.ENTITIES_FILE_MANAGER,
                                                                    ' SET ', constants.HEADER_FILE_MANAGER_FILE_MARKDOWN,
                                                                    ' = "', markdownFile,
                                                                    '" WHERE ', constants.HEADER_FILE_MANAGER_FILE_ID,
                                                                    ' = ', fileId)])
        Severity: Major
        Found in sashimi-webapp/src/database/sql-related/sqlCommands.js and 2 other locations - About 1 hr to fix
        sashimi-webapp/src/database/sql-related/sqlCommands.js on lines 427..432
        sashimi-webapp/src/database/sql-related/sqlCommands.js on lines 513..518

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

        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(organizationData).to.deep.equal([{
                    name: 'temporary',
                    creation_date: creationDate,
                    organization_index: 1,
                    organization_id: 1,
        sashimi-webapp/test/unit/specs/database/create/initDataGenerator.spec.js on lines 26..33

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

        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([{
                name: 'temporary',
                creation_date: creationDate,
                organization_index: 1,
                organization_id: 1,
        sashimi-webapp/test/unit/specs/database/create/entitiesCreator.spec.js on lines 189..196

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

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

        function toggleEditorViewerView(browser, component) {
          const devServer = browser.globals.devServerURL;
        
          browser.url(`${devServer}/content`);
          browser.expect.element('#app').to.be.visible.before(5000);

          Function createNewFile has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function createNewFile(organizationId, filePath, folderId, newFileId, newFileName) {
            return new Promise((resolve, reject) => {
              const currentDateTime = dateTime.getCurrentLongTime();
          
              const fileOrganizationId = organizationId;
          Severity: Minor
          Found in sashimi-webapp/src/database/data-modifier/dataAdd.js - About 1 hr to fix

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

              const thirdFile = [{
                organization_id: 1,
                folder_id: 0,
                file_id: 3,
                file_name: 'copy of abcd',
            sashimi-webapp/test/unit/specs/database/data-modifier/dataAdd.spec.js on lines 27..37
            sashimi-webapp/test/unit/specs/database/retrieve/query.spec.js on lines 27..37
            sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 151..161
            sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 162..172
            sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 173..183
            sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 184..194
            sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 195..205
            sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 206..216
            sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 217..227

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

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

                const firstFile = [{
                  organization_id: 1,
                  folder_id: 0,
                  file_id: 1,
                  file_name: 'abcd',
            sashimi-webapp/test/unit/specs/database/data-modifier/dataAdd.spec.js on lines 27..37
            sashimi-webapp/test/unit/specs/database/data-modifier/dataAdd.spec.js on lines 49..59
            sashimi-webapp/test/unit/specs/database/retrieve/query.spec.js on lines 27..37
            sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 162..172
            sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 173..183
            sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 184..194
            sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 195..205
            sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 206..216
            sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 217..227

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

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

                const thirdFile = [{
                  organization_id: 1,
                  folder_id: 0,
                  file_id: 3,
                  file_name: 'd',
            sashimi-webapp/test/unit/specs/database/data-modifier/dataAdd.spec.js on lines 27..37
            sashimi-webapp/test/unit/specs/database/data-modifier/dataAdd.spec.js on lines 49..59
            sashimi-webapp/test/unit/specs/database/retrieve/query.spec.js on lines 27..37
            sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 151..161
            sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 162..172
            sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 184..194
            sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 195..205
            sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 206..216
            sashimi-webapp/test/unit/specs/database/sql-related/sqlCommands.spec.js on lines 217..227

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

            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

              const secondFile = [{
                organization_id: 1,
                folder_id: 0,
                file_id: 2,
                file_name: 'newFile',
            sashimi-webapp/test/unit/specs/database/retrieve/query.spec.js on lines 38..48

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

            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 (state.src.charCodeAt(pos) === 61  /* = */&&
                  state.src.charCodeAt(pos + 1) === 61  /* = */&&
                  state.src.charCodeAt(pos + 2) === 62 /* > */ &&
                  state.src.charCodeAt(pos + 3) === 104 /* h */ &&
                  state.src.charCodeAt(pos + 4) === 105 /* i */ &&

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

                const secondFile = [{
                  organization_id: 1,
                  folder_id: 0,
                  file_id: 2,
                  file_name: 'newFile',
              sashimi-webapp/test/unit/specs/database/data-modifier/dataAdd.spec.js on lines 38..48

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

              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