storipress/karbon

View on GitHub

Showing 118 of 118 total issues

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

it('can handle real article', () => {
  const handlers = resolveSEOPresets([{ preset: 'basic' }])
  const results: unknown[] = []
  const resourceURL: ResourcePage<BaseMeta> = {
    enable: true,
packages/karbon/src/runtime/composables/__tests__/seo-preset.spec.ts on lines 299..343

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

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

it('can handle author page', () => {
  const handlers = resolveSEOPresets([{ preset: 'basic' }])
  const results: unknown[] = []
  const resourceURL: ResourcePage<BaseMeta> = {
    enable: true,
packages/karbon/src/runtime/composables/__tests__/seo-preset.spec.ts on lines 226..270

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

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

  async setup(
    { flags, resources, fullStatic, fallback, paywall, seo, isViewable: isViewablePath, previewParagraph },
    nuxt,
  ) {
    const resolver = createResolver(import.meta.url)
Severity: Major
Found in packages/karbon/src/module.ts - About 1 day to fix

    File module.ts has 541 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import process from 'node:process'
    import type { Resolver } from '@nuxt/kit'
    import {
      addComponent,
      addComponentsDir,
    Severity: Major
    Found in packages/karbon/src/module.ts - About 1 day to fix

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

        const opt = convertToOption('article', [
          {
            type: 'static',
            value: '/',
          },
      Severity: Major
      Found in packages/karbon/src/url/__tests__/to-options.spec.ts and 1 other location - About 5 hrs to fix
      packages/karbon/src/url/__tests__/to-options.spec.ts on lines 90..124

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

      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 opt = convertToOption('article', [
          {
            type: 'static',
            value: '/',
          },
      Severity: Major
      Found in packages/karbon/src/url/__tests__/to-options.spec.ts and 1 other location - About 5 hrs to fix
      packages/karbon/src/url/__tests__/to-options.spec.ts on lines 203..237

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

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

      export async function bundle(path: string, vuefileName: string, layoutName: string, dir: string, ssr?: boolean) {
        process.env.NODE_ENV = 'production'
        const name = snakeCase(basename(vuefileName, '.vue'))
        const rollupOptions = createConfig(name, dir, ssr)
        const config = await loadNuxtConfigOnce()
      Severity: Major
      Found in packages/karbon/src/cli/bundle/index.ts - About 4 hrs to fix

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

        interface UsePaginationReturn<T> {
          /**
           * current page number
           */
          page: Ref<number>
        Severity: Major
        Found in packages/karbon/src/runtime/composables/pagination.ts and 1 other location - About 4 hrs to fix
        packages/karbon/src/runtime/composables/pagination.ts on lines 56..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 122.

        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

        export interface UseArticlePaginationReturn extends Omit<UsePaginationReturn<UseArticleReturnWithURL>, 'list'> {
          /**
           * current page number
           *
           * it's ok to modify the page number directly if you need to jump to a specific page
        Severity: Major
        Found in packages/karbon/src/runtime/composables/pagination.ts and 1 other location - About 4 hrs to fix
        packages/karbon/src/runtime/composables/pagination.ts on lines 25..54

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

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

        export function useArticleLoader<UseChunk extends false | number>({
          chunk,
          condition: conditionInput = usePageMetaAsCondition(),
          preload = chunk || 0,
          exclude = usePageMetaAsExclude(),
        Severity: Minor
        Found in packages/karbon/src/runtime/composables/front-page.ts - About 4 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

        File article.ts has 343 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import util from 'node:util'
        import type { ZodError } from 'zod'
        import { gql } from '@apollo/client/core/index.js'
        import type { SearchResponse } from '@storipress/typesense-xior'
        
        
        Severity: Minor
        Found in packages/karbon/src/runtime/api/article.ts - About 4 hrs to fix

          File seo-preset.spec.ts has 327 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { expect, it } from 'vitest'
          import { identity, reduce } from 'remeda'
          import { htmlFilter } from '@storipress/karbon-utils'
          import type { SEOContext } from '../seo-preset'
          import { resolveSEOPresets } from '../seo-preset'
          Severity: Minor
          Found in packages/karbon/src/runtime/composables/__tests__/seo-preset.spec.ts - About 3 hrs to fix

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

            export const invalidContext: ResourcePageContext = import.meta.env.DEV
              ? new Proxy({} as ResourcePageContext, {
                  get(_obj, key) {
                    console.error(`Forbid to access internal context object key ${String(key)} without using \`getResourceOption\``)
                    throw new Error('accessing internal context')
            Severity: Major
            Found in packages/karbon/src/runtime/utils/invalid-context.ts and 1 other location - About 3 hrs to fix
            packages/karbon/src/runtime/routes/_snapshot.ts on lines 38..45

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

            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 invalidContext: ResourcePageContext = import.meta.env.DEV
              ? new Proxy({} as ResourcePageContext, {
                  get(_obj, key) {
                    console.warn(`Forbid to access internal context object key ${String(key)} without using \`getResourceOption\``)
                    throw new Error('accessing internal context')
            Severity: Major
            Found in packages/karbon/src/runtime/routes/_snapshot.ts and 1 other location - About 3 hrs to fix
            packages/karbon/src/runtime/utils/invalid-context.ts on lines 3..10

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

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

              async setup(
                { flags, resources, fullStatic, fallback, paywall, seo, isViewable: isViewablePath, previewParagraph },
                nuxt,
              ) {
                const resolver = createResolver(import.meta.url)
            Severity: Minor
            Found in packages/karbon/src/module.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

                    authInfo: computed<Record<string, any> | undefined | null>({
                      get() {
                        if (authInfo.value) {
                          return authInfo.value
                        }
            Severity: Major
            Found in packages/karbon/src/runtime/plugins/paywall-noop.client.ts and 1 other location - About 3 hrs to fix
            packages/karbon/src/runtime/plugins/paywall.client.ts on lines 115..128

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

            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

                    authInfo: computed<Record<string, any> | undefined | null>({
                      get() {
                        if (authInfo.value) {
                          return authInfo.value
                        }
            Severity: Major
            Found in packages/karbon/src/runtime/plugins/paywall.client.ts and 1 other location - About 3 hrs to fix
            packages/karbon/src/runtime/plugins/paywall-noop.client.ts on lines 24..37

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

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

            export function createStoripressBaseClient(
              apollo: Apollo,
              getHeaders: () => Record<string, string | null | undefined>,
              uri: string,
              opt: CreateBaseClientInput = {},
            Severity: Major
            Found in packages/karbon/src/runtime/composables/storipress-base-client.ts - About 3 hrs to fix

              Function convertToOption has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

              export function convertToOption(
                resource: Resources,
                parts: URLPart[],
                staticParams = {},
              ): ResourcePage<BaseMeta, RouteOptionsContext> {
              Severity: Minor
              Found in packages/karbon/src/url/to-options.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

              export interface ClientHooks {
                'karbon:request': (ctx: RequestContext) => HookResult
                'karbon:response': (ctx: ResponseContext) => HookResult
                'karbon:searchRequest': (ctx: SearchRequestContext) => HookResult
                'karbon:searchResponse': (ctx: SearchResponseContext) => HookResult
              packages/karbon/src/module.ts on lines 53..58

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

              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