emmercm/igir

View on GitHub

Showing 444 of 448 total issues

Function trashOrDelete has a Cognitive Complexity of 12 (exceeds 5 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

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

  render(force = false): void {
    this.singleBarFormatted?.getSingleBar().update(this.payload);

    const callback = (): void => {
      // Dequeue all log messages
Severity: Minor
Found in src/console/progressBarCli.ts - About 1 hr to fix

    Function walk has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static async walk(pathLike: PathLike, callback?: FsWalkCallback): Promise<string[]> {
        let output: string[] = [];
    
        let entries: fs.Dirent[];
        try {
    Severity: Minor
    Found in src/polyfill/fsPoly.ts - About 1 hr to fix

      Function hashStream has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public static async hashStream(stream: Stream, checksumBitmask: number): Promise<ChecksumProps> {
          // Not calculating any checksums, do nothing
          if (!checksumBitmask) {
            // WARN(cemmer): this may leave the stream un-drained and therefore some file handles open!
            return {};
      Severity: Minor
      Found in src/types/files/fileChecksums.ts - About 1 hr to fix

        Function extractEntryToFile has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async extractEntryToFile(entryPath: string, extractedFilePath: string): Promise<void> {
            const tempDir = await fsPoly.mkdtemp(path.join(Temp.getTempDir(), '7z'));
            try {
              let tempFile = path.join(tempDir, entryPath);
              await new Promise<void>((resolve, reject) => {
        Severity: Minor
        Found in src/types/files/archives/sevenZip/sevenZip.ts - About 1 hr to fix

          Function scan has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async scan(): Promise<Patch[]> {
              this.progressBar.logTrace('scanning patch files');
              this.progressBar.setSymbol(ProgressBarSymbol.FILE_SCANNING);
              this.progressBar.reset(0);
          
          
          Severity: Minor
          Found in src/modules/patchScanner.ts - About 1 hr to fix

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

              process(
                dat: DAT,
                parentsToCandidates: Map<Parent, ReleaseCandidate[]>,
              ): Map<Parent, ReleaseCandidate[]> {
                if (parentsToCandidates.size === 0) {
            Severity: Minor
            Found in src/modules/candidates/candidatePostProcessor.ts - About 1 hr to fix

              Function infer has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                infer(dat: DAT): DAT {
                  if (dat.hasParentCloneInfo() && !this.options.getDatIgnoreParentClone()) {
                    this.progressBar.logTrace(`${dat.getNameShort()}: DAT has parent/clone info, skipping`);
                    return dat;
                  }
              Severity: Minor
              Found in src/modules/dats/datParentInferrer.ts - About 1 hr to fix

                Function fromFilePoly has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  static async fromFilePoly(inputRomFile: File, patchFile: FilePoly): Promise<PPFHeader> {
                    const header = (await patchFile.readNext(5)).toString();
                    if (!header.startsWith(PPFHeader.FILE_SIGNATURE.toString())) {
                      throw new ExpectedError(`PPF patch header is invalid: ${patchFile.getPathLike()}`);
                    }
                Severity: Minor
                Found in src/types/patches/ppfPatch.ts - About 1 hr to fix

                  Function fromFilePoly has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    static async fromFilePoly(patchFile: FilePoly): Promise<VcdiffWindow> {
                      const winIndicator = (await patchFile.readNext(1)).readUInt8();
                      let sourceSegmentSize = 0;
                      let sourceSegmentPosition = 0;
                      if (winIndicator & (VcdiffWinIndicator.SOURCE | VcdiffWinIndicator.TARGET)) {
                  Severity: Minor
                  Found in src/types/patches/vcdiffPatch.ts - About 1 hr to fix

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

                      async getArchiveEntries(checksumBitmask: number): Promise<ArchiveEntry<this>[]> {
                        const archiveEntryPromises: Promise<ArchiveEntry<this>>[] = [];
                    
                        // WARN(cemmer): entries in tar archives don't have headers, the entire file has to be read to
                        // calculate the CRCs
                    Severity: Minor
                    Found in src/types/files/archives/tar.ts - About 1 hr to fix

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

                        @Memoize()
                        getName(): string {
                          return Object.keys(FileSignature.SIGNATURES).find(
                            (name) => FileSignature.SIGNATURES[name] === this,
                          ) as string;
                      Severity: Major
                      Found in src/types/files/fileSignature.ts and 1 other location - About 1 hr to fix
                      src/types/files/romHeader.ts on lines 135..140

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

                      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

                        getFilterLanguage(): Set<string> {
                          if (this.filterLanguage.length > 0) {
                            return new Set(Options.filterUniqueUpper(this.filterLanguage));
                          }
                          return new Set();
                      Severity: Major
                      Found in src/types/options.ts and 1 other location - About 1 hr to fix
                      src/types/options.ts on lines 1065..1070

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

                      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

                        getFilterRegion(): Set<string> {
                          if (this.filterRegion.length > 0) {
                            return new Set(Options.filterUniqueUpper(this.filterRegion));
                          }
                          return new Set();
                      Severity: Major
                      Found in src/types/options.ts and 1 other location - About 1 hr to fix
                      src/types/options.ts on lines 1058..1063

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

                      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

                              if (!biosGame) {
                                // Invalid romOf attribute, external BIOS not found
                                this.progressBar.logTrace(
                                  `${dat.getNameShort()}: ${game.getName()} references an invalid BIOS: ${game.getBios()}`,
                                );
                      Severity: Major
                      Found in src/modules/dats/datMergerSplitter.ts and 1 other location - About 1 hr to fix
                      src/modules/dats/datMergerSplitter.ts on lines 154..160

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

                      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

                        @Memoize()
                        getName(): string {
                          return Object.keys(ROMHeader.HEADERS).find(
                            (name) => ROMHeader.HEADERS[name] === this,
                          ) as string;
                      Severity: Major
                      Found in src/types/files/romHeader.ts and 1 other location - About 1 hr to fix
                      src/types/files/fileSignature.ts on lines 352..357

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

                      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

                              if (!parentGame) {
                                // Invalid cloneOf attribute, parent not found
                                this.progressBar.logTrace(
                                  `${dat.getNameShort()}: ${game.getName()} references an invalid parent: ${game.getParent()}`,
                                );
                      Severity: Major
                      Found in src/modules/dats/datMergerSplitter.ts and 1 other location - About 1 hr to fix
                      src/modules/dats/datMergerSplitter.ts on lines 120..126

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

                      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 gameNamesToGames = dat.getGames().reduce((map, game) => {
                            map.set(game.getName(), game);
                            return map;
                          }, new Map<string, Game>());
                      Severity: Major
                      Found in src/modules/dats/datMergerSplitter.ts and 1 other location - About 1 hr to fix
                      src/modules/candidates/candidateMergeSplitValidator.ts on lines 38..41

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

                      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 datGamesIndexed = dat.getGames().reduce((map, game) => {
                            map.set(game.getName(), game);
                            return map;
                          }, new Map<string, Game>());
                      Severity: Major
                      Found in src/modules/candidates/candidateMergeSplitValidator.ts and 1 other location - About 1 hr to fix
                      src/modules/dats/datMergerSplitter.ts on lines 43..46

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

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

                        async getOrComputeFileSignature(file: File): Promise<FileSignature | undefined> {
                          // NOTE(cemmer): we're explicitly not catching ENOENT errors here, we want it to bubble up
                          const stats = await FsPoly.stat(file.getFilePath());
                          if (stats.size === 0) {
                            // An empty file can't have a signature
                      Severity: Minor
                      Found in src/types/files/fileCache.ts - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language