YetiForceCompany/YetiForceCRM

View on GitHub
public_html/layouts/basic/modules/Settings/SharingAccess/resources/SharingAccess.js

Summary

Maintainability
D
2 days
Test Coverage

File SharingAccess.js has 291 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';

jQuery.Class(
    'Settings_Sharing_Access_Js',

    Function registerEvents has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            registerEvents: function () {
                const thisInstance = this;
                let contentTable = thisInstance.getContentTable(),
                    contentContainer = thisInstance.getContentContainer();
                thisInstance.registerSharingAccessEdit();

      Function deleteCustomRule has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

              deleteCustomRule: function (deleteElement) {
                  let deleteUrl = deleteElement.data('url');
                  let currentRow = deleteElement.closest('.js-custom-rule-entries');
                  app.showConfirmModal({
                      title: app.vtranslate('LBL_DELETE_CONFIRMATION'),

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

              deleteCustomRule: function (deleteElement) {
                  let deleteUrl = deleteElement.data('url');
                  let currentRow = deleteElement.closest('.js-custom-rule-entries');
                  app.showConfirmModal({
                      title: app.vtranslate('LBL_DELETE_CONFIRMATION'),

        Function saveCustomRule has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                saveCustomRule: function (form, e) {
                    const thisInstance = this;
                    let data = form.serializeFormData();
                    if (typeof data === 'undefined') {
                        data = {};

          Function confirmedCallback has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                          confirmedCallback: () => {
                              AppConnector.request(deleteUrl).done(function (data) {
                                  let response = data.result;
                                  if (response && response.success) {
                                      currentRow.fadeOut('slow');

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

                        AppConnector.request(data)
                            .done(function (data) {
                                progressIndicatorElement.progressIndicator({ mode: 'hide' });
                                aDeferred.resolve(data);
                            })
            public_html/layouts/basic/modules/Settings/Inventory/resources/Index.js on lines 267..275
            public_html/layouts/basic/modules/Settings/Vtiger/resources/Tax.js on lines 258..266

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

            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(params)
                            .done(function (data) {
                                aDeferred.resolve(data);
                            })
                            .fail(function (error) {
            public_html/layouts/basic/modules/Vtiger/resources/BasicSearch.min.js on lines 26..26

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

            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

                    setContentTable: function (element) {
                        if (element instanceof jQuery) {
                            this.contentTable = element;
                            return this;
                        }
            public_html/layouts/basic/modules/Settings/SharingAccess/resources/SharingAccess.js on lines 24..31

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

            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

                    setContentContainer: function (element) {
                        if (element instanceof jQuery) {
                            this.contentsContainer = element;
                            return this;
                        }
            public_html/layouts/basic/modules/Settings/SharingAccess/resources/SharingAccess.js on lines 15..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 54.

            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 3 locations. Consider refactoring.
            Open

                        contentTable.on('click', '.js-delete', function (e) {
                            let deleteElement = $(e.currentTarget);
                            thisInstance.deleteCustomRule(deleteElement);
                        });
            public_html/layouts/basic/modules/Settings/LayoutEditor/resources/LayoutEditor.js on lines 144..147
            public_html/layouts/basic/modules/Settings/LayoutEditor/resources/LayoutEditor.js on lines 1078..1081

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

            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