Showing 70 of 199 total issues

Function register has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.register = function(server, options, next) {

  server.route([
    {
      method: 'POST',
Severity: Minor
Found in api/lib/application/passwords/index.js - About 1 hr to fix

    Function deserialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      deserialize(airtableRecord) {
    
        const challenge = new Challenge();
    
        challenge.id = airtableRecord.id;
    Severity: Minor
    Found in api/lib/infrastructure/serializers/airtable/challenge-serializer.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

    Function create has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      create: (request, reply) => {
    
        const organization = organizationSerializer.deserialize(request.payload);
        const user = _extractUserInformation(request, organization);
    
    
    Severity: Minor
    Found in api/lib/application/organizations/organization-controller.js - About 1 hr to fix

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

        _serializeCompetenceIncluded(model, included) {
          model.competences.forEach((competence) => {
            const competenceData = {
              'id': competence.id,
              'type': 'competences',
      Severity: Minor
      Found in api/lib/infrastructure/serializers/jsonapi/profile-serializer.js - About 1 hr to fix

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

        function getScoreAndLevel(assessmentId) {
          let estimatedLevel = 0;
          let pixScore =0;
        
          return Promise.all([
        Severity: Minor
        Found in api/lib/domain/services/assessment-service.js - About 1 hr to fix

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

          exports.register = function(server, options, next) {
          
            server.route([
              {
                method: 'GET',
          Severity: Minor
          Found in api/lib/application/healthcheck/index.js - About 1 hr to fix

            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

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

              function _getCertificationResult(assessment) {
                let startOfCertificationDate;
              
                return Promise.all([assessment, answersRepository.findByAssessment(assessment.id)])
                  .then(([assessment, answersByAssessments]) => {
              Severity: Minor
              Found in api/lib/domain/services/certification-service.js - About 1 hr to fix

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

                  _resetValidationFields() {
                    const defaultValidationObject = {
                      lastName: {
                        status: 'default',
                        message: null
                Severity: Minor
                Found in live/app/components/signup-form.js - About 1 hr to fix

                  Function save has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    save(request, reply) {
                      const userId = request.auth.credentials.userId;
                      const accessCode = request.payload.data.attributes['access-code'];
                      return sessionService.sessionExists(accessCode)
                        .then((sessionId) => certificationService.startNewCertification(userId, sessionId))
                  Severity: Minor
                  Found in api/lib/application/courses/course-controller.js - About 1 hr to fix

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

                    function _applyTreatmentsToSolutions(solutions, deactivations) {
                      return _.mapValues(solutions, (validSolutions) => {
                        return _.map(validSolutions, (validSolution) => {
                          const pretreatedSolution = validSolution.toString();
                    
                    
                    Severity: Minor
                    Found in api/lib/domain/services/solution-service-qrocm-dep.js - About 1 hr to fix

                      Function save has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        save(request, reply) {
                      
                          if (_isRequestWronglyFormatted(request)) {
                            // FIXME: Should return a promise to be consistent
                            return reply(Boom.badRequest());
                      Severity: Minor
                      Found in api/lib/application/users/user-controller.js - About 1 hr to fix

                        Function deserialize has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          deserialize(airtableRecord) {
                        
                            const challenge = new Challenge();
                        
                            challenge.id = airtableRecord.id;
                        Severity: Minor
                        Found in api/lib/infrastructure/serializers/airtable/challenge-serializer.js - About 1 hr to fix

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

                          function _formatResult(scoring, validations, deactivations) {
                            let result = AnswerStatus.OK;
                          
                            const numberOfGoodAnswers = _numberOfGoodAnswers(validations, deactivations);
                          
                          
                          Severity: Minor
                          Found in api/lib/domain/services/solution-service-qrocm-dep.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 deserialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                            deserialize(airtableRecord) {
                              const course = new Course();
                          
                              course.id = airtableRecord.id;
                          
                          
                          Severity: Minor
                          Found in api/lib/infrastructure/serializers/airtable/course-serializer.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

                          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

                              Function saveAnswerAndNavigate has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  saveAnswerAndNavigate(challenge, assessment, answerValue, answerTimeout, answerElapsedTime) {
                              Severity: Minor
                              Found in live/app/routes/assessments/challenge.js - About 35 mins to fix

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

                                  register(server, options, next) {
                                
                                    server.on('response', (request) => {
                                
                                      const responseDuration = request.info.responded - request.info.received;
                                Severity: Minor
                                Found in api/lib/infrastructure/plugins/metrics.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 _.chain(definedUserAnswers) // [false, true]
                                    .concat(arrayOfFalse)     // [false, true, false, false]
                                    .zip(proposals)           // [[false, 'prop 1'], [true, 'prop 2'], [false, 'prop 3'], [false, 'prop 4']]
                                    .map(_.reverse)           // [['prop 1', false], ['prop 2', true], ['prop 3', false], ['prop 4', false]]
                                    .value();
                                Severity: Major
                                Found in live/app/utils/labeled-checkboxes.js - About 30 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language