emmercm/igir

View on GitHub

Showing 187 of 448 total issues

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

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

            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 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 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 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(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 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 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 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 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

                                Function getOrComputeFileHeader has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  async getOrComputeFileHeader(file: File): Promise<ROMHeader | 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 header
                                Severity: Minor
                                Found in src/types/files/fileCache.ts - About 1 hr to fix

                                  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

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

                                      filter(dat: DAT): DAT {
                                        // Return early if there aren't any games
                                        if (dat.getGames().length === 0) {
                                          this.progressBar.logTrace(`${dat.getNameShort()}: no games to filter`);
                                          return dat;
                                    Severity: Minor
                                    Found in src/modules/dats/datFilter.ts - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language