emmercm/igir

View on GitHub

Showing 444 of 448 total issues

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

    return this.extractEntryToStream(
      entryPath,
      async (stream) =>
        new Promise((resolve, reject) => {
          const writeStream = fs.createWriteStream(extractedFilePath);
Severity: Major
Found in src/types/files/archives/zip.ts and 1 other location - About 2 hrs to fix
src/types/files/archives/chd/chd.ts on lines 99..108

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

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 4 locations. Consider refactoring.
Open

    if (datObject.datafile) {
      try {
        return LogiqxDAT.fromObject(datObject.datafile);
      } catch (error) {
        this.progressBar.logTrace(`${datFile.toString()}: failed to parse DAT object: ${error}`);
Severity: Major
Found in src/modules/dats/datScanner.ts and 3 other locations - About 2 hrs to fix
src/modules/dats/datScanner.ts on lines 300..309
src/modules/dats/datScanner.ts on lines 311..320
src/modules/dats/datScanner.ts on lines 322..331

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

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

    return this.extractEntryToStreamCached(
      entryPath,
      async (stream) =>
        new Promise((resolve, reject) => {
          const writeStream = fs.createWriteStream(extractedFilePath);
Severity: Major
Found in src/types/files/archives/chd/chd.ts and 1 other location - About 2 hrs to fix
src/types/files/archives/zip.ts on lines 87..96

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

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 validate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  validate(dat: DAT, parentsToCandidates: Map<Parent, ReleaseCandidate[]>): string[] {
    if (parentsToCandidates.size === 0) {
      this.progressBar.logTrace(
        `${dat.getNameShort()}: no parents to validate merged & split ROM sets for`,
      );
Severity: Minor
Found in src/modules/candidates/candidateMergeSplitValidator.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 applyPatch has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  private static async applyPatch(
    patchFile: FilePoly,
    sourceFile: FilePoly,
    targetFile: FilePoly,
  ): Promise<void> {
Severity: Minor
Found in src/types/patches/bpsPatch.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 clean has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  async clean(dirsToClean: string[], filesToExclude: File[]): Promise<string[]> {
    // If nothing was written, then don't clean anything
    if (filesToExclude.length === 0) {
      this.progressBar.logTrace('no files were written, not cleaning output');
      return [];
Severity: Minor
Found in src/modules/directoryCleaner.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 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

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

    new GameConsole(/GBA|Game ?Boy Advance/i, ['.gba'], {
      adam: 'GBA',
      batocera: 'gba',
      emulationstation: 'gba',
      funkeyos: 'Game Boy Advance',
Severity: Major
Found in src/types/gameConsole.ts and 3 other locations - About 2 hrs to fix
src/types/gameConsole.ts on lines 763..777
src/types/gameConsole.ts on lines 996..1010
src/types/gameConsole.ts on lines 1011..1025

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

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 4 locations. Consider refactoring.
Open

    new GameConsole(/Game Gear/i, ['.gg'], {
      adam: 'GG',
      batocera: 'gamegear',
      emulationstation: 'gamegear',
      funkeyos: 'Game Gear',
Severity: Major
Found in src/types/gameConsole.ts and 3 other locations - About 2 hrs to fix
src/types/gameConsole.ts on lines 748..762
src/types/gameConsole.ts on lines 763..777
src/types/gameConsole.ts on lines 1011..1025

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

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 4 locations. Consider refactoring.
Open

    new GameConsole(/Master System/i, ['.sms'], {
      adam: 'SMS',
      batocera: 'mastersystem',
      emulationstation: 'mastersystem',
      funkeyos: 'Sega Master System',
Severity: Major
Found in src/types/gameConsole.ts and 3 other locations - About 2 hrs to fix
src/types/gameConsole.ts on lines 748..762
src/types/gameConsole.ts on lines 763..777
src/types/gameConsole.ts on lines 996..1010

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

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 4 locations. Consider refactoring.
Open

    new GameConsole(/GBC|Game ?Boy Color/i, ['.gbc'], {
      adam: 'GBC',
      batocera: 'gbc',
      emulationstation: 'gbc',
      funkeyos: 'Game Boy Color',
Severity: Major
Found in src/types/gameConsole.ts and 3 other locations - About 2 hrs to fix
src/types/gameConsole.ts on lines 748..762
src/types/gameConsole.ts on lines 996..1010
src/types/gameConsole.ts on lines 1011..1025

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

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

  static async realpath(pathLike: PathLike): Promise<string> {
    if (!(await this.exists(pathLike))) {
      throw new ExpectedError(`can't get realpath of non-existent path: ${pathLike}`);
    }
    return fs.promises.realpath(pathLike);
Severity: Major
Found in src/polyfill/fsPoly.ts and 1 other location - About 2 hrs to fix
src/polyfill/fsPoly.ts on lines 317..322

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

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

  static async readlink(pathLike: PathLike): Promise<string> {
    if (!(await this.isSymlink(pathLike))) {
      throw new ExpectedError(`can't readlink of non-symlink: ${pathLike}`);
    }
    return fs.promises.readlink(pathLike);
Severity: Major
Found in src/polyfill/fsPoly.ts and 1 other location - About 2 hrs to fix
src/polyfill/fsPoly.ts on lines 347..352

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

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 (!checkArgv._.includes('zip') && needZip.length > 0) {
          throw new ExpectedError(
            `Missing required command for option${needZip.length !== 1 ? 's' : ''} ${needZip.join(', ')}: zip`,
          );
        }
Severity: Major
Found in src/modules/argumentsParser.ts and 1 other location - About 2 hrs to fix
src/modules/argumentsParser.ts on lines 559..563

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

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 (!checkArgv._.includes('link') && needLinkCommand.length > 0) {
          throw new ExpectedError(
            `Missing required command for option${needLinkCommand.length !== 1 ? 's' : ''} ${needLinkCommand.join(', ')}: link`,
          );
        }
Severity: Major
Found in src/modules/argumentsParser.ts and 1 other location - About 2 hrs to fix
src/modules/argumentsParser.ts on lines 538..542

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

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

      private async parseDatFile(datFile: File): Promise<DAT | undefined> {
        let dat: DAT | undefined;
    
        if (
          !dat &&
    Severity: Minor
    Found in src/modules/dats/datScanner.ts - About 1 hr to fix

      Function romsWithFiles has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                unpatchedReleaseCandidate.getRomsWithFiles().map(async (romWithFiles) => {
                  // Apply the new filename
                  let rom = romWithFiles.getRom();
                  let inputFile = romWithFiles.getInputFile();
                  let outputFile = romWithFiles.getOutputFile();
      Severity: Minor
      Found in src/modules/candidates/candidatePatchGenerator.ts - About 1 hr to fix

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

          async process(inputRomFiles: File[]): Promise<File[]> {
            if (inputRomFiles.length === 0) {
              return inputRomFiles;
            }
        
        
        Severity: Minor
        Found in src/modules/roms/romHeaderProcessor.ts - About 1 hr to fix

          Function addCommands has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              const addCommands = (yargsObj: Argv, previousCommands: string[] = []): Argv => {
                commands
                  // Don't allow/show duplicate commands, i.e. don't give `igir copy copy` as an option
                  .filter(([command]) => !previousCommands.includes(command))
                  // Don't allow/show conflicting commands, i.e. don't give `igir copy move` as an option
          Severity: Minor
          Found in src/modules/argumentsParser.ts - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language