YetiForceCompany/YetiForceCRM

View on GitHub
public_html/layouts/basic/modules/Vtiger/resources/CalendarView.js

Summary

Maintainability
F
3 days
Test Coverage

File CalendarView.js has 539 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* {[The file is published on the basis of YetiForce Public License 6.5 that can be found in the following directory: licenses/LicenseEN.txt or yetiforce.com]} */
'use strict';

/**
 * Class representing a standard calendar.
Severity: Major
Found in public_html/layouts/basic/modules/Vtiger/resources/CalendarView.js - About 1 day to fix

    Vtiger_Calendar_Js has 29 functions (exceeds 20 allowed). Consider refactoring.
    Open

    window.Vtiger_Calendar_Js = class Vtiger_Calendar_Js extends Calendar_Js {
        /**
         * Create calendar's options.
         * @param {jQuery} container
         * @param {bool} readonly
    Severity: Minor
    Found in public_html/layouts/basic/modules/Vtiger/resources/CalendarView.js - About 3 hrs to fix

      Function registerSwitchEvents has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          registerSwitchEvents() {
              let isWorkDays,
                  switchShowTypeVal,
                  switchContainer = $('.js-calendar__tab--filters'),
                  switchShowType = switchContainer.find('.js-switch--showType'),
      Severity: Major
      Found in public_html/layouts/basic/modules/Vtiger/resources/CalendarView.js - About 2 hrs to fix

        Function registerSwitchEvents has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            registerSwitchEvents() {
                let isWorkDays,
                    switchShowTypeVal,
                    switchContainer = $('.js-calendar__tab--filters'),
                    switchShowType = switchContainer.find('.js-switch--showType'),
        Severity: Minor
        Found in public_html/layouts/basic/modules/Vtiger/resources/CalendarView.js - About 2 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 generateDaysList has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            generateDaysList() {
                const datesView = this.container.find('.js-dates-row'),
                    activeDays = moment(this.fullCalendar.view.currentStart).format('DDD'),
                    nextDays = moment(this.fullCalendar.view.currentStart).add(7, 'days');
                let prevDays = moment(this.fullCalendar.view.currentStart).subtract(5, 'days'),
        Severity: Minor
        Found in public_html/layouts/basic/modules/Vtiger/resources/CalendarView.js - About 1 hr to fix

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

              registerClearFilterButton() {
                  const sidebar = this.getSidebarView(),
                      clearBtn = this.calendarView.find('.js-calendar__clear-filters');
                  app.showPopoverElementView(clearBtn);
                  clearBtn.on('click', () => {
          Severity: Minor
          Found in public_html/layouts/basic/modules/Vtiger/resources/CalendarView.js - About 1 hr to fix

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

                getSelectedUsersCalendar() {
                    const sidebar = this.getSidebarView();
                    let selectedUsers = sidebar.find('.js-input-user-owner-id:checked'),
                        notSelectedUsers = sidebar.find('.js-input-user-owner-id:not(:checked)'),
                        selectedUsersAjax = sidebar.find('.js-input-user-owner-id-ajax'),
            Severity: Minor
            Found in public_html/layouts/basic/modules/Vtiger/resources/CalendarView.js - About 1 hr to fix

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

                  registerDayClickEvent(info) {
                      const self = this,
                          userFormat = App.Fields.Date.dateToUserFormat(info.date);
                      if (!CONFIG.isQuickCreateSupported) {
                          app.openUrl(
              Severity: Minor
              Found in public_html/layouts/basic/modules/Vtiger/resources/CalendarView.js - About 1 hr to fix

                Function generateDaysList has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    generateDaysList() {
                        const datesView = this.container.find('.js-dates-row'),
                            activeDays = moment(this.fullCalendar.view.currentStart).format('DDD'),
                            nextDays = moment(this.fullCalendar.view.currentStart).add(7, 'days');
                        let prevDays = moment(this.fullCalendar.view.currentStart).subtract(5, 'days'),
                Severity: Minor
                Found in public_html/layouts/basic/modules/Vtiger/resources/CalendarView.js - About 45 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 setCalendarModuleOptions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    setCalendarModuleOptions() {
                        const self = this;
                        return {
                            allDaySlot: app.getMainParams('allDaySlot'),
                            dateClick: (args) => {
                Severity: Minor
                Found in public_html/layouts/basic/modules/Vtiger/resources/CalendarView.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

                        const datesView = this.container.find('.js-dates-row'),
                            activeDays = moment(this.fullCalendar.view.currentStart).format('DDD'),
                            nextDays = moment(this.fullCalendar.view.currentStart).add(7, 'days');
                public_html/layouts/basic/modules/Vtiger/resources/CalendarView.js on lines 426..428

                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

                        const datesView = this.container.find('.js-dates-row'),
                            activeWeek = moment(this.fullCalendar.view.currentStart).format('WW'),
                            nextWeeks = moment(this.fullCalendar.view.currentStart).add(6, 'weeks');
                public_html/layouts/basic/modules/Vtiger/resources/CalendarView.js on lines 390..392

                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

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

                        AppConnector.request(defaultParams).done((events) => {
                            self.fullCalendar.removeAllEvents();
                            self.fullCalendar.addEventSource(events.result);
                            progressInstance.progressIndicator({ mode: 'hide' });
                        });
                public_html/layouts/basic/modules/Calendar/resources/CalendarView.js on lines 210..214

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

                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 (app.getMainParams('showType') !== showTypeState) {
                            $('label.active', switchShowType).find('input').filter(':first').trigger('change');
                        }
                public_html/layouts/basic/modules/Vtiger/resources/CalendarView.js on lines 288..290

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

                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 (app.getMainParams('switchingDays') !== switchingDaysState) {
                                $('label.active', switchSwitchingDays).find('input').filter(':first').trigger('change');
                            }
                public_html/layouts/basic/modules/Vtiger/resources/CalendarView.js on lines 267..269

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

                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 (typeof currentTarget.data('on-text') !== 'undefined') {
                                    app.setMainParams('switchingDays', 'workDays');
                                    app.moduleCacheSet('defaultSwitchingDays', 'workDays');
                                    hiddenDays = app.getMainParams('hiddenDays', true);
                                } else if (typeof currentTarget.data('off-text') !== 'undefined') {
                public_html/layouts/basic/modules/Vtiger/resources/CalendarView.js on lines 258..264

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

                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 (typeof currentTarget.data('on-text') !== 'undefined') {
                                app.setMainParams('showType', 'current');
                                app.moduleCacheSet('defaultShowType', 'current');
                            } else if (typeof currentTarget.data('off-text') !== 'undefined') {
                                app.setMainParams('showType', 'history');
                public_html/layouts/basic/modules/Vtiger/resources/CalendarView.js on lines 277..284

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

                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

                            headerToolbar: {
                                left: `dayGridMonth,${app.getMainParams('weekView')},${app.getMainParams('dayView')},listWeek,today`,
                                center: 'prevYear,prev,title,next,nextYear',
                                right: ''
                            },
                public_html/layouts/basic/modules/Calendar/resources/CalendarQuickCreate.js on lines 25..29

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

                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