emmercm/igir

View on GitHub

Showing 444 of 448 total issues

Function getOrComputeFileChecksums has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async getOrComputeFileChecksums(filePath: string, checksumBitmask: number): Promise<File> {
    // NOTE(cemmer): we're explicitly not catching ENOENT errors here, we want it to bubble up
    const stats = await FsPoly.stat(filePath);
    const cacheKey = await this.getCacheKey(filePath, undefined, ValueType.FILE_CHECKSUMS);

Severity: Minor
Found in src/types/files/fileCache.ts - About 1 hr to fix

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

      async filesFrom(
        filePath: string,
        fileChecksumBitmask: number = ChecksumBitmask.CRC32,
        archiveChecksumBitmask = fileChecksumBitmask,
      ): Promise<File[]> {
    Severity: Minor
    Found in src/types/files/fileFactory.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 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

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

          if (inputRomFile.getSize() !== sourceSize) {
            throw new ExpectedError(
              `BPS patch expected ROM size of ${fsPoly.sizeReadable(sourceSize)}: ${this.getFile().toString()}`,
            );
          }
    Severity: Major
    Found in src/types/patches/bpsPatch.ts and 2 other locations - About 1 hr to fix
    src/types/patches/apsGbaPatch.ts on lines 35..39
    src/types/patches/dpsPatch.ts on lines 28..32

    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 60.

    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 (inputRomFile.getSize() !== originalSize) {
            throw new ExpectedError(
              `APS (GBA) patch expected ROM size of ${fsPoly.sizeReadable(originalSize)}: ${this.getFile().toString()}`,
            );
          }
    Severity: Major
    Found in src/types/patches/apsGbaPatch.ts and 2 other locations - About 1 hr to fix
    src/types/patches/bpsPatch.ts on lines 65..69
    src/types/patches/dpsPatch.ts on lines 28..32

    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 60.

    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 (inputRomFile.getSize() !== originalSize) {
            throw new ExpectedError(
              `DPS patch expected ROM size of ${fsPoly.sizeReadable(originalSize)}: ${this.getFile().toString()}`,
            );
          }
    Severity: Major
    Found in src/types/patches/dpsPatch.ts and 2 other locations - About 1 hr to fix
    src/types/patches/apsGbaPatch.ts on lines 35..39
    src/types/patches/bpsPatch.ts on lines 65..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 60.

    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 missingGames has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          .flatMap((game) => {
            let missingDependencies: string[] = [];
    
            // Validate dependent parent was found
            if (
    Severity: Minor
    Found in src/modules/candidates/candidateMergeSplitValidator.ts - About 1 hr to fix

      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

        Function entriesFromArchiveExtension has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private async entriesFromArchiveExtension(
            filePath: string,
            checksumBitmask: number,
            fileExt = filePath.replace(/.+?(?=(\.[a-zA-Z0-9]+)+)/, ''),
          ): Promise<ArchiveEntry<Archive>[] | undefined> {
        Severity: Minor
        Found in src/types/files/fileFactory.ts - About 1 hr to fix

          Function merge has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            merge(dat: DAT): DAT {
              // Don't do anything if no type provided
              if (this.options.getMergeRoms() === undefined) {
                this.progressBar.logTrace(
                  `${dat.getNameShort()}: no ROM merge option provided, doing nothing`,
          Severity: Minor
          Found in src/modules/dats/datMergerSplitter.ts - About 1 hr to fix

            Function validateUniqueOutputPaths has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private validateUniqueOutputPaths(
                dat: DAT,
                parentsToCandidates: Map<Parent, ReleaseCandidate[]>,
              ): ReleaseCandidate[] {
                const outputPathsToCandidates = [...parentsToCandidates.values()]
            Severity: Minor
            Found in src/modules/candidates/candidateValidator.ts - About 1 hr to fix

              Function decode has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                decode(
                  copyAddressesData: Buffer,
                  copyAddressesOffset: number,
                  here: number,
                  mode: number,
              Severity: Minor
              Found in src/types/patches/vcdiffPatch.ts - About 1 hr to fix

                Function scanPaths has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  private static async scanPaths(
                    globPatterns: string[],
                    walkCallback?: FsWalkCallback,
                    requireFiles = true,
                  ): Promise<string[]> {
                Severity: Minor
                Found in src/types/options.ts - About 1 hr to fix

                  Function getArchiveEntries has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    async getArchiveEntries(checksumBitmask: number): Promise<ArchiveEntry<this>[]> {
                      // https://github.com/ZJONSSON/node-unzipper/issues/280
                      // UTF-8 entry names are not decoded correctly
                      // But this is mitigated by `extractEntryToStream()` and therefore `extractEntryToFile()` both
                      //  using `unzipper.Open.file()` as well, so mangled filenames here will still extract fine
                  Severity: Minor
                  Found in src/types/files/archives/zip.ts - About 1 hr to fix

                    Function getArchiveEntriesNotCached has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      private async getArchiveEntriesNotCached(checksumBitmask: number): Promise<ArchiveEntry<this>[]> {
                        /**
                         * WARN(cemmer): {@link _7z.list} seems to have issues with any amount of real concurrency,
                         *  it will return no files but also no error. Try to prevent that behavior.
                         */
                    Severity: Minor
                    Found in src/types/files/archives/sevenZip/sevenZip.ts - About 1 hr to fix

                      Function globPath has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        private static async globPath(
                          inputPath: string,
                          walkCallback: FsWalkCallback,
                        ): Promise<string[]> {
                          // Windows will report that \\.\nul doesn't exist, catch it explicitly
                      Severity: Minor
                      Found in src/types/options.ts - About 1 hr to fix

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

                              if (game.disk) {
                                if (Array.isArray(game.disk)) {
                                  gameDisks = game.disk;
                                } else {
                                  gameDisks = [game.disk];
                        Severity: Major
                        Found in src/modules/dats/datScanner.ts and 2 other locations - About 1 hr to fix
                        src/modules/dats/datScanner.ts on lines 370..376
                        src/modules/dats/datScanner.ts on lines 382..388

                        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 58.

                        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 size = dat
                              .getGames()
                              .flatMap((game) => game.getRoms())
                              .reduce((sum, rom) => sum + rom.getSize(), 0);
                        Severity: Major
                        Found in src/modules/dats/datScanner.ts and 1 other location - About 1 hr to fix
                        src/modules/dats/datFilter.ts on lines 55..58

                        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 58.

                        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 (game.rom) {
                                if (Array.isArray(game.rom)) {
                                  gameRoms = game.rom;
                                } else {
                                  gameRoms = [game.rom];
                        Severity: Major
                        Found in src/modules/dats/datScanner.ts and 2 other locations - About 1 hr to fix
                        src/modules/dats/datScanner.ts on lines 370..376
                        src/modules/dats/datScanner.ts on lines 401..407

                        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 58.

                        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 size = filteredDat
                              .getGames()
                              .flatMap((game) => game.getRoms())
                              .reduce((sum, rom) => sum + rom.getSize(), 0);
                        Severity: Major
                        Found in src/modules/dats/datFilter.ts and 1 other location - About 1 hr to fix
                        src/modules/dats/datScanner.ts on lines 199..202

                        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 58.

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language