hongaar/bandersnatch

View on GitHub

Showing 4 of 254 total issues

File countries.ts has 2331 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { command, program } from "../src/index.js";

type CountryData = {
  name: string;
  native: string;
Severity: Major
Found in examples/countries.ts - About 6 days to fix

    Function getQuestions has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private getQuestions(args: T) {
        // If we need to prompt for things, fill questions array
        return this.baseArgs.reduce((questions, arg) => {
          const name = arg.getName();
          const defaultValue = arg.getDefault();
    Severity: Major
    Found in src/prompter.ts - About 2 hrs to fix

      Consider simplifying this complex logical expression.
      Open

            if (isPromptable && (!presentInArgs || isDefault)) {
              // Detect the type of question we need to ask
              switch (true) {
                case typeof arg.getChoices() !== "undefined" &&
                  (arg.getType() === "array" || Array.isArray(defaultValue)):
      Severity: Major
      Found in src/prompter.ts - About 40 mins to fix

        Function add has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          public add(obj: Argument | Option | Command<any>) {
            if (isArgument(obj)) {
              // If last argument is variadic, we should not add more arguments. See
              // https://github.com/yargs/yargs/blob/master/docs/advanced.md#variadic-positional-arguments
              const allArguments = this.getArguments();
        Severity: Minor
        Found in src/command.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

        Severity
        Category
        Status
        Source
        Language