.scripts/rename.ts

Summary

Maintainability
A
2 hrs
Test Coverage

Function main has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function main(): Promise<void> {
  for await (const entry of readdirP(path.relative(process.cwd(), path.join(__dirname, '..', 'dist/esm')))) {
    const match = /^(.*)(\.(js|js\.map|d\.ts))$/.exec(entry)
    if (match == null) {
      continue
Severity: Minor
Found in .scripts/rename.ts - About 1 hr to fix

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

    async function* readdirP(dir: string): AsyncGenerator<string> {
      for (const entry of await fs.readdir(dir, { withFileTypes: true })) {
        if (entry.isDirectory()) {
          for await (const sub of readdirP(path.join(dir, entry.name))) {
            yield sub
    Severity: Minor
    Found in .scripts/rename.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 main has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    async function main(): Promise<void> {
      for await (const entry of readdirP(path.relative(process.cwd(), path.join(__dirname, '..', 'dist/esm')))) {
        const match = /^(.*)(\.(js|js\.map|d\.ts))$/.exec(entry)
        if (match == null) {
          continue
    Severity: Minor
    Found in .scripts/rename.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

    There are no issues that match your filters.

    Category
    Status