emmercm/igir

View on GitHub
src/types/dats/game.ts

Summary

Maintainability
F
4 days
Test Coverage

Game has 56 functions (exceeds 20 allowed). Consider refactoring.
Open

export default class Game implements GameProps {
  @Expose()
  readonly name: string;

  /**
Severity: Major
Found in src/types/dats/game.ts - About 1 day to fix

    File game.ts has 495 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import 'reflect-metadata';
    
    import { Expose, Transform, Type } from 'class-transformer';
    
    import ArrayPoly from '../../polyfill/arrayPoly.js';
    Severity: Minor
    Found in src/types/dats/game.ts - About 7 hrs to fix

      Function getGameType has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

        getGameType(): GameType {
          // NOTE(cemmer): priority here matters!
          if (this.isBios()) {
            return GameType.BIOS;
          }
      Severity: Minor
      Found in src/types/dats/game.ts - About 3 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 getGameType has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        getGameType(): GameType {
          // NOTE(cemmer): priority here matters!
          if (this.isBios()) {
            return GameType.BIOS;
          }
      Severity: Major
      Found in src/types/dats/game.ts - About 2 hrs to fix

        Function getRegions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          getRegions(): string[] {
            const releaseRegions = this.getReleases().map((release) => release.getRegion().toUpperCase());
            if (releaseRegions.length > 0) {
              return releaseRegions;
            }
        Severity: Minor
        Found in src/types/dats/game.ts - About 35 mins 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

        Avoid too many return statements within this function.
        Open

              return GameType.CRACKED;
        Severity: Major
        Found in src/types/dats/game.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return GameType.HOMEBREW;
          Severity: Major
          Found in src/types/dats/game.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return GameType.TRAINED;
            Severity: Major
            Found in src/types/dats/game.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return GameType.RETAIL;
              Severity: Major
              Found in src/types/dats/game.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return [];
                Severity: Major
                Found in src/types/dats/game.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        return GameType.DEMO;
                  Severity: Major
                  Found in src/types/dats/game.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                          return GameType.PROGRAM;
                    Severity: Major
                    Found in src/types/dats/game.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                            return GameType.UNLICENSED;
                      Severity: Major
                      Found in src/types/dats/game.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              return GameType.DEVICE;
                        Severity: Major
                        Found in src/types/dats/game.ts - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                return GameType.PIRATED;
                          Severity: Major
                          Found in src/types/dats/game.ts - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                  return GameType.BETA;
                            Severity: Major
                            Found in src/types/dats/game.ts - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                    return GameType.DEBUG;
                              Severity: Major
                              Found in src/types/dats/game.ts - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                      return GameType.FIXED;
                                Severity: Major
                                Found in src/types/dats/game.ts - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                        return GameType.SAMPLE;
                                  Severity: Major
                                  Found in src/types/dats/game.ts - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                        return 0;
                                    Severity: Major
                                    Found in src/types/dats/game.ts - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                            return GameType.TRANSLATED;
                                      Severity: Major
                                      Found in src/types/dats/game.ts - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                              return GameType.PROTOTYPE;
                                        Severity: Major
                                        Found in src/types/dats/game.ts - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                return GameType.OVERDUMP;
                                          Severity: Major
                                          Found in src/types/dats/game.ts - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                  return GameType.HACKED;
                                            Severity: Major
                                            Found in src/types/dats/game.ts - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                    return GameType.BAD;
                                              Severity: Major
                                              Found in src/types/dats/game.ts - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                      return GameType.PENDING_DUMP;
                                                Severity: Major
                                                Found in src/types/dats/game.ts - About 30 mins to fix

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

                                                    @Expose()
                                                    @Type(() => Disk)
                                                    @Transform(({ value }) => value || [])
                                                    readonly disk?: Disk | Disk[];
                                                  Severity: Major
                                                  Found in src/types/dats/game.ts and 3 other locations - About 1 hr to fix
                                                  src/types/dats/game.ts on lines 123..126
                                                  src/types/dats/softwarelist/software.ts on lines 11..14
                                                  src/types/dats/softwarelist/softwareListDat.ts on lines 18..21

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

                                                  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

                                                    @Expose()
                                                    @Type(() => ROM)
                                                    @Transform(({ value }) => value || [])
                                                    readonly rom?: ROM | ROM[];
                                                  Severity: Major
                                                  Found in src/types/dats/game.ts and 3 other locations - About 1 hr to fix
                                                  src/types/dats/game.ts on lines 128..131
                                                  src/types/dats/softwarelist/software.ts on lines 11..14
                                                  src/types/dats/softwarelist/softwareListDat.ts on lines 18..21

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

                                                  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

                                                    hasHack(): boolean {
                                                      return this.name.match(/\(Hack\)/i) !== null || this.name.match(/\[h[a-zA-Z90-9+]*\]/) !== null;
                                                    }
                                                  Severity: Major
                                                  Found in src/types/dats/game.ts and 1 other location - About 1 hr to fix
                                                  src/types/dats/game.ts on lines 396..400

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

                                                  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

                                                    isPirated(): boolean {
                                                      return (
                                                        this.name.match(/\(Pirate[a-z0-9. ]*\)/i) !== null || this.name.match(/\[p[0-9]*\]/) !== null
                                                      );
                                                    }
                                                  Severity: Major
                                                  Found in src/types/dats/game.ts and 1 other location - About 1 hr to fix
                                                  src/types/dats/game.ts on lines 461..463

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

                                                  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 (versionMatches && versionMatches?.length >= 2 && !Number.isNaN(versionMatches[1])) {
                                                        return Number(versionMatches[1]);
                                                      }
                                                  Severity: Minor
                                                  Found in src/types/dats/game.ts and 1 other location - About 45 mins to fix
                                                  src/types/dats/game.ts on lines 236..238

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

                                                  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

                                                    isPrototype(): boolean {
                                                      return (
                                                        this.name.match(/\([^)]*Proto[a-z0-9. ]*\)/i) !== null ||
                                                        this.getCategory() === 'Preproduction'
                                                      );
                                                  Severity: Minor
                                                  Found in src/types/dats/game.ts and 1 other location - About 45 mins to fix
                                                  src/types/dats/game.ts on lines 405..410

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

                                                  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 (revNumberMatches && revNumberMatches?.length >= 2 && !Number.isNaN(revNumberMatches[1])) {
                                                        return Number(revNumberMatches[1]);
                                                      }
                                                  Severity: Minor
                                                  Found in src/types/dats/game.ts and 1 other location - About 45 mins to fix
                                                  src/types/dats/game.ts on lines 252..254

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

                                                  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

                                                    isProgram(): boolean {
                                                      return (
                                                        this.name.match(/\([a-z0-9. ]*Program\)|(Check|Sample) Program/i) !== null ||
                                                        this.getCategory() === 'Applications'
                                                      );
                                                  Severity: Minor
                                                  Found in src/types/dats/game.ts and 1 other location - About 45 mins to fix
                                                  src/types/dats/game.ts on lines 415..420

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

                                                  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

                                                  There are no issues that match your filters.

                                                  Category
                                                  Status