nandenjin/twinkle-parser

View on GitHub

Showing 8 of 9 total issues

Function repairCSV has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

export const repairCSV = (csvString: string): string => {
  /** Escape content inside quotation */
  const escape = (content: string) => {
    let result = ''
    do {
Severity: Minor
Found in src/util/csv.ts - About 3 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 default has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

export default function (pkg: PackageJSON, _argv: string[]): number {
  const argv = parseArgs(_argv.slice(2))

  // * Help
  if (argv.h || argv.help) {
Severity: Minor
Found in src/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 default has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function (pkg: PackageJSON, _argv: string[]): number {
  const argv = parseArgs(_argv.slice(2))

  // * Help
  if (argv.h || argv.help) {
Severity: Major
Found in src/cli.ts - About 2 hrs to fix

    Function parse has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function parse(csvData: string): KDBData {
      const output: KDBData = {}
    
      const data = parseCSV(csvData) as string[][]
    
    
    Severity: Minor
    Found in src/index.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 repairCSV has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const repairCSV = (csvString: string): string => {
      /** Escape content inside quotation */
      const escape = (content: string) => {
        let result = ''
        do {
    Severity: Minor
    Found in src/util/csv.ts - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                    for (let i = s; i <= e; i++) {
                      ps.push(i)
                    }
      Severity: Major
      Found in src/index.ts - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                  if (arrayUtil.isConsecutiveN(union)) {
                    a[1] = union
                    periods.splice(j, 1)
                  }
        Severity: Major
        Found in src/index.ts - About 45 mins to fix

          Avoid too many return statements within this function.
          Open

            return 0
          Severity: Major
          Found in src/cli.ts - About 30 mins to fix
            Severity
            Category
            Status
            Source
            Language