emmercm/igir

View on GitHub
src/types/datStatus.ts

Summary

Maintainability
D
1 day
Test Coverage

File datStatus.ts has 311 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { writeToString } from '@fast-csv/format';
import chalk, { ChalkInstance } from 'chalk';

import ArrayPoly from '../polyfill/arrayPoly.js';
import DAT from './dats/dat.js';
Severity: Minor
Found in src/types/datStatus.ts - About 3 hrs to fix

    Function toCsv has 78 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async toCsv(options: Options): Promise<string> {
        const foundReleaseCandidates = DATStatus.getValuesForAllowedTypes(
          options,
          this.foundRomTypesToReleaseCandidates,
        );
    Severity: Major
    Found in src/types/datStatus.ts - About 3 hrs to fix

      Function toCsv has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        async toCsv(options: Options): Promise<string> {
          const foundReleaseCandidates = DATStatus.getValuesForAllowedTypes(
            options,
            this.foundRomTypesToReleaseCandidates,
          );
      Severity: Minor
      Found in src/types/datStatus.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 constructor has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        constructor(
          dat: DAT,
          options: Options,
          parentsToReleaseCandidates: Map<Parent, ReleaseCandidate[]>,
        ) {
      Severity: Minor
      Found in src/types/datStatus.ts - About 1 hr to fix

        Function rows has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              .map((game) => {
                let status = GameStatus.MISSING;
        
                if (this.ignoredHashCodesToGames.has(game.hashCode())) {
                  status = GameStatus.IGNORED;
        Severity: Minor
        Found in src/types/datStatus.ts - About 1 hr to fix

          Function getAllowedTypes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            private static getAllowedTypes(options: Options): ROMType[] {
              return [
                !options.getOnlyBios() && !options.getOnlyDevice() && !options.getOnlyRetail()
                  ? ROMType.GAME
                  : undefined,
          Severity: Minor
          Found in src/types/datStatus.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 toConsole has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            toConsole(options: Options): string {
              return `${DATStatus.getAllowedTypes(options)
                .filter((type) => this.allRomTypesToGames.get(type)?.length)
                .map((type) => {
                  const found = this.foundRomTypesToReleaseCandidates.get(type) ?? [];
          Severity: Minor
          Found in src/types/datStatus.ts - About 1 hr to fix

            There are no issues that match your filters.

            Category
            Status