Kentico/gatsby-source-kontent

View on GitHub

Showing 13 of 40 total issues

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

      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

        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

              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

                      Function Articles has a Cognitive Complexity of 6 (exceeds 5 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 25 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 getLanguageLinkExtension has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const getLanguageLinkExtension = (): object => ({
                        name: getKontentItemLanguageLinkExtensionName(),
                        extend: (): object => ({
                          async resolve(
                            source: { value?: string[]; modular_content?: string[]; type: string },
                      Severity: Minor
                      Found in packages/gatsby-source-kontent/src/createSchemaCustomization.items.ts - About 25 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 getElementFieldsDefinitionForType has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const getElementFieldsDefinitionForType = (
                        type: KontentType,
                      ): { [key: string]: { type: string } } => {
                        const elementFields: {
                          [key: string]: {
                      Severity: Minor
                      Found in packages/gatsby-source-kontent/src/createSchemaCustomization.items.ts - About 25 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