Kentico/gatsby-source-kontent

View on GitHub

Showing 80 of 80 total issues

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

const getKontentTaxonomyNodeStringForCodeName = (
  codename: string,
  config: PluginNamingConfiguration = defaultPluginNamingConfiguration,
): string =>
  `${config.prefix}${CONNECTOR}${TAXONOMY_IDENTIFIER}${CONNECTOR}${codename}`;
Severity: Major
Found in packages/gatsby-source/src/naming.ts and 2 other locations - About 1 hr to fix
packages/gatsby-source/src/naming.ts on lines 38..42
packages/gatsby-source/src/naming.ts on lines 96..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 59.

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

    async resolve(
      source: { value?: string[]; modular_content?: string[]; type: string },
      _args: unknown,
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
      context: any,
Severity: Minor
Found in packages/gatsby-source/src/createSchemaCustomization.items.ts - About 1 hr to fix

    Function linkUsedByContentItems has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const linkUsedByContentItems = (
      api,
      parentTypeCodename,
      childTypeCodename,
      linkedElementCodename,
    Severity: Minor
    Found in examples/relationships/example-used-by-content-item-link.js - About 1 hr to fix

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

        if (pluginConfig.includeTaxonomies) {
          const taxonomies = api.getNodesByType(getKontentTaxonomyTypeName());
          for (const taxonomy of taxonomies) {
            api.actions.touchNode(taxonomy);
          }
      Severity: Major
      Found in packages/gatsby-source/src/webhookProcessor.ts and 1 other location - About 1 hr to fix
      packages/gatsby-source/src/webhookProcessor.ts on lines 294..299

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

      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 (pluginConfig.includeTypes) {
          const types = api.getNodesByType(getKontentTypeTypeName());
          for (const type of types) {
            api.actions.touchNode(type);
          }
      Severity: Major
      Found in packages/gatsby-source/src/webhookProcessor.ts and 1 other location - About 1 hr to fix
      packages/gatsby-source/src/webhookProcessor.ts on lines 287..292

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

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

      const replaceNode = (
        domNode: Element,
        linkedItems: any[] | undefined,
        resolveLinkedItem: Function | undefined,
        images: any[] | undefined,
      Severity: Minor
      Found in packages/gatsby-components/src/rich-text-element/index.tsx - 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 replaceNode has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const replaceNode = (
        domNode: Element,
        linkedItems: any[] | undefined,
        resolveLinkedItem: Function | undefined,
        images: any[] | undefined,
      Severity: Minor
      Found in packages/gatsby-components/src/rich-text-element/index.tsx - About 1 hr to fix

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

        const loadAllKontentItems = async (
          config: CustomPluginOptions,
          language: string,
        ): Promise<KontentItemInput[]> => {
          let continuationToken = '';
        Severity: Minor
        Found in packages/gatsby-source/src/client.ts - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

            else if ((api.webhookBody as IWebhookWorkflowResponse)?.message?.api_name === "content_management") {
              const parsedBody = api.webhookBody as IWebhookWorkflowResponse;
          
              const isCorrectStructure = parsedBody?.data?.items?.every(item => item.language && item.transition_from && item.transition_to && item.item.id)
                && parsedBody?.message?.api_name
          Severity: Major
          Found in packages/gatsby-source/src/webhookProcessor.ts - About 1 hr to fix

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

            const getKontentTypesCacheKey = (
              config: PluginNamingConfiguration = defaultPluginNamingConfiguration,
            ): string =>
              `${config.prefix}${CONNECTOR}${TYPE_IDENTIFIER}${CONNECTOR}${CACHE_IDENTIFIER}`;
            Severity: Major
            Found in packages/gatsby-source/src/naming.ts and 6 other locations - About 55 mins to fix
            packages/gatsby-source/src/naming.ts on lines 48..51
            packages/gatsby-source/src/naming.ts on lines 71..74
            packages/gatsby-source/src/naming.ts on lines 86..89
            packages/gatsby-source/src/naming.ts on lines 91..94
            packages/gatsby-source/src/naming.ts on lines 106..109
            packages/gatsby-source/src/naming.ts on lines 111..114

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

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

            const getKontentTaxonomySystemElementTypeName = (
              config: PluginNamingConfiguration = defaultPluginNamingConfiguration,
            ): string =>
              `${config.prefix}${CONNECTOR}${TAXONOMY_IDENTIFIER}${CONNECTOR}${SYSTEM_IDENTIFIER}`;
            Severity: Major
            Found in packages/gatsby-source/src/naming.ts and 6 other locations - About 55 mins to fix
            packages/gatsby-source/src/naming.ts on lines 48..51
            packages/gatsby-source/src/naming.ts on lines 71..74
            packages/gatsby-source/src/naming.ts on lines 91..94
            packages/gatsby-source/src/naming.ts on lines 106..109
            packages/gatsby-source/src/naming.ts on lines 111..114
            packages/gatsby-source/src/naming.ts on lines 123..126

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

            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 createSchemaCustomization = async (
              api: CreateSchemaCustomizationArgs,
            ): Promise<void> => {
              const schema = getKontentTaxonomiesSchemaNamingConfiguration();
              api.actions.createTypes(schema);
            packages/gatsby-source/src/createSchemaCustomization.types.ts on lines 4..9

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

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

            const getKontentItemSystemElementTypeName = (
              config: PluginNamingConfiguration = defaultPluginNamingConfiguration,
            ): string =>
              `${config.prefix}${CONNECTOR}${ITEM_IDENTIFIER}${CONNECTOR}${SYSTEM_IDENTIFIER}`;
            Severity: Major
            Found in packages/gatsby-source/src/naming.ts and 6 other locations - About 55 mins to fix
            packages/gatsby-source/src/naming.ts on lines 71..74
            packages/gatsby-source/src/naming.ts on lines 86..89
            packages/gatsby-source/src/naming.ts on lines 91..94
            packages/gatsby-source/src/naming.ts on lines 106..109
            packages/gatsby-source/src/naming.ts on lines 111..114
            packages/gatsby-source/src/naming.ts on lines 123..126

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

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

            const getKontentTypeSystemElementTypeName = (
              config: PluginNamingConfiguration = defaultPluginNamingConfiguration,
            ): string =>
              `${config.prefix}${CONNECTOR}${TYPE_IDENTIFIER}${CONNECTOR}${SYSTEM_IDENTIFIER}`;
            Severity: Major
            Found in packages/gatsby-source/src/naming.ts and 6 other locations - About 55 mins to fix
            packages/gatsby-source/src/naming.ts on lines 48..51
            packages/gatsby-source/src/naming.ts on lines 71..74
            packages/gatsby-source/src/naming.ts on lines 86..89
            packages/gatsby-source/src/naming.ts on lines 91..94
            packages/gatsby-source/src/naming.ts on lines 111..114
            packages/gatsby-source/src/naming.ts on lines 123..126

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

            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 createSchemaCustomization = async (
              api: CreateSchemaCustomizationArgs,
            ): Promise<void> => {
              const schema = getKontentTypesSchemaNamingConfiguration();
              api.actions.createTypes(schema);
            Severity: Minor
            Found in packages/gatsby-source/src/createSchemaCustomization.types.ts and 1 other location - About 55 mins to fix
            packages/gatsby-source/src/createSchemaCustomization.taxonomies.ts on lines 4..9

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

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

            const getKontentItemLanguageLinkExtensionName = (
              config: PluginNamingConfiguration = defaultPluginNamingConfiguration,
            ): string =>
              `${config.prefix}${CONNECTOR}${ITEM_IDENTIFIER}${CONNECTOR}${LANGUAGE_LINK_EXTENSION_IDENTIFIER}`;
            Severity: Major
            Found in packages/gatsby-source/src/naming.ts and 6 other locations - About 55 mins to fix
            packages/gatsby-source/src/naming.ts on lines 48..51
            packages/gatsby-source/src/naming.ts on lines 86..89
            packages/gatsby-source/src/naming.ts on lines 91..94
            packages/gatsby-source/src/naming.ts on lines 106..109
            packages/gatsby-source/src/naming.ts on lines 111..114
            packages/gatsby-source/src/naming.ts on lines 123..126

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

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

            const getKontentTypeElementTypeName = (
              config: PluginNamingConfiguration = defaultPluginNamingConfiguration,
            ): string =>
              `${config.prefix}${CONNECTOR}${TYPE_IDENTIFIER}${CONNECTOR}${ELEMENT_IDENTIFIER}`;
            Severity: Major
            Found in packages/gatsby-source/src/naming.ts and 6 other locations - About 55 mins to fix
            packages/gatsby-source/src/naming.ts on lines 48..51
            packages/gatsby-source/src/naming.ts on lines 71..74
            packages/gatsby-source/src/naming.ts on lines 86..89
            packages/gatsby-source/src/naming.ts on lines 91..94
            packages/gatsby-source/src/naming.ts on lines 106..109
            packages/gatsby-source/src/naming.ts on lines 123..126

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

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

            const getKontentTaxonomyTermTypeName = (
              config: PluginNamingConfiguration = defaultPluginNamingConfiguration,
            ): string =>
              `${config.prefix}${CONNECTOR}${TAXONOMY_IDENTIFIER}${CONNECTOR}${TAXONOMY_TERM_IDENTIFIER}`;
            Severity: Major
            Found in packages/gatsby-source/src/naming.ts and 6 other locations - About 55 mins to fix
            packages/gatsby-source/src/naming.ts on lines 48..51
            packages/gatsby-source/src/naming.ts on lines 71..74
            packages/gatsby-source/src/naming.ts on lines 86..89
            packages/gatsby-source/src/naming.ts on lines 106..109
            packages/gatsby-source/src/naming.ts on lines 111..114
            packages/gatsby-source/src/naming.ts on lines 123..126

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

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

            const handleUpsertItem = async (
              api: SourceNodesArgs,
              pluginConfig: CustomPluginOptions,
              itemId: string,
              itemLanguage?: string,
            Severity: Minor
            Found in packages/gatsby-source/src/webhookProcessor.ts - About 55 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

            Function parseKontentWebhookBody has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            const parseKontentWebhookBody = (api: SourceNodesArgs): IWebhookDeliveryResponse | IWebhookWorkflowResponse | null => {
            
              if ((api.webhookBody as IWebhookDeliveryResponse)?.message?.api_name === "delivery_preview" || (api.webhookBody as IWebhookDeliveryResponse)?.message?.api_name === "delivery_production") {
                const parsedBody = api.webhookBody as IWebhookDeliveryResponse;
            
            Severity: Minor
            Found in packages/gatsby-source/src/webhookProcessor.ts - About 55 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

            Severity
            Category
            Status
            Source
            Language