orlowdev/gatsby-source-notion-api

View on GitHub

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

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

            if (childBlock.type == "bulleted_list_item") {
                return acc
                    .concat("* ")
                    .concat(blockToString(childBlock.bulleted_list_item.text))
                    .concat(EOL_MD)
    Severity: Major
    Found in src/transformers/notion-block-to-markdown.js and 1 other location - About 1 hr to fix
    src/transformers/notion-block-to-markdown.js on lines 57..63

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

    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

            if (childBlock.type == "numbered_list_item") {
                return acc
                    .concat("1. ")
                    .concat(blockToString(childBlock.numbered_list_item.text))
                    .concat(EOL_MD)
    Severity: Major
    Found in src/transformers/notion-block-to-markdown.js and 1 other location - About 1 hr to fix
    src/transformers/notion-block-to-markdown.js on lines 49..55

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

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

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

                return acc
                    .concat("<details><summary>")
                    .concat(blockToString(childBlock.toggle.text))
                    .concat("</summary>")
                    .concat(childBlocksString)
    Severity: Minor
    Found in src/transformers/notion-block-to-markdown.js and 1 other location - About 55 mins to fix
    src/transformers/notion-block-to-markdown.js on lines 89..94

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

    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 acc
                    .concat("![")
                    .concat(blockToString(childBlock.image.caption))
                    .concat("](")
                    .concat(imageUrl)
    Severity: Minor
    Found in src/transformers/notion-block-to-markdown.js and 1 other location - About 55 mins to fix
    src/transformers/notion-block-to-markdown.js on lines 66..71

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

    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

                const audioUrl =
                    childBlock.audio.type == "external" ? childBlock.audio.external.url : childBlock.audio.file.url
    Severity: Minor
    Found in src/transformers/notion-block-to-markdown.js and 1 other location - About 40 mins to fix
    src/transformers/notion-block-to-markdown.js on lines 86..87

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

    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

                const imageUrl =
                    childBlock.image.type == "external" ? childBlock.image.external.url : childBlock.image.file.url
    Severity: Minor
    Found in src/transformers/notion-block-to-markdown.js and 1 other location - About 40 mins to fix
    src/transformers/notion-block-to-markdown.js on lines 99..100

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

    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 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
                      Severity
                      Category
                      Status
                      Source
                      Language