storipress/karbon

View on GitHub

Showing 58 of 116 total issues

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

      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

        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

          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

          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

            File parser.spec.ts has 277 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { expect, it } from 'vitest'
            import { parse, toRoute } from '../parser'
            
            it('parse url work', () => {
              expect(parse('/posts/{slug}')).toMatchInlineSnapshot(`
            Severity: Minor
            Found in packages/karbon/src/url/__tests__/parser.spec.ts - About 2 hrs to fix

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

              function getDefineArticle(pageMeta: PageMeta, site: Site) {
                const siteConfig = useSiteConfig()
                const siteUrl = withoutTrailingSlash(siteConfig.url)
                const article: Article = pageMeta.meta
                const authors = article.authors.map((author) => {
              Severity: Major
              Found in packages/karbon/src/runtime/composables/article-schema.ts - About 2 hrs to fix

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

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

                  Function useResourceList has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function useResourceList<Type extends Resources, Return = ResourceIDWithURL<Type>>(
                    resource: Type,
                    opt: UseResourceListOptions<Type, Return> = {},
                  ): AsyncData<Return[], true | null> {
                    if (opt.withoutAsyncData) {
                  Severity: Major
                  Found in packages/karbon/src/runtime/composables/resources.ts - About 2 hrs to fix

                    File front-page.ts has 258 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import type { Ref } from 'vue'
                    import { warn } from 'vue'
                    import { hash } from 'ohash'
                    import type { MaybeRef } from '@vueuse/core'
                    import type { Promisable } from 'type-fest'
                    Severity: Minor
                    Found in packages/karbon/src/runtime/composables/front-page.ts - About 2 hrs to fix

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

                      export function normalizeArticle(article: RawArticleLike | TypesenseArticleLike) {
                        const {
                          title,
                          blurb,
                          seo,
                      Severity: Major
                      Found in packages/karbon/src/runtime/api/normalize-article.ts - About 2 hrs to fix

                        Function tapClient has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          const tapClient = new ApolloLink((operation, forward) => {
                            const id = crypto.randomUUID()
                        
                            operation.setContext({
                              karbonTracing: id,
                        Severity: Major
                        Found in packages/karbon/src/runtime/composables/storipress-base-client.ts - About 2 hrs to fix

                          Function useRenderEditorBlock has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                          Open

                          export function useRenderEditorBlock(blocks: Record<string, Component>) {
                            return {
                              async render(fields: Record<string, unknown[]>, { uuid, name }: { uuid: string; name: string }) {
                                const element = document.querySelector(`div[data-uuid="${uuid}"]`)
                                if (element && !Reflect.get(element, IS_RENDERED)) {
                          Severity: Minor
                          Found in packages/karbon/src/runtime/article/utils/render-editor-block.ts - About 2 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

                          Function useLoadMore has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                          Open

                          export function useLoadMore<T>(GeneratorSource: () => AsyncGenerator<T>, option?: LoadMoreOptions) {
                            const { preload } = option ?? {}
                          
                            const loading = ref(false)
                            const isDone = ref(false)
                          Severity: Minor
                          Found in packages/karbon/src/runtime/composables/load-more.ts - About 1 hr 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 useLoadMore has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export function useLoadMore<T>(GeneratorSource: () => AsyncGenerator<T>, option?: LoadMoreOptions) {
                            const { preload } = option ?? {}
                          
                            const loading = ref(false)
                            const isDone = ref(false)
                          Severity: Minor
                          Found in packages/karbon/src/runtime/composables/load-more.ts - About 1 hr to fix

                            Function compress has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            async function compress() {
                              await fs.remove(siteTemplateName)
                            
                              const files = await globby(
                                [
                            Severity: Minor
                            Found in packages/karbon/src/cli/karbon.ts - About 1 hr to fix

                              Function convertToOption has 45 lines of code (exceeds 25 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 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language