orlowdev/gatsby-source-notion-api

View on GitHub

Showing 20 of 22 total issues

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

exports.notionBlockToMarkdown = (block, lowerTitleLevel) => {
    // Get the child content of the block.
    let childMarkdown = (block.children ?? [])
        .map((block) => this.notionBlockToMarkdown(block, lowerTitleLevel))
        .join("")
Severity: Minor
Found in src/transformers/notion-block-to-markdown.js - About 4 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 102 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.notionBlockToMarkdown = (block, lowerTitleLevel) => {
    // Get the child content of the block.
    let childMarkdown = (block.children ?? [])
        .map((block) => this.notionBlockToMarkdown(block, lowerTitleLevel))
        .join("")
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, cache) => {
        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 `${EOL_MD}![${blockToString(block.image.caption)}](${imageUrl})${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 [EOL_MD, block.video.external.url, EOL_MD].join("")
      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 [EOL_MD, "<audio controls>", `<source src="${audioUrl}" />`, "</audio>", EOL_MD].join("")
        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 [EOL_MD, prependToLines(markdown, ">", false), EOL_MD].join("")
          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 prependToLines(markdown, "*").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 [
                          EOL_MD,
                          "<ColumnList>",
                          EOL_MD,
                          markdown,
              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 `${EOL_MD}---${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 [
                              "<Column>",
                              EOL_MD,
                              EOL_MD,
                              markdown,
                  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 [
                                EOL_MD,
                                "<details><summary>",
                                blockMarkdown,
                                "</summary>",
                    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 [EOL_MD, `<!-- This block type '${block.type}' is not supported yet. -->`, EOL_MD].join("")
                      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 prependToLines(markdown, "1.").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 prependToLines(markdown, symbol).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 [
                                        EOL_MD,
                                        `\`\`\` ${block.code.language}${EOL_MD}`,
                                        blockMarkdown,
                                        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 [EOL_MD, block.embed.url, EOL_MD].join("")
                              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 `${EOL_MD}[${bookmarkCaption}](${bookmarkUrl})${EOL_MD}`
                                Severity: Major
                                Found in src/transformers/notion-block-to-markdown.js - About 30 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language