orlowdev/gatsby-source-notion-api

View on GitHub

Showing 17 of 23 total issues

Function notionBlockToMarkdown has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
Open

exports.notionBlockToMarkdown = (block, lowerTitleLevel, depth = 0) =>
    block.children.reduce((acc, childBlock) => {
        let childBlocksString = ""

        if (childBlock.has_children) {
Severity: Minor
Found in src/transformers/notion-block-to-markdown.js - About 7 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 notionBlockToMarkdown has 119 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    block.children.reduce((acc, childBlock) => {
        let childBlocksString = ""

        if (childBlock.has_children) {
            childBlocksString = "  "
Severity: Major
Found in src/transformers/notion-block-to-markdown.js - About 4 hrs to fix

    Function blockToString has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.blockToString = (textBlocks) =>
        textBlocks.reduce((text, textBlock) => {
            const data = {
                ...textBlock.text,
                ...textBlock.annotations,
    Severity: Minor
    Found in src/block-to-string.js - About 2 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 getBlocks has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.getBlocks = async ({ id, notionVersion, token }, reporter) => {
        let hasMore = true
        let blockContent = []
        let startCursor = ""
    
    
    Severity: Minor
    Found in src/notion-api/get-blocks.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 getPages has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.getPages = async ({ token, databaseId, notionVersion = "2021-05-13" }, reporter) => {
        let hasMore = true
        let startCursor = ""
        const url = `https://api.notion.com/v1/databases/${databaseId}/query`
        const body = {
    Severity: Minor
    Found in src/notion-api/get-pages.js - About 35 mins 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

    Avoid too many return statements within this function.
    Open

                return acc
                    .concat(`<!-- This block is not supported by Notion API yet. -->`)
                    .concat(EOL_MD)
                    .concat(childBlocksString)
    Severity: Major
    Found in src/transformers/notion-block-to-markdown.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return acc
                      .concat(EOL_MD)
                      .concat("```", childBlock.code.language, EOL_MD)
                      .concat(blockToString(childBlock.code.text))
                      .concat(EOL_MD)
      Severity: Major
      Found in src/transformers/notion-block-to-markdown.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return acc.concat(videoUrl).concat(EOL_MD)
        Severity: Major
        Found in src/transformers/notion-block-to-markdown.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return acc.concat(childBlock.embed.url).concat(EOL_MD)
          Severity: Major
          Found in src/transformers/notion-block-to-markdown.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return acc
                            .concat("1. ")
                            .concat(blockToString(childBlock.numbered_list_item.text))
                            .concat(EOL_MD)
                            .concat(childBlocksString)
            Severity: Major
            Found in src/transformers/notion-block-to-markdown.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return acc
                              .concat("<details><summary>")
                              .concat(blockToString(childBlock.toggle.text))
                              .concat("</summary>")
                              .concat(childBlocksString)
              Severity: Major
              Found in src/transformers/notion-block-to-markdown.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return acc
                                .concat("![")
                                .concat(blockToString(childBlock.image.caption))
                                .concat("](")
                                .concat(imageUrl)
                Severity: Major
                Found in src/transformers/notion-block-to-markdown.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return acc
                                  .concat("<audio controls>")
                                  .concat(EOL_MD)
                                  .concat(`<source src="${audioUrl}" />`)
                                  .concat(EOL_MD)
                  Severity: Major
                  Found in src/transformers/notion-block-to-markdown.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return acc.concat("---").concat(EOL_MD)
                    Severity: Major
                    Found in src/transformers/notion-block-to-markdown.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return acc
                                      .concat("[")
                                      .concat(bookmarkCaption)
                                      .concat("](")
                                      .concat(bookmarkUrl)
                      Severity: Major
                      Found in src/transformers/notion-block-to-markdown.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return acc.concat("> ").concat(blockToString(childBlock.quote.text)).concat(EOL_MD)
                        Severity: Major
                        Found in src/transformers/notion-block-to-markdown.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return acc
                          Severity: Major
                          Found in src/transformers/notion-block-to-markdown.js - About 30 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language