gadael/gadael

View on GitHub

Showing 761 of 761 total issues

Function exports has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

exports = module.exports = function(services, app) {

    let service = new services.list(app);

    let collaborators = {};
Severity: Minor
Found in api/services/user/collaborators/list.js - About 5 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

File save.js has 397 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

const saveAbsence = require('./../../user/requests/saveAbsence');
const Services = require('restitute').service;
const util = require('util');
Severity: Minor
Found in api/services/admin/compulsoryleaves/save.js - About 5 hrs to fix

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

            service.app.db.models.Calendar.findById(params.id)
            .then(document => {
    
                if (document.locked) {
                    return service.forbidden(gt.gettext('The calendar is locked'));
    Severity: Major
    Found in api/services/admin/calendars/delete.js and 1 other location - About 5 hrs to fix
    api/services/admin/types/delete.js on lines 20..36

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

    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

            service.app.db.models.Type.findById(params.id)
            .then(document => {
    
                if (document.locked) {
                    return service.forbidden(gt.gettext('This type is locked'));
    Severity: Major
    Found in api/services/admin/types/delete.js and 1 other location - About 5 hrs to fix
    api/services/admin/calendars/delete.js on lines 20..36

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

    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

    var query = function(service, params) {
    
        var find = service.app.db.models.AccountNWDaysCalendar.find();
        find.populate('calendar');
    
    
    Severity: Major
    Found in api/services/admin/accountnwdayscalendars/list.js and 1 other location - About 5 hrs to fix
    api/services/admin/accountschedulecalendars/list.js on lines 14..30

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

    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

    var query = function(service, params) {
    
        var find = service.app.db.models.AccountScheduleCalendar.find();
        find.populate('calendar');
    
    
    Severity: Major
    Found in api/services/admin/accountschedulecalendars/list.js and 1 other location - About 5 hrs to fix
    api/services/admin/accountnwdayscalendars/list.js on lines 14..30

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

    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 createRenewalChart has 127 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        return function createRenewalChart(gettextCatalog, $filter) {
    
            return function renewalChart($scope, beneficiariesResource)
            {
                $scope.renewalChart = {
    Severity: Major
    Found in public/js/services/renewalChart.js - About 5 hrs to fix

      Function renewalChart has 124 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              return function renewalChart($scope, beneficiariesResource)
              {
                  $scope.renewalChart = {
      
                      availableHours: 0,
      Severity: Major
      Found in public/js/services/renewalChart.js - About 4 hrs to fix

        File saveAbsence.js has 372 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        'use strict';
        
        const util = require('util');
        
        
        
        Severity: Minor
        Found in api/services/user/requests/saveAbsence.js - About 4 hrs to fix

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

          exports = module.exports = function(services, app)
          {
          
              var service = new services.list(app);
          
          
          Severity: Major
          Found in api/services/account/accountrights/list.js - About 4 hrs to fix

            Function exports has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
            Open

            exports = module.exports = function(services, app) {
            
                var service = new services.list(app);
            
                /**
            Severity: Minor
            Found in api/services/user/calendarevents/list.js - About 4 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 exports has 121 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            exports = module.exports = function(params) {
                var collectionSchema = new params.mongoose.Schema({
                    name: { type: String, required: true, unique: true  },
                    timeCreated: { type: Date, default: Date.now },
                    attendance: { type: Number, min: 0, max: 100, default: 100 },   // attendance percentage
            Severity: Major
            Found in schema/RightCollection.js - About 4 hrs to fix

              Function site has 120 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              exports = module.exports = function site(languageCode) {
              
                  let headers = {};
                  let sessionCookie;
              
              
              Severity: Major
              Found in doc/create_screenshots/site.js - About 4 hrs to fix

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

                            revokeAuthorizationCode: (code) => {
                                return app.db.models.User
                                .findOne({ 'api.authorizationCode': code.code }, 'api')
                                .exec()
                                .then(user => {
                Severity: Major
                Found in modules/oauth.js and 1 other location - About 4 hrs to fix
                modules/oauth.js on lines 176..188

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

                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

                            revokeToken: (token) => {
                                return app.db.models.User
                                .findOne({ 'api.refreshToken': token.refreshToken }, 'api')
                                .exec()
                                .then(user => {
                Severity: Major
                Found in modules/oauth.js and 1 other location - About 4 hrs to fix
                modules/oauth.js on lines 192..204

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

                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 routes.js has 366 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                define(['angular', 'app'], function(angular, app) {
                    'use strict';
                
                    return app.config(['$routeProvider', function($routeProvider) {
                
                
                Severity: Minor
                Found in public/js/routes.js - About 4 hrs to fix

                  Function createGraphValues has 117 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          function createGraphValues(renewals, requestsPromise)
                          {
                              var history = [];
                  
                              function round(x) {
                  Severity: Major
                  Found in public/js/services/beneficiary.js - About 4 hrs to fix

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

                    exports = module.exports = function(services, app) {
                    
                        var service = new services.list(app);
                    
                    
                    
                    Severity: Major
                    Found in api/services/user/accountbeneficiaries/list.js - About 4 hrs to fix

                      Function saveRequest has 116 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function saveRequest(service, params) {
                      
                          const gt = service.app.utility.gettext;
                          const postpone = service.app.utility.postpone;
                      
                      
                      Severity: Major
                      Found in api/services/user/requests/save.js - About 4 hrs to fix

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

                            accountSchema.methods.getScheduleCalendarOverlapQuery = function(dtstart, dtend) {
                        
                                var from = new Date(dtstart);
                                from.setHours(0,0,0,0);
                                var to = new Date(dtend);
                        Severity: Major
                        Found in schema/User_Account.js and 1 other location - About 4 hrs to fix
                        schema/User_Account.js on lines 383..394

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

                        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