ducktors/crane

View on GitHub

Showing 18 of 33 total issues

File run-prompt.ts has 309 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { confirm, select, isCancel, cancel, text } from '@clack/prompts'

import { canSkipEmptying } from './can-skip-emptying'
import { isValidPackageName, toValidPackageName } from './package-name-utils'

Severity: Minor
Found in lib/run-prompt.ts - About 3 hrs to fix

    File cli.ts has 297 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #!/usr/bin/env node
    import { intro, outro, spinner } from '@clack/prompts'
    import { red, bold, bgYellow, black, yellow, green, bgRed } from 'picocolors'
    import minimist from 'minimist'
    import { join, relative, resolve } from 'node:path'
    Severity: Minor
    Found in cli.ts - About 3 hrs to fix

      Function scaffold has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      async function scaffold({
        fullProjectDir,
        existingProject,
        projectType,
        packageName,
      Severity: Minor
      Found in cli.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 main has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      async function main() {
        await ensurePnpm()
      
        console.log()
        intro(bgYellow(black(` Crane CLI v${version} `)))
      Severity: Major
      Found in cli.ts - About 2 hrs to fix

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

        function renderTemplate(
          src: string,
          dest: string,
          existingProject?: 'force' | 'inject' | 'skip',
        ) {
        Severity: Minor
        Found in lib/renderers/template.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 printGuideText has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        function printGuideText({
          fullProjectDir,
          changesets,
          projectType,
          shouldInstallDeps,
        Severity: Minor
        Found in cli.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 renderTemplate has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function renderTemplate(
          src: string,
          dest: string,
          existingProject?: 'force' | 'inject' | 'skip',
        ) {
        Severity: Minor
        Found in lib/renderers/template.ts - About 1 hr to fix

          Function ensurePnpm has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export async function ensurePnpm() {
            const isPnpmAvailable = await checkPnpm()
            if (!isPnpmAvailable) {
              console.log()
              intro(bgRed(black(underline(' Crane CLI is missing some pre-requisites'))))
          Severity: Minor
          Found in lib/ensure-pnpm.ts - About 1 hr to fix

            Function getCommand has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            export function getCommand(
              packageManager: string,
              scriptName: string,
              args?: string,
            ) {
            Severity: Minor
            Found in lib/get-command.ts - About 55 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 deepMerge has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            export function deepMerge(target: any, obj: any) {
              for (const key of Object.keys(obj)) {
                const oldVal = target[key]
                const newVal = obj[key]
            
            
            Severity: Minor
            Found in lib/deep-merge.ts - About 35 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

            Avoid too many return statements within this function.
            Open

              return shouldContinue
            Severity: Major
            Found in lib/run-prompt.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                return existingProject
              Severity: Major
              Found in lib/run-prompt.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    if (existingProject === 'inject') return
                Severity: Major
                Found in lib/renderers/template.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return
                  Severity: Major
                  Found in lib/renderers/template.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                      return projectType
                    Severity: Major
                    Found in lib/run-prompt.ts - About 30 mins to fix

                      Function postOrderDirectoryTraverse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export function postOrderDirectoryTraverse(
                        dir: string,
                        dirCallback: (dir: string) => void,
                        fileCallback: (file: string) => void,
                      ) {
                      Severity: Minor
                      Found in lib/post-order-directory-traverse.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 askExistingProject has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                      async function askExistingProject({
                        force,
                        inject,
                        projectName,
                      }: { force?: boolean; inject?: boolean; projectName: string }) {
                      Severity: Minor
                      Found in lib/run-prompt.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 ensurePnpm has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export async function ensurePnpm() {
                        const isPnpmAvailable = await checkPnpm()
                        if (!isPnpmAvailable) {
                          console.log()
                          intro(bgRed(black(underline(' Crane CLI is missing some pre-requisites'))))
                      Severity: Minor
                      Found in lib/ensure-pnpm.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