Kentico/gatsby-source-kontent

View on GitHub

Showing 40 of 40 total issues

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

const getKontentTypeArtifact = (
  api: SourceNodesArgs,
  kontentType: KontentType,
  includeRawContent: boolean,
): KontentType => {
Severity: Major
Found in packages/gatsby-source-kontent/src/sourceNodes.types.ts and 1 other location - About 5 hrs to fix
packages/gatsby-source-kontent/src/sourceNodes.taxonomies.ts on lines 9..30

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

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 getKontentTypeArtifact = (
  api: SourceNodesArgs,
  kontentTaxonomy: KontentTaxonomy,
  includeRawContent: boolean,
): KontentTaxonomy => {
Severity: Major
Found in packages/gatsby-source-kontent/src/sourceNodes.taxonomies.ts and 1 other location - About 5 hrs to fix
packages/gatsby-source-kontent/src/sourceNodes.types.ts on lines 14..35

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

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

const getKontentItemsSchemaNamingConfiguration = (
  config: PluginNamingConfiguration = defaultPluginNamingConfiguration,
): string => {
  const template = fs.readFileSync(
    path.join(__dirname, 'template.items.schema.gql'),
Severity: Major
Found in packages/gatsby-source-kontent/src/naming.ts - About 3 hrs to fix

    Function addLanguageLinks has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const addLanguageLinks = (api, typeCodename) => {
      const {
        actions: { createTypes },
        schema,
      } = api
    Severity: Major
    Found in site/example-languages-link.js - About 2 hrs to fix

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

      const getKontentItemElementsSchemaTypeName = (
        type: string,
        config: PluginNamingConfiguration = defaultPluginNamingConfiguration,
      ): string =>
        `${config.prefix}${CONNECTOR}${ITEM_IDENTIFIER}${CONNECTOR}${type}${CONNECTOR}${MULTI_ELEMENT_IDENTIFIER}`;
      Severity: Major
      Found in packages/gatsby-source-kontent/src/naming.ts and 1 other location - About 1 hr to fix
      packages/gatsby-source-kontent/src/naming.ts on lines 58..62

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

      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 getKontentItemElementValueTypeNameByType = (
        type: string,
        config: PluginNamingConfiguration = defaultPluginNamingConfiguration,
      ): string =>
        `${config.prefix}${CONNECTOR}${ITEM_IDENTIFIER}${CONNECTOR}${type}${CONNECTOR}${ELEMENT_IDENTIFIER}`;
      Severity: Major
      Found in packages/gatsby-source-kontent/src/naming.ts and 1 other location - About 1 hr to fix
      packages/gatsby-source-kontent/src/naming.ts on lines 64..68

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

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

      const Articles = (props) => {
        const { data } = props;
        const articles = data.allKontentItemArticle.group.map(articleItem => {
          const variants = articleItem
            .nodes
      Severity: Minor
      Found in site/src/pages/articles.js - About 1 hr to fix

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

          try {
            await kontentItemsCreateSchemaCustomization(api, pluginConfig);
            if (pluginConfig.includeTaxonomies) {
              await kontentTaxonomiesCreateSchemaCustomization(api);
            }
        Severity: Major
        Found in packages/gatsby-source-kontent/gatsby-node.ts and 1 other location - About 1 hr to fix
        packages/gatsby-source-kontent/gatsby-node.ts on lines 45..67

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

        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

          try {
            if(!_.isEmpty(api.webhookBody)){ //preview run
              await handleIncomingWebhook(api, pluginConfig, itemTypes);
              return;
            }
        Severity: Major
        Found in packages/gatsby-source-kontent/gatsby-node.ts and 1 other location - About 1 hr to fix
        packages/gatsby-source-kontent/gatsby-node.ts on lines 23..38

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

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

                resolve: async (source, args, context, info) => {
                  const pluginInfo = await context.nodeModel.runQuery({
                    query: {
                      filter: {
                        name: {
        Severity: Minor
        Found in site/example-languages-link.js - About 1 hr to fix

          Function RichTextSample has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const RichTextSample = () => {
            // normally loaded in `props.data`
            const data = sampleDataFromQuery.data
            // Rich text data
            const richTextElement = data.kontentItemPerson.elements.bio
          Severity: Minor
          Found in site/src/pages/rich-text.js - About 1 hr to fix

            Function createSchemaCustomization has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const createSchemaCustomization = async (
              api: CustomCreateSchemaCustomizationArgs,
              pluginConfig: CustomPluginOptions,
            ): Promise<void> => {
              // TODO check https://github.com/gatsbyjs/gatsby/pull/14610/files/5c50c435ab49884b6d854cd07f20efd95d1e5f52#diff-29de3acf9ce1010435f2b2f0043dba8cR252

              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-kontent/src/naming.ts and 2 other locations - About 1 hr to fix
              packages/gatsby-source-kontent/src/naming.ts on lines 37..41
              packages/gatsby-source-kontent/src/naming.ts on lines 95..99

              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

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

              const getKontentItemNodeTypeName = (
                type: string,
                config: PluginNamingConfiguration = defaultPluginNamingConfiguration,
              ): string =>
                `${config.prefix}${CONNECTOR}${ITEM_IDENTIFIER}${CONNECTOR}${type}`;
              Severity: Major
              Found in packages/gatsby-source-kontent/src/naming.ts and 2 other locations - About 1 hr to fix
              packages/gatsby-source-kontent/src/naming.ts on lines 75..79
              packages/gatsby-source-kontent/src/naming.ts on lines 95..99

              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

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

              const getKontentTypeNodeStringForCodeName = (
                codename: string,
                config: PluginNamingConfiguration = defaultPluginNamingConfiguration,
              ): string =>
                `${config.prefix}${CONNECTOR}${TYPE_IDENTIFIER}${CONNECTOR}${codename}`;
              Severity: Major
              Found in packages/gatsby-source-kontent/src/naming.ts and 2 other locations - About 1 hr to fix
              packages/gatsby-source-kontent/src/naming.ts on lines 37..41
              packages/gatsby-source-kontent/src/naming.ts on lines 75..79

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

                const articles = data.allKontentItemArticle.group.map(articleItem => {
                  const variants = articleItem
                    .nodes
                    .sort((a, b) => a.preferred_language < b.preferred_language ? 1 : -1)
                    .map(variant => {
              Severity: Minor
              Found in site/src/pages/articles.js - About 1 hr to fix

                Function addKontentTypeItemsLink has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const addKontentTypeItemsLink = async api => {
                  const {
                    actions: { createTypes },
                    schema,
                  } = api
                Severity: Minor
                Found in site/example-type-items-link.js - About 1 hr to fix

                  Function resolve has 29 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,

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

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

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

                      const createSchemaCustomization = async (
                        api: CustomCreateSchemaCustomizationArgs,
                      ): Promise<void> => {
                        const schema = getKontentTypesSchemaNamingConfiguration();
                        api.actions.createTypes(schema);
                      packages/gatsby-source-kontent/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

                      Severity
                      Category
                      Status
                      Source
                      Language