XasCode/terrafile-backend-lib

View on GitHub

Showing 8 of 67 total issues

Function Terrafile has 121 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function Terrafile(options: CliOptions): Status {
  function validateOptions(): Status {
    if (!validOptions(this.options, `file` as Option)) {
      this.success = false;
      this.contents = null;
Severity: Major
Found in src/backend/processFile.ts - About 4 hrs to fix

    Function Terrafile has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    function Terrafile(options: CliOptions): Status {
      function validateOptions(): Status {
        if (!validOptions(this.options, `file` as Option)) {
          this.success = false;
          this.contents = null;
    Severity: Minor
    Found in src/backend/processFile.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 Git has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    function Git(matchStart?: string, sourceType?: ModulesKeyType): GitModuleTypes {
      function replaceUrlVersionIfVersionParam(source: Path, version: string): Path {
        return version ? [source.split(`?ref=`)[0], version].join(`?ref=`) : source;
      }
    
    
    Severity: Minor
    Found in src/backend/moduleSources/common/git.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 cloneRepoToDest has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    async function cloneRepoToDest(
      repoUrl: Path,
      fullDest: Path,
      cloner: (_: string[], __?: Path) => Promise<ExecResult>,
      fsHelpers: FsHelpers,
    Severity: Minor
    Found in src/backend/moduleSources/common/cloneRepo.ts - About 1 hr to fix

      Function Git has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function Git(matchStart?: string, sourceType?: ModulesKeyType): GitModuleTypes {
        function replaceUrlVersionIfVersionParam(source: Path, version: string): Path {
          return version ? [source.split(`?ref=`)[0], version].join(`?ref=`) : source;
        }
      
      
      Severity: Minor
      Found in src/backend/moduleSources/common/git.ts - About 1 hr to fix

        Function process has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async function process(): Promise<Status> {
            const retVal = { ...this };
            if (this.success) {
              const fetchResults = await fetchModules(
                this.contents,
        Severity: Minor
        Found in src/backend/processFile.ts - About 1 hr to fix

          Function fetchModules has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              contents: [string, Record<string, string>][],
              dir: Path,
              fetcher: (_: Config) => Promise<RetString>,
              cloner: (_: string[], __?: Path) => Promise<ExecResult>,
              fsHelpers: FsHelpers,
          Severity: Minor
          Found in src/backend/processFile.ts - About 35 mins to fix

            Function install has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            async function install(options: CliOptions): Promise<void> {
              console.log(chalk.blue(`Plan: (${options.file}) --> (${options.directory})`));
              const createResult = createTargetDirectory(options);
              if (!createResult.success) {
                console.error(chalk.red(`  ! Failed - create target directory: ${options.directory}`));
            Severity: Minor
            Found in src/backend/index.ts - About 25 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