emmercm/igir

View on GitHub
src/types/options.ts

Summary

Maintainability
F
4 days
Test Coverage

Options has 124 functions (exceeds 20 allowed). Consider refactoring.
Wontfix

export default class Options implements OptionsProps {
  @Expose({ name: '_' })
  readonly commands: string[];

  readonly input: string[];
Severity: Major
Found in src/types/options.ts - About 2 days to fix

    File options.ts has 900 lines of code (exceeds 250 allowed). Consider refactoring.
    Wontfix

    import 'reflect-metadata';
    
    import os from 'node:os';
    import path from 'node:path';
    
    
    Severity: Major
    Found in src/types/options.ts - About 2 days to fix

      Function constructor has 93 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        constructor(options?: OptionsProps) {
          this.commands = options?.commands ?? [];
      
          this.input = options?.input ?? [];
          this.inputExclude = options?.inputExclude ?? [];
      Severity: Major
      Found in src/types/options.ts - About 3 hrs to fix

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

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

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

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

            Function scanPaths has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

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

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

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

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

              private static async sanitizeGlobPattern(globPattern: string): Promise<string> {
                const pathsSplit = globPattern.split(/[\\/]/);
                for (let i = 0; i < pathsSplit.length; i += 1) {
                  const subPath = pathsSplit.slice(0, i + 1).join('/');
                  if (subPath !== '' && !(await fsPoly.exists(subPath))) {
            Severity: Minor
            Found in src/types/options.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 [];
            Severity: Major
            Found in src/types/options.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

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

                Avoid too many return statements within this function.
                Open

                    return paths;
                Severity: Major
                Found in src/types/options.ts - About 30 mins to fix

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

                    getInputChecksumMax(): ChecksumBitmask | undefined {
                      const checksumBitmask = Object.keys(ChecksumBitmask).find(
                        (bitmask) => bitmask.toUpperCase() === this.inputChecksumMax?.toUpperCase(),
                      );
                      if (!checksumBitmask) {
                  Severity: Major
                  Found in src/types/options.ts and 5 other locations - About 2 hrs to fix
                  src/types/options.ts on lines 771..779
                  src/types/options.ts on lines 915..923
                  src/types/options.ts on lines 925..933
                  src/types/options.ts on lines 1028..1036
                  src/types/options.ts on lines 1208..1216

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

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

                    getDirGameSubdir(): GameSubdirMode | undefined {
                      const subdirMode = Object.keys(GameSubdirMode).find(
                        (mode) => mode.toLowerCase() === this.dirGameSubdir?.toLowerCase(),
                      );
                      if (!subdirMode) {
                  Severity: Major
                  Found in src/types/options.ts and 5 other locations - About 2 hrs to fix
                  src/types/options.ts on lines 771..779
                  src/types/options.ts on lines 781..789
                  src/types/options.ts on lines 925..933
                  src/types/options.ts on lines 1028..1036
                  src/types/options.ts on lines 1208..1216

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

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

                    getMergeRoms(): MergeMode | undefined {
                      const mergeMode = Object.keys(MergeMode).find(
                        (mode) => mode.toLowerCase() === this.mergeRoms?.toLowerCase(),
                      );
                      if (!mergeMode) {
                  Severity: Major
                  Found in src/types/options.ts and 5 other locations - About 2 hrs to fix
                  src/types/options.ts on lines 771..779
                  src/types/options.ts on lines 781..789
                  src/types/options.ts on lines 915..923
                  src/types/options.ts on lines 925..933
                  src/types/options.ts on lines 1208..1216

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

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

                    getInputChecksumMin(): ChecksumBitmask | undefined {
                      const checksumBitmask = Object.keys(ChecksumBitmask).find(
                        (bitmask) => bitmask.toUpperCase() === this.inputChecksumMin?.toUpperCase(),
                      );
                      if (!checksumBitmask) {
                  Severity: Major
                  Found in src/types/options.ts and 5 other locations - About 2 hrs to fix
                  src/types/options.ts on lines 781..789
                  src/types/options.ts on lines 915..923
                  src/types/options.ts on lines 925..933
                  src/types/options.ts on lines 1028..1036
                  src/types/options.ts on lines 1208..1216

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

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

                    getFixExtension(): FixExtension | undefined {
                      const fixExtensionMode = Object.keys(FixExtension).find(
                        (mode) => mode.toLowerCase() === this.fixExtension?.toLowerCase(),
                      );
                      if (!fixExtensionMode) {
                  Severity: Major
                  Found in src/types/options.ts and 5 other locations - About 2 hrs to fix
                  src/types/options.ts on lines 771..779
                  src/types/options.ts on lines 781..789
                  src/types/options.ts on lines 915..923
                  src/types/options.ts on lines 1028..1036
                  src/types/options.ts on lines 1208..1216

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

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

                    getPreferRevision(): PreferRevision | undefined {
                      const preferRevision = Object.keys(PreferRevision).find(
                        (mode) => mode.toLowerCase() === this.preferRevision?.toLowerCase(),
                      );
                      if (!preferRevision) {
                  Severity: Major
                  Found in src/types/options.ts and 5 other locations - About 2 hrs to fix
                  src/types/options.ts on lines 771..779
                  src/types/options.ts on lines 781..789
                  src/types/options.ts on lines 915..923
                  src/types/options.ts on lines 925..933
                  src/types/options.ts on lines 1028..1036

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

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

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

                    async scanPatchFilesWithoutExclusions(walkCallback?: FsWalkCallback): Promise<string[]> {
                      const patchFiles = await this.scanPatchFiles(walkCallback);
                      const patchExcludeFiles = new Set(await this.scanPatchExcludeFiles());
                      return patchFiles.filter((patchPath) => !patchExcludeFiles.has(patchPath));
                    }
                  Severity: Major
                  Found in src/types/options.ts and 2 other locations - About 2 hrs to fix
                  src/types/options.ts on lines 642..646
                  src/types/options.ts on lines 819..823

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

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

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

                    async scanInputFilesWithoutExclusions(walkCallback?: FsWalkCallback): Promise<string[]> {
                      const inputFiles = await this.scanInputFiles(walkCallback);
                      const inputExcludeFiles = new Set(await this.scanInputExcludeFiles());
                      return inputFiles.filter((inputPath) => !inputExcludeFiles.has(inputPath));
                    }
                  Severity: Major
                  Found in src/types/options.ts and 2 other locations - About 2 hrs to fix
                  src/types/options.ts on lines 819..823
                  src/types/options.ts on lines 856..860

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

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

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

                    async scanDatFilesWithoutExclusions(walkCallback?: FsWalkCallback): Promise<string[]> {
                      const datFiles = await this.scanDatFiles(walkCallback);
                      const datExcludeFiles = new Set(await this.scanDatExcludeFiles());
                      return datFiles.filter((inputPath) => !datExcludeFiles.has(inputPath));
                    }
                  Severity: Major
                  Found in src/types/options.ts and 2 other locations - About 2 hrs to fix
                  src/types/options.ts on lines 642..646
                  src/types/options.ts on lines 856..860

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

                  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

                  There are no issues that match your filters.

                  Category
                  Status