antongolub/misc

View on GitHub

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

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

if (import.meta.url.startsWith('file:')) {
  const modulePath = url.fileURLToPath(import.meta.url)
  if (process.argv[1] === modulePath) {
    (async () => run())()
  }
Severity: Major
Found in packages/dep/tsc-dts-fix/src/main/ts/cli.ts and 1 other location - About 2 hrs to fix
packages/topoconfig/extends/src/main/ts/cli.ts on lines 33..38

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

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

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

    export type TConfig = {
      granularity?: TGranularity
      keepers?:     TConfigDeclaration[]
      dryrun?:      boolean
      combine?:     boolean
    Severity: Major
    Found in packages/dep/upkeeper/src/main/ts/interface.ts and 1 other location - About 1 hr to fix
    packages/dep/upkeeper/src/main/ts/interface.ts on lines 76..85

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

    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 type TConfigNormalized = {
      granularity:  TGranularity
      keepers:      TKeeperConfigNormalized[]
      dryrun:       boolean
      combine :     boolean
    Severity: Major
    Found in packages/dep/upkeeper/src/main/ts/interface.ts and 1 other location - About 1 hr to fix
    packages/dep/upkeeper/src/main/ts/interface.ts on lines 65..74

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

    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 travel = (regexp: RegExp) =>
        path.split(regexp)
          .filter(Boolean)
          .reduce((res, key) => (res !== null && res !== undefined ? res[key] : res), obj)
    Severity: Major
    Found in packages/topoconfig/core/src/main/ts/util.ts and 1 other location - About 1 hr to fix
    packages/topoconfig/cmds/src/main/ts/get.ts on lines 6..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 69.

    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 travel = (regexp: RegExp) =>
        path.split(regexp)
          .filter(Boolean)
          .reduce((res, key) => (res !== null && res !== undefined ? res[key] : res), obj)
    Severity: Major
    Found in packages/topoconfig/cmds/src/main/ts/get.ts and 1 other location - About 1 hr to fix
    packages/topoconfig/core/src/main/ts/util.ts on lines 6..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 69.

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

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

        for (const [line, count] of entry.da) {
          hits[`da,${line}`] = Math.max(hits[`da,${line}`] || 0, count)
        }
    Severity: Major
    Found in packages/lcov-utils/src/main/ts/lcov.ts and 1 other location - About 1 hr to fix
    packages/lcov-utils/src/main/ts/lcov.ts on lines 134..136

    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

        for (const [count, name] of entry.fnda) {
          hits[`fnda,${name}`] = Math.max(hits[`fnda,${name}`] || 0, count)
        }
    Severity: Major
    Found in packages/lcov-utils/src/main/ts/lcov.ts and 1 other location - About 1 hr to fix
    packages/lcov-utils/src/main/ts/lcov.ts on lines 131..133

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

                Severity
                Category
                Status
                Source
                Language