wkdhkr/dedupper

View on GitHub
src/services/judgment/JudgmentService.js

Summary

Maintainability
C
1 day
Test Coverage

Function detect has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async detect(
    fileInfo: FileInfo,
    storedFileInfoByHash: ?HashRow,
    storedFileInfoByPHashs: HashRow[],
    storedFileInfoByNames: HashRow[] = []
Severity: Major
Found in src/services/judgment/JudgmentService.js - About 2 hrs to fix

    Function detect has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

      async detect(
        fileInfo: FileInfo,
        storedFileInfoByHash: ?HashRow,
        storedFileInfoByPHashs: HashRow[],
        storedFileInfoByNames: HashRow[] = []
    Severity: Minor
    Found in src/services/judgment/JudgmentService.js - 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

    Avoid too many return statements within this function.
    Open

          return this.rl.logResult(fileInfo, [TYPE_HOLD, null, TYPE_DEEP_LEARNING]);
    Severity: Major
    Found in src/services/judgment/JudgmentService.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return this.rl.logResult(fileInfo, [TYPE_SAVE, null, TYPE_NO_PROBLEM]);
      Severity: Major
      Found in src/services/judgment/JudgmentService.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              return this.phl.handlePHashHit(fileInfo, storedFileInfoByPHashs);
        Severity: Major
        Found in src/services/judgment/JudgmentService.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return judgeResult;
          Severity: Major
          Found in src/services/judgment/JudgmentService.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return this.rl.logResult(fileInfo, [
                    this.al.fixAction(!this.config.instantDelete, TYPE_DELETE),
                    null,
                    deleteReason
                  ]);
            Severity: Major
            Found in src/services/judgment/JudgmentService.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return this.rl.logResult(fileInfo, [
                        this.config.deepLearningConfig.instantDelete
                          ? TYPE_DELETE
                          : TYPE_HOLD,
                        null,
              Severity: Major
              Found in src/services/judgment/JudgmentService.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return this.pl.handleNameHit(fileInfo, storedFileInfoByNames);
                Severity: Major
                Found in src/services/judgment/JudgmentService.js - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status