Dulce-Work-Schedule/2018.1-Dulce_Schedule

View on GitHub
Client/api.js

Summary

Maintainability
F
1 wk
Test Coverage

Function api has 308 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function api(options){

//#############################################################################
  this.add('role:api,path:createSchedule', function(msg, respond){
    // result variable store attribute errors or the success created schedule
Severity: Major
Found in Client/api.js - About 1 day to fix

    File api.js has 344 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    
    currentWeekNumber = require('current-week-number');
    
    // The RegExp Object above validates MongoBD ObjectIds
    function IsInvalidObjectId(objectIdString){
    Severity: Minor
    Found in Client/api.js - About 4 hrs to fix

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

        String.prototype.format = function(){
          var replaceable_count = (this.match(/{}/g) || []).length;
          if(arguments.length < replaceable_count){
            console.log(
              "Expecting " + replaceable_count + "arguments, " +
      Severity: Minor
      Found in Client/api.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

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

        this.add('role:api,path:listYearByUser', function (msg, respond) {
          console.log(msg.args)
          var currentDate = new Date();
          var year = msg.args.query.year;
          if (year == undefined || year == "Invalid Date") {
      Severity: Major
      Found in Client/api.js and 1 other location - About 1 day to fix
      Client/api.js on lines 302..322

      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 219.

      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

        this.add('role:api,path:listYearBySector', function (msg, respond) {
          console.log(msg.args)
          var currentDate = new Date();
          var year = msg.args.query.year;
          if (year == undefined || year == "Invalid Date") {
      Severity: Major
      Found in Client/api.js and 1 other location - About 1 day to fix
      Client/api.js on lines 352..372

      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 219.

      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

          if(isNaN(max_hours_month)){
            result.max_hours_month_NaN_error = 'O máximo de horas por mês deve ser um valor inteiro positivo';
            console.log(result.max_hours_month_NaN_error);
          } else if(max_hours_month <= 0){
            result.max_hours_month_negative_number_error = 'O máximo de horas por mês deve ser um valor positivo maior que zero';
      Severity: Major
      Found in Client/api.js and 3 other locations - About 4 hrs to fix
      Client/api.js on lines 156..165
      Client/api.js on lines 190..199
      Client/api.js on lines 202..211

      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 121.

      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

          if(isNaN(max_hours_week)){
            result.max_hours_week_NaN_error = 'O máximo de horas por semana deve ser um valor inteiro positivo';
            console.log(result.max_hours_week_NaN_error);
          } else if(max_hours_week <= 0){
            result.max_hours_week_negative_number_error = 'O máximo de horas por semana deve ser um valor positivo maior que zero';
      Severity: Major
      Found in Client/api.js and 3 other locations - About 4 hrs to fix
      Client/api.js on lines 156..165
      Client/api.js on lines 178..187
      Client/api.js on lines 202..211

      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 121.

      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

          if(isNaN(min_hours_month)){
            result.min_hours_month_NaN_error = 'O mínimo de horas por mês deve ser um valor inteiro positivo';
            console.log(result.min_hours_month_NaN_error);
          } else if(min_hours_month <= 0){
            result.min_hours_month_negative_number_error = 'O mínimo de horas por mês deve ser um valor positivo maior que zero';
      Severity: Major
      Found in Client/api.js and 3 other locations - About 4 hrs to fix
      Client/api.js on lines 156..165
      Client/api.js on lines 178..187
      Client/api.js on lines 190..199

      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 121.

      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

          if(isNaN(max_hours_day)){
            result.max_hours_day_NaN_error = 'O máximo de horas por dia deve ser um valor inteiro positivo';
            console.log(result.max_hours_day_NaN_error);
          } else if(max_hours_day <= 0){
            result.max_hours_day_negative_number_error = 'O máximo de horas por dia deve ser um valor positivo maior que zero';
      Severity: Major
      Found in Client/api.js and 3 other locations - About 4 hrs to fix
      Client/api.js on lines 178..187
      Client/api.js on lines 190..199
      Client/api.js on lines 202..211

      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 121.

      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

          if(arguments.length < replaceable_count){
            console.log(
              "Expecting " + replaceable_count + "arguments, " +
              arguments.length + 'found.');
            return this
      Severity: Major
      Found in Client/api.js and 1 other location - About 3 hrs to fix
      Server/plg_schedule.js on lines 30..41

      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 104.

      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

          if (sector_id == null || sector_id == "") {
            result.sector_id_error = 'O setor é obrigatório';
            console.log(result.sector_id_error);
          } else if (IsInvalidObjectId(sector_id)) {
            result.invalid_sector_id_error = 'sector_id inválido'
      Severity: Major
      Found in Client/api.js and 1 other location - About 1 hr to fix
      Client/api.js on lines 95..100

      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 72.

      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

          if (profile_id == null || profile_id == "") {
            result.profile_id_error = 'O usuário é obrigatório';
            console.log(result.profile_id_error);
          } else if (IsInvalidObjectId(profile_id)) {
            result.invalid_profile_id_error = 'profile_id inválido'
      Severity: Major
      Found in Client/api.js and 1 other location - About 1 hr to fix
      Client/api.js on lines 87..92

      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 72.

      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 get_schedule_duration( start_time, end_time){
        // The diference between Dates are given in milliseconds.
        // So we divide by the amount of milliseconds in 1 hour
        console.log(start_time);
        console.log(end_time);
      Severity: Major
      Found in Client/api.js and 1 other location - About 1 hr to fix
      Server/plg_schedule.js on lines 11..22

      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 66.

      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

          if (msg.args.body.start_time == null) {
            result.start_time_null_error = 'Horário inicial não pode ser nulo';
            console.log(result.start_time_null_error);
          } else {
            start_time = new Date(msg.args.body.start_time);
      Severity: Major
      Found in Client/api.js and 1 other location - About 1 hr to fix
      Client/api.js on lines 75..84

      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 64.

      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

          if (msg.args.body.end_time == null) {
            result.end_time_null_error = 'Horário final não pode ser nulo';
            console.log(result.end_time_null_error);
          } else {
            end_time = new Date(msg.args.body.end_time);
      Severity: Major
      Found in Client/api.js and 1 other location - About 1 hr to fix
      Client/api.js on lines 64..73

      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 64.

      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

      There are no issues that match your filters.

      Category
      Status