api/lib/domain/services/solution-service-qroc.js

Summary

Maintainability
D
1 day
Test Coverage

Function _formatResult has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

function _formatResult(validations, deactivations) {

  if (deactivationsService.isDefault(deactivations)) {
    if (validations.t1t2t3Ratio <= 0.25) {
      return AnswerStatus.OK;
Severity: Minor
Found in api/lib/domain/services/solution-service-qroc.js - 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 _formatResult has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function _formatResult(validations, deactivations) {

  if (deactivationsService.isDefault(deactivations)) {
    if (validations.t1t2t3Ratio <= 0.25) {
      return AnswerStatus.OK;
Severity: Minor
Found in api/lib/domain/services/solution-service-qroc.js - About 1 hr to fix

    Function '_formatResult' has too many statements (25). Maximum allowed is 20.
    Open

    function _formatResult(validations, deactivations) {

    enforce a maximum number of statements allowed in function blocks (max-statements)

    The max-statements rule allows you to specify the maximum number of statements allowed in a function.

    function foo() {
      var bar = 1; // one statement
      var baz = 2; // two statements
      var qux = 3; // three statements
    }

    Rule Details

    This rule enforces a maximum number of statements allowed in function blocks.

    Options

    This rule has a number or object option:

    • "max" (default 10) enforces a maximum number of statements allows in function blocks

    Deprecated: The object property maximum is deprecated; please use the object property max instead.

    This rule has an object option:

    • "ignoreTopLevelFunctions": true ignores top-level functions

    max

    Examples of incorrect code for this rule with the default { "max": 10 } option:

    /*eslint max-statements: ["error", 10]*/
    /*eslint-env es6*/
    
    function foo() {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
    
      var foo11 = 11; // Too many.
    }
    
    let foo = () => {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
    
      var foo11 = 11; // Too many.
    };

    Examples of correct code for this rule with the default { "max": 10 } option:

    /*eslint max-statements: ["error", 10]*/
    /*eslint-env es6*/
    
    function foo() {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
      return function () {
    
        // The number of statements in the inner function does not count toward the
        // statement maximum.
    
        return 42;
      };
    }
    
    let foo = () => {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
      return function () {
    
        // The number of statements in the inner function does not count toward the
        // statement maximum.
    
        return 42;
      };
    }

    ignoreTopLevelFunctions

    Examples of additional correct code for this rule with the { "max": 10 }, { "ignoreTopLevelFunctions": true } options:

    /*eslint max-statements: ["error", 10, { "ignoreTopLevelFunctions": true }]*/
    
    function foo() {
      var foo1 = 1;
      var foo2 = 2;
      var foo3 = 3;
      var foo4 = 4;
      var foo5 = 5;
      var foo6 = 6;
      var foo7 = 7;
      var foo8 = 8;
      var foo9 = 9;
      var foo10 = 10;
      var foo11 = 11;
    }

    Related Rules

    • [complexity](complexity.md)
    • [max-depth](max-depth.md)
    • [max-len](max-len.md)
    • [max-nested-callbacks](max-nested-callbacks.md)
    • [max-params](max-params.md) Source: http://eslint.org/docs/rules/

    Function _applyTreatmentsToSolutions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function _applyTreatmentsToSolutions(solution, deactivations) {
      const pretreatedSolutions = _applyPreTreatmentsToSolutions(solution);
      return _.map(pretreatedSolutions, (pretreatedSolution) => {
    
        if (deactivationsService.isDefault(deactivations)) {
    Severity: Minor
    Found in api/lib/domain/services/solution-service-qroc.js - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

        else if (deactivationsService.hasOnlyT1T2(deactivations)) {
          if (validations.t3Ratio <= 0.25) {
            return AnswerStatus.OK;
          }
          return AnswerStatus.KO;
      Severity: Major
      Found in api/lib/domain/services/solution-service-qroc.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

            if (_.includes(validations.adminAnswers, validations.t1t2)) {
              return AnswerStatus.OK;
            }
        Severity: Major
        Found in api/lib/domain/services/solution-service-qroc.js - About 45 mins to fix

          Avoid too many return statements within this function.
          Open

                return AnswerStatus.OK;
          Severity: Major
          Found in api/lib/domain/services/solution-service-qroc.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return AnswerStatus.KO;
            Severity: Major
            Found in api/lib/domain/services/solution-service-qroc.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return AnswerStatus.KO;
              Severity: Major
              Found in api/lib/domain/services/solution-service-qroc.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return AnswerStatus.KO;
                Severity: Major
                Found in api/lib/domain/services/solution-service-qroc.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        return pretreatedSolution;
                  Severity: Major
                  Found in api/lib/domain/services/solution-service-qroc.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                          return t1(pretreatedSolution);
                    Severity: Major
                    Found in api/lib/domain/services/solution-service-qroc.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                            return AnswerStatus.OK;
                      Severity: Major
                      Found in api/lib/domain/services/solution-service-qroc.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              return AnswerStatus.OK;
                        Severity: Major
                        Found in api/lib/domain/services/solution-service-qroc.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                return t2(pretreatedSolution);
                          Severity: Major
                          Found in api/lib/domain/services/solution-service-qroc.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                return AnswerStatus.KO;
                            Severity: Major
                            Found in api/lib/domain/services/solution-service-qroc.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                    return pretreatedSolution;
                              Severity: Major
                              Found in api/lib/domain/services/solution-service-qroc.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                      return AnswerStatus.OK;
                                Severity: Major
                                Found in api/lib/domain/services/solution-service-qroc.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                      return AnswerStatus.KO;
                                  Severity: Major
                                  Found in api/lib/domain/services/solution-service-qroc.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                        return AnswerStatus.KO;
                                    Severity: Major
                                    Found in api/lib/domain/services/solution-service-qroc.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                            return AnswerStatus.OK;
                                      Severity: Major
                                      Found in api/lib/domain/services/solution-service-qroc.js - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                              return AnswerStatus.OK;
                                        Severity: Major
                                        Found in api/lib/domain/services/solution-service-qroc.js - About 30 mins to fix

                                          There are no issues that match your filters.

                                          Category
                                          Status