emmercm/igir

View on GitHub

Showing 444 of 448 total issues

Function parseGdi has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  private static async parseGdi<T extends Archive>(
    archive: T,
    gdiFilePath: string,
    binRawFilePaths: string[],
    checksumBitmask: number,
Severity: Minor
Found in src/types/files/archives/chd/chdGdiParser.ts - About 1 hr to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      hashCode(): string {
        return (
          this.getSha256() ?? this.getSha1() ?? this.getMd5() ?? `${this.getCrc32()}|${this.getSize()}`
        );
      }
    Severity: Major
    Found in src/types/files/file.ts and 1 other location - About 1 hr to fix
    src/types/dats/rom.ts on lines 164..168

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 67.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        new GameConsole(/FDS|(Famicom|Family) Computer Disk System/i, ['.fds'], {
          adam: 'FDS',
          batocera: 'fds',
          emulationstation: 'fds',
          funkeyos: 'NES',
    Severity: Major
    Found in src/types/gameConsole.ts and 1 other location - About 1 hr to fix
    src/types/gameConsole.ts on lines 257..270

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 67.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        new GameConsole(/WonderSwan/i, ['.ws'], {
          adam: 'WSC',
          batocera: 'wswan',
          emulationstation: 'wonderswan',
          funkeyos: 'WonderSwan',
    Severity: Major
    Found in src/types/gameConsole.ts and 1 other location - About 1 hr to fix
    src/types/gameConsole.ts on lines 702..715

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 67.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      hashCode(): string {
        return (
          this.getSha256() ?? this.getSha1() ?? this.getMd5() ?? `${this.getCrc32()}|${this.getSize()}`
        );
      }
    Severity: Major
    Found in src/types/dats/rom.ts and 1 other location - About 1 hr to fix
    src/types/files/file.ts on lines 525..529

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 67.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function parseXmlDat has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      private parseXmlDat(datFile: File, fileContents: string): DAT | undefined {
        this.progressBar.logTrace(
          `${datFile.toString()}: attempting to parse ${fsPoly.sizeReadable(fileContents.length)} of XML`,
        );
    
    
    Severity: Minor
    Found in src/modules/dats/datScanner.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 create has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async create(
        dat: DAT,
        parentsToCandidates: Map<Parent, ReleaseCandidate[]>,
      ): Promise<string | undefined> {
        if (!this.options.shouldDir2Dat()) {
    Severity: Minor
    Found in src/modules/dir2DatCreator.ts - About 1 hr to fix

      Function trashOrDelete has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private async trashOrDelete(filePaths: string[]): Promise<void> {
          // Prefer recycling...
          for (let i = 0; i < filePaths.length; i += Defaults.OUTPUT_CLEANER_BATCH_SIZE) {
            const filePathsChunk = filePaths.slice(i, i + Defaults.OUTPUT_CLEANER_BATCH_SIZE);
            this.progressBar.logInfo(
      Severity: Minor
      Found in src/modules/directoryCleaner.ts - About 1 hr to fix

        Function extractAndPatchToFile has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async extractAndPatchToFile(destinationPath: string): Promise<void> {
            const start = this.getFileHeader()?.getDataOffsetBytes() ?? 0;
            const patch = this.getPatch();
        
            // Simple case: create a file without removing its header
        Severity: Minor
        Found in src/types/files/file.ts - About 1 hr to fix

          Function downloadToPath has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async downloadToPath(filePath: string): Promise<File> {
              if (await fsPoly.exists(this.getFilePath())) {
                return this;
              }
          
          
          Severity: Minor
          Found in src/types/files/file.ts - About 1 hr to fix

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                if (Array.isArray(this.machine)) {
                  if (this.machine.length > 0) {
                    return this.machine;
                  }
                } else if (this.machine) {
            Severity: Major
            Found in src/types/dats/mame/mameDat.ts and 2 other locations - About 1 hr to fix
            src/types/dats/logiqx/logiqxDat.ts on lines 55..61
            src/types/dats/logiqx/logiqxDat.ts on lines 63..69

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 66.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                if (Array.isArray(this.game)) {
                  if (this.game.length > 0) {
                    return this.game;
                  }
                } else if (this.game) {
            Severity: Major
            Found in src/types/dats/logiqx/logiqxDat.ts and 2 other locations - About 1 hr to fix
            src/types/dats/logiqx/logiqxDat.ts on lines 63..69
            src/types/dats/mame/mameDat.ts on lines 49..55

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 66.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                if (Array.isArray(this.machine)) {
                  if (this.machine.length > 0) {
                    return this.machine;
                  }
                } else if (this.machine) {
            Severity: Major
            Found in src/types/dats/logiqx/logiqxDat.ts and 2 other locations - About 1 hr to fix
            src/types/dats/logiqx/logiqxDat.ts on lines 55..61
            src/types/dats/mame/mameDat.ts on lines 49..55

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 66.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                const bMatched = romRegex.some((regex) =>
                  b
                    .getGame()
                    .getRoms()
                    .some((rom) => regex.test(rom.getName())),
            Severity: Major
            Found in src/modules/candidates/candidatePreferer.ts and 1 other location - About 1 hr to fix
            src/modules/candidates/candidatePreferer.ts on lines 144..151

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 66.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                const aMatched = romRegex.some((regex) =>
                  a
                    .getGame()
                    .getRoms()
                    .some((rom) => regex.test(rom.getName())),
            Severity: Major
            Found in src/modules/candidates/candidatePreferer.ts and 1 other location - About 1 hr to fix
            src/modules/candidates/candidatePreferer.ts on lines 152..159

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 66.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Function filterGame has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private filterGame(game: Game): boolean {
                // If any condition evaluates to 'true', then the candidate will be excluded
                return (
                  [
                    this.options.getFilterRegex() &&
            Severity: Minor
            Found in src/modules/dats/datFilter.ts - About 1 hr to fix

              Function parseSourceMaterialDatabase has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private async parseSourceMaterialDatabase(
                  datFile: File,
                  fileContents: string,
                ): Promise<DAT | undefined> {
                  this.progressBar.logTrace(`${datFile.toString()}: attempting to parse SMDB`);
              Severity: Minor
              Found in src/modules/dats/datScanner.ts - About 1 hr to fix

                Function hashedRomsWithFiles has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                                  releaseCandidate.getRomsWithFiles().map(async (romWithFiles) => {
                                    const inputFile = romWithFiles.getInputFile();
                                    if (!(inputFile instanceof ArchiveFile)) {
                                      return romWithFiles;
                                    }
                Severity: Minor
                Found in src/modules/candidates/candidateArchiveFileHasher.ts - About 1 hr to fix

                  Function save has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    public async save(): Promise<void> {
                      try {
                        await this.saveMutex.runExclusive(async () => {
                          // Clear any existing timeout
                          if (this.saveToFileTimeout !== undefined) {
                  Severity: Minor
                  Found in src/types/cache.ts - About 1 hr to fix

                    Function applyCommandOpen has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                      private async applyCommandOpen(patchFile: FilePoly, targetFile: FilePoly): Promise<void> {
                        const multiFile = (await patchFile.readNext(1)).readUInt8();
                        if (multiFile > 0) {
                          throw new ExpectedError(
                            `Multi-file NINJA patches aren't supported: ${this.getFile().toString()}`,
                    Severity: Minor
                    Found in src/types/patches/ninjaPatch.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

                    Severity
                    Category
                    Status
                    Source
                    Language