antongolub/misc

View on GitHub

Showing 28 of 40 total issues

Function extract has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

const extract = (readable: TPseudoReadable, _opts?: TOpts): TCodeRef[] => {
  const {re, comments, bufferSize, offset} = normalizeOpts(_opts)
  const refs: TCodeRef[] = []
  const pushRef = (type: string, value: string, index: number) => refs.push({ type, value, index })

Severity: Minor
Found in packages/dep/depseek/src/main/ts/depseek.ts - About 7 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 extract has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const extract = (readable: TPseudoReadable, _opts?: TOpts): TCodeRef[] => {
  const {re, comments, bufferSize, offset} = normalizeOpts(_opts)
  const refs: TCodeRef[] = []
  const pushRef = (type: string, value: string, index: number) => refs.push({ type, value, index })

Severity: Minor
Found in packages/dep/depseek/src/main/ts/depseek.ts - About 1 hr to fix

    Function extendObject has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    export const extendObject = ({result, sources, prefix, rules, index}: TExtendCtx & {result: Record<string, any>}) => {
      for (const source of sources) {
        for (const key of getProps(source)) {
          const p = `${prefix ? prefix + '.' : ''}${key as string}`
          const rule = getRule(p, rules)
    Severity: Minor
    Found in packages/topoconfig/extends/src/main/ts/extend.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 sum has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const sum = (lcov: Lcov | string, prefix?: string): LcovDigest => {
      if (typeof lcov === 'string') {
        return sum(parse(lcov), prefix)
      }
      let brf = 0
    Severity: Minor
    Found in packages/lcov-utils/src/main/ts/lcov.ts - About 1 hr to fix

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

      export const processData = (...chunks: any[]) =>
        chunks.length === 1
          ? chunks[0]
          : expand(chunks.reduce((m, v, k) => {
            if (v === VARARG) {
      Severity: Minor
      Found in packages/topoconfig/core/src/main/ts/process.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 getExports has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      const getExports = async (contents: string, file: string): Promise<string[]> => {
        const { lines } = parseContentsLayout(contents)
        const refs = []
        let r = false
        for (const line of lines) {
      Severity: Minor
      Found in packages/esbuild/plugin-hybrid-export/src/main/ts/plugin.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 hybridExportPlugin has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const hybridExportPlugin = (options: Record<string, any> = {}): Plugin => {
        return {
          name: 'hybrid-export',
          setup(build) {
            const {
      Severity: Minor
      Found in packages/esbuild/plugin-hybrid-export/src/main/ts/plugin.ts - About 1 hr to fix

        Function formatEntry has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const formatEntry = (entry: LcovEntry): string => {
          const {
            tn,
            sf,
            fn,
        Severity: Minor
        Found in packages/lcov-utils/src/main/ts/lcov.ts - About 1 hr to fix

          Function transformFile has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          export const transformFile = async (file: TFileEntry, hooks: TTransformHook[], cwd = process.cwd()): Promise<TFileEntry | undefined> => {
            let contents = file.contents
            let path = file.path
            for (const hook of hooks) {
              if (hook.pattern.test(file.path)) {
          Severity: Minor
          Found in packages/esbuild/plugin-utils/src/main/ts/utils.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 setup has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              setup(build) {
                const {
                  entryPoints: entries,
                  format,
                  absWorkingDir = process.cwd(),
          Severity: Minor
          Found in packages/esbuild/plugin-hybrid-export/src/main/ts/plugin.ts - About 1 hr to fix

            Function spawn has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            ): Promise<{stdout: string, stderr: string}> => new Promise((resolve, reject) => {
              let status: number | null = 0
              const now = Date.now()
              const stderr: string[] = []
              const stdout: string[] = []
            Severity: Minor
            Found in packages/dep/upkeeper/src/main/ts/util.ts - About 1 hr to fix

              Function createCtx has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const createCtx = (config: any, opts: TPopulateOpts, loader: TLoad, populate: TPopulate, sync = false): TCtx => {
                const _opts = parseOpts(opts)
                const rules = _opts.rules || {}
                const _extendKeys = Object.keys(rules).filter(k => rules[k] === TStrategy.POPULATE)
                const extendKeys = _extendKeys.length > 0 ? _extendKeys : ['extends']
              Severity: Minor
              Found in packages/topoconfig/extends/src/main/ts/populate.ts - About 1 hr to fix

                Function mergeHits has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                const mergeHits = (entries: LcovEntry[]) => {
                  const hits: Record<string, number> = {}
                
                  for (const entry of entries) {
                    for (const [line, name] of entry.fn) {
                Severity: Minor
                Found in packages/lcov-utils/src/main/ts/lcov.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 get has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                export const get = <T = any>(obj: any, path: string, defaultValue?: any): T => {
                  if (!path || path === '.') return obj
                  if (path.startsWith('.')) return get(obj, path.slice(1), defaultValue)
                
                  const travel = (regexp: RegExp) =>
                Severity: Minor
                Found in packages/topoconfig/cmds/src/main/ts/get.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 getFilesList has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                export const getFilesList = async (dir: string, recursive = true, files: string[] = []) => {
                  if (dir.endsWith('node_modules')) return files
                  for (const file of await fs.readdir(dir)) {
                    const name = `${dir}/${file}`
                    if (fss.statSync(name).isDirectory()) {
                Severity: Minor
                Found in packages/esbuild/plugin-utils/src/main/ts/utils.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 get has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                export const get = <T = any>(obj: any, path?: string, defaultValue?: any): T => {
                  if (!path) return obj
                  if (path.startsWith('.')) return get(obj, path.slice(1), defaultValue)
                
                  const travel = (regexp: RegExp) =>
                Severity: Minor
                Found in packages/topoconfig/core/src/main/ts/util.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

                Avoid deeply nested control flow statements.
                Open

                        if (q === char && prev !== '\\') {
                          if (strLiteral && isDep(token.slice(-offset), re)) pushRef('dep', strLiteral, i - strLiteral.length)
                          strLiteral = ''
                          token = ''
                          q = null
                Severity: Major
                Found in packages/dep/depseek/src/main/ts/depseek.ts - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                          else if (char === '"' || char === "'" || char === '`') q = char
                          else if (prev === '/' && (char === '/' || char === '*')) c = char
                          else token += char
                  Severity: Major
                  Found in packages/dep/depseek/src/main/ts/depseek.ts - About 45 mins to fix

                    Function collide has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export const collide = (lcov: Lcov, ...patches: (Lcov | [Lcov, string])[]): Lcov => {
                      const result: Lcov = {}
                      const prefixes = []
                      for (const patch of patches) {
                        const [_lcov, prefix] = Array.isArray(patch) ? patch : [patch]
                    Severity: Minor
                    Found in packages/lcov-utils/src/main/ts/lcov.ts - About 45 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 parseDtsBundle has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export const parseDtsBundle = (input: string): TAssets => {
                      let declaration: {name: string, contents: string} | null = null
                      const lines = input.split('\n')
                      const declarations: {name: string, contents: string}[] = []
                      const directives: Set<string> = new Set()
                    Severity: Minor
                    Found in packages/dep/tsc-dts-fix/src/main/ts/dts.ts - About 45 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