Showing 199 of 199 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

  get(challengeId) {
    return new Promise((resolve, reject) => {
      const cacheKey = `solution-repository_get_${challengeId}`;
      cache.get(cacheKey, (err, cachedValue) => {
        if (err) return reject(err);
Severity: Major
Found in api/lib/infrastructure/repositories/solution-repository.js and 2 other locations - About 2 hrs to fix
api/lib/infrastructure/repositories/challenge-repository.js on lines 54..63
api/lib/infrastructure/repositories/course-repository.js on lines 60..69

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 90.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

function _replyWithAuthenticationError(reply) {
  return Promise.resolve().then(() => {
    const errorHttpStatusCode = 401;

    const jsonApiError = new JSONAPIError({
Severity: Major
Found in api/lib/interfaces/controllers/security-controller.js and 1 other location - About 2 hrs to fix
api/lib/interfaces/controllers/security-controller.js on lines 21..33

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 88.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

function _replyWithAuthorizationError(reply) {
  return Promise.resolve().then(() => {
    const errorHttpStatusCode = 403;

    const jsonApiError = new JSONAPIError({
Severity: Major
Found in api/lib/interfaces/controllers/security-controller.js and 1 other location - About 2 hrs to fix
api/lib/interfaces/controllers/security-controller.js on lines 7..19

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 88.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

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

  server.route([

    {
Severity: Major
Found in api/lib/application/assessments/index.js - About 2 hrs to fix

    Function exports has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = (function() {
    
      const config = {
        rootPath: path.normalize(__dirname + '/..'),
    
    
    Severity: Major
    Found in api/lib/settings.js - About 2 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              answer.challenge.skills.forEach(skill => {
                skill.getEasierWithin(this.course.tubes).forEach(validatedSkill => {
                  if(!skills.includes(validatedSkill))
                    skills.push(validatedSkill);
                });
      Severity: Major
      Found in api/lib/cat/assessment.js and 1 other location - About 2 hrs to fix
      api/lib/cat/assessment.js on lines 107..112

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 82.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              answer.challenge.skills.forEach(skill => {
                skill.getHarderWithin(this.course.tubes).forEach(failedSkill => {
                  if(!failedSkills.includes(failedSkill))
                    failedSkills.push(failedSkill);
                });
      Severity: Major
      Found in api/lib/cat/assessment.js and 1 other location - About 2 hrs to fix
      api/lib/cat/assessment.js on lines 90..95

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 82.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

      exports.register = function(server, options, next) {
      
        server.route([
          {
            method: 'POST',
      Severity: Major
      Found in api/lib/application/users/index.js - About 2 hrs to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          addSkill(newSkill) {
            const hasAlreadySkill = _(this.skills).filter(skill => skill.name === newSkill.name).size();
        
            if(!hasAlreadySkill) {
              this.skills.push(newSkill);
        Severity: Major
        Found in api/lib/domain/models/UserCompetence.js and 1 other location - About 2 hrs to fix
        api/lib/domain/models/UserCompetence.js on lines 21..27

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 79.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          addChallenge(newChallenge) {
            const hasAlreadyChallenge = _(this.challenges).filter(challenge => challenge.id === newChallenge.id).size();
        
            if(!hasAlreadyChallenge) {
              this.challenges.push(newChallenge);
        Severity: Major
        Found in api/lib/domain/models/UserCompetence.js and 1 other location - About 2 hrs to fix
        api/lib/domain/models/UserCompetence.js on lines 13..19

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 79.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Assessment has 21 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Assessment {
          constructor(course, answers) {
            this.course = course;
            this.answers = answers;
          }
        Severity: Minor
        Found in api/lib/cat/assessment.js - About 2 hrs to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            refresh(id) {
              return new Promise((resolve, reject) => {
                const cacheKey = `course-repository_get_${id}`;
                cache.del(cacheKey, (err) => {
                  if (err) return reject(err);
          Severity: Major
          Found in api/lib/infrastructure/repositories/course-repository.js and 1 other location - About 2 hrs to fix
          api/lib/infrastructure/repositories/solution-repository.js on lines 29..37

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 78.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            refresh(challengeId) {
              return new Promise((resolve, reject) => {
                const cacheKey = `solution-repository_get_${challengeId}`;
                cache.del(cacheKey, (err) => {
                  if (err) return reject(err);
          Severity: Major
          Found in api/lib/infrastructure/repositories/solution-repository.js and 1 other location - About 2 hrs to fix
          api/lib/infrastructure/repositories/course-repository.js on lines 71..79

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 78.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          File assessment-service.js has 255 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          const courseRepository = require('../../infrastructure/repositories/course-repository');
          const certificationCourseRepository = require('../../infrastructure/repositories/certification-course-repository');
          const answerRepository = require('../../infrastructure/repositories/answer-repository');
          const assessmentRepository = require('../../infrastructure/repositories/assessment-repository');
          const certificationChallengeRepository = require('../../infrastructure/repositories/certification-challenge-repository');
          Severity: Minor
          Found in api/lib/domain/services/assessment-service.js - About 2 hrs to fix

            Similar blocks of code found in 4 locations. Consider refactoring.
            Open

            exports.register = function(server, options, next) {
            
              server.route([
                {
                  method: 'GET',
            Severity: Major
            Found in api/lib/application/simulateErrors/index.js and 3 other locations - About 2 hrs to fix
            api/lib/application/authentication/index.js on lines 3..18
            api/lib/application/followers/index.js on lines 3..18
            api/lib/application/metrics/index.js on lines 3..17

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 76.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 4 locations. Consider refactoring.
            Open

            exports.register = function(server, options, next) {
            
              server.route([
                {
                  method: 'GET',
            Severity: Major
            Found in api/lib/application/metrics/index.js and 3 other locations - About 2 hrs to fix
            api/lib/application/authentication/index.js on lines 3..18
            api/lib/application/followers/index.js on lines 3..18
            api/lib/application/simulateErrors/index.js on lines 3..18

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 76.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 4 locations. Consider refactoring.
            Open

            exports.register = function(server, options, next) {
            
              server.route([
                {
                  method: 'POST',
            Severity: Major
            Found in api/lib/application/followers/index.js and 3 other locations - About 2 hrs to fix
            api/lib/application/authentication/index.js on lines 3..18
            api/lib/application/metrics/index.js on lines 3..17
            api/lib/application/simulateErrors/index.js on lines 3..18

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 76.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 4 locations. Consider refactoring.
            Open

            exports.register = function(server, options, next) {
            
              server.route([
                {
                  method: 'POST',
            Severity: Major
            Found in api/lib/application/authentication/index.js and 3 other locations - About 2 hrs to fix
            api/lib/application/followers/index.js on lines 3..18
            api/lib/application/metrics/index.js on lines 3..17
            api/lib/application/simulateErrors/index.js on lines 3..18

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 76.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            function extractFilters(request) {
              return _.reduce(request.query, (result, queryFilterValue, queryFilterKey) => {
                const field = queryFilterKey.match(/filter\[([a-zA-Z]*)]/)[1];
                if (field) {
                  result[field] = queryFilterValue;
            Severity: Major
            Found in api/lib/infrastructure/utils/query-params-utils.js and 1 other location - About 2 hrs to fix
            api/lib/application/organizations/organization-controller.js on lines 148..156

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 75.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            function _extractFilters(request) {
              return _.reduce(request.query, (result, queryFilterValue, queryFilterKey) => {
                const field = queryFilterKey.match(/filter\[([a-z]*)]/)[1];
                if (field) {
                  result[field] = queryFilterValue;
            Severity: Major
            Found in api/lib/application/organizations/organization-controller.js and 1 other location - About 2 hrs to fix
            api/lib/infrastructure/utils/query-params-utils.js on lines 3..11

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 75.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Severity
            Category
            Status
            Source
            Language