Kentico/gatsby-source-kontent

View on GitHub

Showing 80 of 80 total issues

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

      for (const key in modularKontent) {
        if (Object.prototype.hasOwnProperty.call(modularKontent, key)) {
          const modularKontentItem = modularKontent[key];
          const nodeId = createNodeFromRawKontentItem(api, modularKontentItem, pluginConfig.includeRawContent, lang);
          touchedItemsIds.push(nodeId);
Severity: Major
Found in packages/gatsby-source/src/webhookProcessor.ts and 1 other location - About 2 hrs to fix
packages/gatsby-source/src/webhookProcessor.ts on lines 103..109

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

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

    for (const key in modularKontent) {
      if (Object.prototype.hasOwnProperty.call(modularKontent, key)) {
        const modularKontentItem = modularKontent[key];
        const nodeId = createNodeFromRawKontentItem(api, modularKontentItem, pluginConfig.includeRawContent, lang);
        createdItemsIds.push(nodeId);
Severity: Major
Found in packages/gatsby-source/src/webhookProcessor.ts and 1 other location - About 2 hrs to fix
packages/gatsby-source/src/webhookProcessor.ts on lines 175..181

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

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

function Index() {
  return (
    <Layout>
      <h1>DSG listing</h1>
      <p>
Severity: Major
Found in examples/dsg-ssr/src/pages/dsg-listing/index.js and 1 other location - About 1 hr to fix
examples/dsg-ssr/src/pages/ssr-listing/index.js on lines 5..17

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

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

function Index() {
  return (
    <Layout>
      <h1>SSR listing</h1>
      <p>
Severity: Major
Found in examples/dsg-ssr/src/pages/ssr-listing/index.js and 1 other location - About 1 hr to fix
examples/dsg-ssr/src/pages/dsg-listing/index.js on lines 5..17

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

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

      <ul>
        <li><Link to="/articles">Language variant relationships</Link></li>
        <li><Link to="/tags">Used by relationship</Link></li>
      </ul>
Severity: Major
Found in examples/relationships/src/pages/index.js and 1 other location - About 1 hr to fix
site/src/pages/index.js on lines 10..13

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

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

      <ul>
        <li><Link to="author">Image resolution example</Link></li>
        <li><Link to="articles">Article listing example</Link></li>
      </ul>
Severity: Major
Found in site/src/pages/index.js and 1 other location - About 1 hr to fix
examples/relationships/src/pages/index.js on lines 12..15

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

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

exports.createSchemaCustomization = async api => {
  const {
    actions: { createTypes },
    schema,
  } = api
Severity: Minor
Found in examples/navigation/gatsby-node.js - About 1 hr to fix

    Function Articles has 41 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

      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/src/naming.ts and 1 other location - About 1 hr to fix
      packages/gatsby-source/src/naming.ts on lines 65..69

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

      const createSchemaCustomization = async (
        api: CreateSchemaCustomizationArgs,
        pluginConfig: CustomPluginOptions,
      ): Promise<void> => {
        // TODO check https://github.com/gatsbyjs/gatsby/pull/14610/files/5c50c435ab49884b6d854cd07f20efd95d1e5f52#diff-29de3acf9ce1010435f2b2f0043dba8cR252
      Severity: Minor
      Found in packages/gatsby-source/src/createSchemaCustomization.items.ts - About 1 hr 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/src/naming.ts and 1 other location - About 1 hr to fix
        packages/gatsby-source/src/naming.ts on lines 59..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 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

          try {
            if (!_.isEmpty(api.webhookBody)) { //preview run
              const itemTypes = (await api.cache.get('kontent-item-types')) || [];
              await handleIncomingWebhook(api, pluginConfig, itemTypes);
              return;
        Severity: Major
        Found in packages/gatsby-source/gatsby-node.ts and 1 other location - About 1 hr to fix
        packages/gatsby-source/gatsby-node.ts on lines 25..40

        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

          try {
            await kontentItemsCreateSchemaCustomization(api, pluginConfig);
            if (pluginConfig.includeTaxonomies) {
              await kontentTaxonomiesCreateSchemaCustomization(api);
            }
        Severity: Major
        Found in packages/gatsby-source/gatsby-node.ts and 1 other location - About 1 hr to fix
        packages/gatsby-source/gatsby-node.ts on lines 47..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 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 resolve has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                resolve: async (source, _args, context, _info) => {
                  const pluginInfo = await context.nodeModel.findOne({
                    query: {
                      filter: {
                        name: {
        Severity: Minor
        Found in examples/relationships/example-languages-variants.js - About 1 hr to fix

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

                      <p>
                        Showcase using{" "}
                        <a href="https://docs.kontent.ai/reference/image-transformation">
                          Kontent.ai Image transformation API
                        </a>{" "}
          Severity: Major
          Found in site/src/pages/author.js and 1 other location - About 1 hr to fix
          site/src/pages/author.js on lines 107..117

          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

                    <p>
                      Showcase using{" "}
                      <a href="https://docs.kontent.ai/reference/image-transformation">
                        Kontent.ai Image transformation API
                      </a>{" "}
          Severity: Major
          Found in site/src/pages/author.js and 1 other location - About 1 hr to fix
          site/src/pages/author.js on lines 130..140

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

          export async function getServerData(context) {
            try {
              const response = await fetch(`https://graphql.kontent.ai/${projectId}`, {
                method: "POST",
          

            Function articles has 31 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

              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/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 76..80

              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/src/naming.ts and 2 other locations - About 1 hr to fix
              packages/gatsby-source/src/naming.ts on lines 76..80
              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

              Severity
              Category
              Status
              Source
              Language