Kentico/gatsby-source-kontent

View on GitHub

Showing 69 of 69 total issues

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

      <article>
        <header>
          <h2>Repositories</h2>
        </header>
        <ul>
Severity: Major
Found in examples/resolution/src/pages/index.js and 1 other location - About 6 hrs to fix
examples/resolution/src/pages/index.js on lines 25..36

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

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

      <article>
        <header>
          <h2>Websites</h2>
        </header>
        <ul>
Severity: Major
Found in examples/resolution/src/pages/index.js and 1 other location - About 6 hrs to fix
examples/resolution/src/pages/index.js on lines 38..49

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

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

    <div style={{
      border: 'silver 1px dashed',
      display: 'inline-block',
      padding: '1em',
      maxWidth: '400px'
Severity: Major
Found in examples/resolution/src/components/repository.js and 1 other location - About 5 hrs to fix
examples/resolution/src/components/website.js on lines 7..27

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

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

    <div style={{
      border: 'silver 1px solid',
      display: 'inline-block',
      padding: '1em'
    }}>
Severity: Major
Found in examples/resolution/src/components/website.js and 1 other location - About 5 hrs to fix
examples/resolution/src/components/repository.js on lines 7..28

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

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

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

const loadAllKontentTypes = async (
  config: CustomPluginOptions,
): Promise<KontentType[]> => {
  const headers = ensureAuthorizationHeader(config);
  ensureTrackingHeader(headers);
Severity: Major
Found in packages/gatsby-source-kontent/src/client.ts and 1 other location - About 4 hrs to fix
packages/gatsby-source-kontent/src/client.ts on lines 193..208

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

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 loadAllKontentTaxonomies = async (
  config: CustomPluginOptions,
): Promise<KontentTaxonomy[]> => {
  const headers = ensureAuthorizationHeader(config);
  ensureTrackingHeader(headers);
Severity: Major
Found in packages/gatsby-source-kontent/src/client.ts and 1 other location - About 4 hrs to fix
packages/gatsby-source-kontent/src/client.ts on lines 163..178

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

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

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

      people.forEach(person => {
        createPage({
          path: resolveUrl(person.__typename, person.elements.slug.value),
          component: require.resolve(`./src/templates/person.js`),
          context: {
    Severity: Major
    Found in examples/resolution/gatsby-node.js and 2 other locations - About 3 hrs to fix
    examples/resolution/gatsby-node.js on lines 76..85
    examples/resolution/gatsby-node.js on lines 87..96

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

    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

      repositories.forEach(repository => {
        createPage({
          path: resolveUrl(repository.__typename, repository.elements.slug.value),
          component: require.resolve(`./src/templates/repository.js`),
          context: {
    Severity: Major
    Found in examples/resolution/gatsby-node.js and 2 other locations - About 3 hrs to fix
    examples/resolution/gatsby-node.js on lines 65..74
    examples/resolution/gatsby-node.js on lines 87..96

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

    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

      websites.forEach(website => {
        createPage({
          path: resolveUrl(website.__typename, website.elements.slug.value),
          component: require.resolve(`./src/templates/website.js`),
          context: {
    Severity: Major
    Found in examples/resolution/gatsby-node.js and 2 other locations - About 3 hrs to fix
    examples/resolution/gatsby-node.js on lines 65..74
    examples/resolution/gatsby-node.js on lines 76..85

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

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

    const handleIncomingWebhook = async (
      api: SourceNodesArgs,
      pluginConfig: CustomPluginOptions,
      itemTypes: string[],
    ): Promise<void> => {
    Severity: Minor
    Found in packages/gatsby-source-kontent/src/webhookProcessor.ts - About 3 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

          <section>
            <p>{website.elements.summary.value}</p>
            <a
              href={website.elements.url.value}
              style={{
    Severity: Major
    Found in examples/resolution/src/templates/website.js and 1 other location - About 2 hrs to fix
    examples/resolution/src/templates/repository.js on lines 12..23

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

    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

          <section>
            <p>{repo.elements.summary.value}</p>
            <a
              href={repo.elements.url.value}
              style={{
    Severity: Major
    Found in examples/resolution/src/templates/repository.js and 1 other location - About 2 hrs to fix
    examples/resolution/src/templates/website.js on lines 13..26

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

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

    const ComplexMenu = () => {
      const data = useStaticQuery(graphql`
        {
          kontentItemNavigationItem(
            system: { codename: { eq: "website_root_navigation" } }
    Severity: Major
    Found in examples/navigation/src/components/complex-menu.js - About 2 hrs to fix

      Function linkLanguageVariants has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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

        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 nodeData = createNodeFromRawKontentItem(api, modularKontentItem, pluginConfig.includeRawContent, lang);
                createdItemsIds.push(nodeData.id);
        Severity: Major
        Found in packages/gatsby-source-kontent/src/webhookProcessor.ts and 1 other location - About 2 hrs to fix
        packages/gatsby-source-kontent/src/webhookProcessor.ts on lines 146..152

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

        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 nodeData = createNodeFromRawKontentItem(api, modularKontentItem, pluginConfig.includeRawContent, lang);
                  touchedItemsIds.push(nodeData.id);
        Severity: Major
        Found in packages/gatsby-source-kontent/src/webhookProcessor.ts and 1 other location - About 2 hrs to fix
        packages/gatsby-source-kontent/src/webhookProcessor.ts on lines 81..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 81.

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

        const handleIncomingWebhook = async (
          api: SourceNodesArgs,
          pluginConfig: CustomPluginOptions,
          itemTypes: string[],
        ): Promise<void> => {
        Severity: Major
        Found in packages/gatsby-source-kontent/src/webhookProcessor.ts - About 2 hrs to fix
          Severity
          Category
          Status
          Source
          Language