YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
D
3 days
Test Coverage

File Vtiger.js has 367 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*+***********************************************************************************
 * The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
Severity: Minor
Found in public_html/layouts/basic/modules/Vtiger/resources/Vtiger.js - About 4 hrs to fix

    Function changeWatching has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        changeWatching: function (instance) {
            let value, module, state, className, user, record;
            if (instance != undefined) {
                instance = $(instance);
                value = instance.data('value');
    Severity: Minor
    Found in public_html/layouts/basic/modules/Vtiger/resources/Vtiger.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 changeWatching has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        changeWatching: function (instance) {
            let value, module, state, className, user, record;
            if (instance != undefined) {
                instance = $(instance);
                value = instance.data('value');
    Severity: Minor
    Found in public_html/layouts/basic/modules/Vtiger/resources/Vtiger.js - About 1 hr to fix

      Function getEmailFromRecord has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          getEmailFromRecord(record, module, maxEmails) {
              const aDeferred = $.Deferred();
              const progress = $.progressIndicator({ position: 'html', blockInfo: { enabled: true } });
              AppConnector.request({
                  dataType: 'html',
      Severity: Minor
      Found in public_html/layouts/basic/modules/Vtiger/resources/Vtiger.js - About 1 hr to fix

        Function markNotifications has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            markNotifications: function (id) {
                let aDeferred = $.Deferred();
                let thisInstance = this;
                let params = {
                    module: 'Notification',
        Severity: Minor
        Found in public_html/layouts/basic/modules/Vtiger/resources/Vtiger.js - About 1 hr to fix

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

              requestReminder: function () {
                  let thisInstance = this;
                  let content = $('.remindersNoticeContainer');
                  let element = $('.remindersNotice');
                  let url = 'index.php?module=Calendar&view=Reminders&type_remainder=true';
          Severity: Minor
          Found in public_html/layouts/basic/modules/Vtiger/resources/Vtiger.js - About 1 hr to fix

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

                sendMailWindow: function (url, popup, postData) {
                    if (popup) {
                        let width = screen.width - 15;
                        let height = screen.height - 150;
                        let left = 0;
            Severity: Minor
            Found in public_html/layouts/basic/modules/Vtiger/resources/Vtiger.js - About 1 hr to fix

              Function sendMailWindow has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  sendMailWindow: function (url, popup, postData) {
                      if (popup) {
                          let width = screen.width - 15;
                          let height = screen.height - 150;
                          let left = 0;
              Severity: Minor
              Found in public_html/layouts/basic/modules/Vtiger/resources/Vtiger.js - About 25 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 registerReminders has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  registerReminders: function () {
                      let activityReminder = (parseInt(app.getMainParams('activityReminder')) || 0) * 1000;
                      if (activityReminder != 0 && $('.remindersNotice.autoRefreshing').length) {
                          Vtiger_Index_Js.requestReminder();
                          window.reminder = setInterval(function () {
              Severity: Minor
              Found in public_html/layouts/basic/modules/Vtiger/resources/Vtiger.js - About 25 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

                                  thisInstance.markNotifications(recordID).done(function (data) {
                                      currentElement.closest('.js-notification-panel').fadeOut(300, function () {
                                          $(this).remove();
                                          thisInstance.refreshReminderCount(content, element, 'js-count-notifications-reminder');
                                      });
              Severity: Major
              Found in public_html/layouts/basic/modules/Vtiger/resources/Vtiger.js and 1 other location - About 2 hrs to fix
              public_html/layouts/basic/modules/Vtiger/resources/Vtiger.js on lines 242..247

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

              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

                                  AppConnector.request(url).done(function (data) {
                                      currentElement.closest('.js-toggle-panel').fadeOut(300, function () {
                                          $(this).remove();
                                          thisInstance.refreshReminderCount(content, element, 'countRemindersNotice');
                                      });
              Severity: Major
              Found in public_html/layouts/basic/modules/Vtiger/resources/Vtiger.js and 1 other location - About 2 hrs to fix
              public_html/layouts/basic/modules/Vtiger/resources/Vtiger.js on lines 209..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 77.

              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 (activityReminder != 0 && $('.remindersNotice.autoRefreshing').length) {
                          Vtiger_Index_Js.requestReminder();
                          window.reminder = setInterval(function () {
                              Vtiger_Index_Js.requestReminder();
                          }, activityReminder);
              public_html/layouts/basic/modules/Vtiger/resources/Vtiger.js on lines 190..195

              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 (reminder != 0 && $('.notificationsNotice.autoRefreshing').length) {
                          Vtiger_Index_Js.getNotificationsForReminder();
                          window.reminderNotifications = setInterval(function () {
                              Vtiger_Index_Js.getNotificationsForReminder();
                          }, reminder);
              public_html/layouts/basic/modules/Vtiger/resources/Vtiger.js on lines 183..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 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 (state == 1) {
                                          instance.toggleClass(instance.data('off') + ' ' + instance.data('on'));
                                          buttonIcon.removeClass('fas fa-eye');
                                          buttonIcon.addClass('fas fa-eye-slash');
                                      } else {
              public_html/layouts/basic/modules/Vtiger/resources/Vtiger.js on lines 310..314

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

              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

                                      } else {
                                          instance.toggleClass(instance.data('on') + ' ' + instance.data('off'));
                                          buttonIcon.removeClass('fas fa-eye-slash');
                                          buttonIcon.addClass('fas fa-eye');
                                      }
              public_html/layouts/basic/modules/Vtiger/resources/Vtiger.js on lines 306..310

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

              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