wkdhkr/dedupper

View on GitHub
src/services/ProcessService.js

Summary

Maintainability
D
2 days
Test Coverage

File ProcessService.js has 495 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// @flow
import maxListenersExceededWarning from "max-listeners-exceeded-warning";
import events from "events";
import typeof { Logger } from "log4js";
import pLimit from "p-limit";
Severity: Minor
Found in src/services/ProcessService.js - About 7 hrs to fix

    ProcessService has 29 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class ProcessService {
      log: Logger;
    
      config: Config;
    
    
    Severity: Minor
    Found in src/services/ProcessService.js - About 3 hrs to fix

      Function processRegularFile has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async processRegularFile(preferFileInfo?: FileInfo): Promise<boolean> {
          const fileInfo =
            preferFileInfo || (await this.fileService.collectFileInfo());
          try {
            await this.lockForRead(fileInfo);
      Severity: Minor
      Found in src/services/ProcessService.js - About 1 hr to fix

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

          constructor(config: Config, path: string, isParent: boolean = true) {
            let { dryrun } = config;
            if (EnvironmentHelper.isTest()) {
              maxListenersExceededWarning();
              dryrun = true;
        Severity: Minor
        Found in src/services/ProcessService.js - About 1 hr to fix

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

            async processAction(
              fileInfo: FileInfo,
              result: JudgeResult
            ): Promise<boolean> {
              const [action, , reason, results] = result;
          Severity: Minor
          Found in src/services/ProcessService.js - About 1 hr to fix

            Function processImportedFile has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async processImportedFile(): Promise<boolean> {
                const sourcePath = this.fileService.getSourcePath();
                const toPath = FileNameMarkHelper.strip(sourcePath);
                const type = AttributeService.detectClassifyTypeByConfig(this.config);
                if (this.fileService.isLibraryPlace(toPath) === false) {
            Severity: Minor
            Found in src/services/ProcessService.js - About 1 hr to fix

              Function process has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                async process(): Promise<boolean> {
                  let result;
                  if (await this.fileService.isDirectory()) {
                    result = (await this.processDirectory()).every(Boolean);
                  } else {
              Severity: Minor
              Found in src/services/ProcessService.js - About 55 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 processRegularFile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                async processRegularFile(preferFileInfo?: FileInfo): Promise<boolean> {
                  const fileInfo =
                    preferFileInfo || (await this.fileService.collectFileInfo());
                  try {
                    await this.lockForRead(fileInfo);
              Severity: Minor
              Found in src/services/ProcessService.js - 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 processFile has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                async processFile(): Promise<boolean> {
                  if (QueueHelper.operationWaitPromises.length > 100) {
                    await QueueHelper.waitOperationWaitPromises();
                  }
                  await ProcessHelper.waitCpuIdle(this.config.maxCpuLoadPercent);
              Severity: Minor
              Found in src/services/ProcessService.js - 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 false;
              Severity: Major
              Found in src/services/ProcessService.js - About 30 mins to fix

                There are no issues that match your filters.

                Category
                Status