storipress/karbon

View on GitHub

Showing 118 of 118 total issues

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

  await expect(
    isViewable({ meta: {} as any, auth: { token: 'token' }, getArticle: (() => {}) as any }),
  ).resolves.toEqual({
    pass: false,
    message: 'Auth fail',
packages/karbon/src/runtime/app/__tests__/default-is-viewable.spec.ts on lines 51..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 72.

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

      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

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

        export const editorBlocks = pipe(
          import.meta.glob('~~/templates/editor-blocks/*.vue', { eager: true }),
          mapKeys((name) => snakeCase(basename(name, '.vue'))),
          mapValues((mod) => (mod as any).default),
        )
        Severity: Major
        Found in packages/karbon/src/runtime/article/utils/editor-blocks.ts and 1 other location - About 1 hr to fix
        packages/karbon/src/runtime/utils/article-layouts.ts on lines 5..9

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

        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 const templates = pipe(
          import.meta.glob('~~/templates/article-layouts/*.vue', { eager: true }),
          mapKeys((name) => snakeCase(basename(name, '.vue'))),
          mapValues((mod) => (mod as any).default),
        )
        Severity: Major
        Found in packages/karbon/src/runtime/utils/article-layouts.ts and 1 other location - About 1 hr to fix
        packages/karbon/src/runtime/article/utils/editor-blocks.ts on lines 5..9

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

        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

            {
              id: 'banner-ad',
              path: '/19968336/header-bid-tag-1',
              sizes: div_2_sizes,
              prebid: [
        Severity: Major
        Found in packages/playground/pages/examples/config.ts and 1 other location - About 1 hr to fix
        packages/playground/pages/examples/config.ts on lines 68..89

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

        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

            {
              id: 'prebid-2',
              path: '/19968336/header-bid-tag-0',
              sizes: div_1_sizes,
              prebid: [
        Severity: Major
        Found in packages/playground/pages/examples/config.ts and 1 other location - About 1 hr to fix
        packages/playground/pages/examples/config.ts on lines 46..67

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

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

          const mount = once(async () => {
            if (!storipress.paywall.enable) {
              return
            }
            const { action, token: tokenQuery } = route.query
        Severity: Minor
        Found in packages/karbon/src/runtime/plugins/paywall.client.ts - About 1 hr to fix

          Function createConfig has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function createConfig(
            name: string,
            dir: string,
            ssr?: boolean,
          ): BuildOptions['rollupOptions'] & { output: OutputOptions } {
          Severity: Minor
          Found in packages/karbon/src/cli/bundle/index.ts - About 1 hr to fix

            Function useFillArticles has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            export function useFillArticles(
              count: number,
              conditionInput?: ConditionInput[],
              { cacheKey: userCacheKey, _conditionID }: { cacheKey?: string; _conditionID?: string } = {},
            ) {
            Severity: Minor
            Found in packages/karbon/src/runtime/composables/front-page.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 resolveSEOProviders has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            export async function resolveSEOProviders(configs: SEOConfig[]): Promise<ResolvedSEOConfig[]> {
              const providers: ResolvedSEOConfig[] = []
              for (const config of configs) {
                if (!config.preset && !config.provider) {
                  logger.warn('SEO config must have either `preset` or `provider`', config)
            Severity: Minor
            Found in packages/karbon/src/seo-provider.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

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

            const gptConfig2 = {
              slots: [
                {
                  id: 'banner-ad',
                  path: '/6355419/Travel/Europe/France/Paris',
            Severity: Major
            Found in packages/playground/pages/examples/config.ts and 1 other location - About 1 hr to fix
            packages/playground/pages/examples/config.ts on lines 1..16

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

            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 gptConfig = {
              slots: [
                {
                  id: 'banner-ad',
                  path: '/6355419/Travel/Europe/France/Paris',
            Severity: Major
            Found in packages/playground/pages/examples/config.ts and 1 other location - About 1 hr to fix
            packages/playground/pages/examples/config.ts on lines 18..33

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

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

              async function* createLoadMore() {
                for (const id of [...articles.value.map(({ id }) => id), ...exclude]) {
                  alreadyUsed.add(id)
                }
                const source = (await getAllArticles()) ?? []
            Severity: Minor
            Found in packages/karbon/src/runtime/composables/front-page.ts - About 1 hr to fix

              Function bundleEditorBlocks has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export async function bundleEditorBlocks() {
                const files = await globby(['templates/editor-blocks/*.vue'])
                const jsonVariable = {
                  blocks: [] as Tblock[],
                }
              Severity: Minor
              Found in packages/karbon/src/cli/bundle/editor-blocks.ts - About 1 hr to fix

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

                  {
                    conditions,
                    count,
                    identity,
                    used,
                Severity: Major
                Found in packages/karbon/src/runtime/composables/front-page.ts and 1 other location - About 1 hr to fix
                packages/karbon/src/runtime/composables/front-page.ts on lines 245..251

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

                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

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

                  opts: {
                    conditions: Condition[]
                    count: number
                    identity?: string
                    used: Set<string>
                Severity: Major
                Found in packages/karbon/src/runtime/composables/front-page.ts and 1 other location - About 1 hr to fix
                packages/karbon/src/runtime/composables/front-page.ts on lines 260..272

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

                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 a Cognitive Complexity of 11 (exceeds 5 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: Minor
                Found in packages/karbon/src/cli/bundle/index.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 usePagination has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function usePagination<T>(allItems: Ref<T[]>, limit: MaybeRef<number>): UsePaginationReturn<T> {
                  // precondition
                  watchInvariant(() => toValue(limit) > 0, '`limit` must not be negative or 0')
                
                  const total = computed(() => {
                Severity: Minor
                Found in packages/karbon/src/runtime/composables/pagination.ts - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language