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',
Function deserialize
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
deserialize(airtableRecord) {
const challenge = new Challenge();
challenge.id = airtableRecord.id;
- Read upRead up
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);
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',
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([
Function register
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.register = function(server, options, next) {
server.route([
{
method: 'GET',
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)) {
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]) => {
Function _resetValidationFields
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
_resetValidationFields() {
const defaultValidationObject = {
lastName: {
status: 'default',
message: null
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))
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();
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());
Function deserialize
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
deserialize(airtableRecord) {
const challenge = new Challenge();
challenge.id = airtableRecord.id;
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);
- Read upRead up
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;
- Read upRead up
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;
Avoid deeply nested control flow statements. Open
if (_.includes(validations.adminAnswers, validations.t1t2)) {
return AnswerStatus.OK;
}
Function saveAnswerAndNavigate
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
saveAnswerAndNavigate(challenge, assessment, answerValue, answerTimeout, answerElapsedTime) {
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;
- Read upRead up
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();