YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
F
3 days
Test Coverage

File LangManagement.js has 480 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';

var Settings_Index_Js = {
    initEvants: function () {

    Function initEvant has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        initEvant: function (element) {
            const options = {
                title: app.vtranslate('LBL_AreYouSure'),
                trigger: 'manual',
                placement: 'left',

      Function showStats has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          showStats: function (data, modules) {
              const thisInstance = this;
              let container = $('.LangManagement'),
                  html = '<div class="col-md-12"><div class="panel panel-default"><div class="panel-body col-md-12">',
                  langStats = 0,

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

            showStats: function (data, modules) {
                const thisInstance = this;
                let container = $('.LangManagement'),
                    html = '<div class="col-md-12"><div class="panel panel-default"><div class="panel-body col-md-12">',
                    langStats = 0,

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

            getDataCharts: function (shortages, max) {
                let container = $('.LangManagement'),
                    data = [],
                    chartData = {
                        labels: [],

          Function registerStatsEvent has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              registerStatsEvent: function () {
                  var thisInstance = this;
                  jQuery('.statsData .btn').on('click', function (e) {
                      var progress = $.progressIndicator({
                          position: 'html',

            Function LoadEditLang has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                LoadEditLang: function (e) {
                    var element = jQuery(e);
                    var position = element.attr('href');
                    if (typeof position === 'undefined') {
                        position = '#' + element.attr('id');

              Function initEditLang has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  initEditLang: function (position) {
                      App.Fields.Picklist.changeSelectElementView($('.LangManagement .layoutContent .active .select2'), 'select2').on(
                          'change',
                          function (e) {
                              e = jQuery(this).closest('.active');

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

                    registerUpdateLanguageBtn(container) {
                        container.find('.js-update').on('click', function (e) {
                            let icon = $(e.target).find('.js-update__icon'),
                                progress = $.progressIndicator({
                                    message: app.vtranslate('JS_LOADING_PLEASE_WAIT'),

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

                          const options = {
                              title: app.vtranslate('LBL_AreYouSure'),
                              trigger: 'manual',
                              placement: 'left',
                              html: true,
                  public_html/layouts/basic/modules/Settings/LangManagement/resources/LangManagement.js on lines 201..213

                  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 makeSureOptions = {
                              title: app.vtranslate('JS_ARE_YOU_SURE_TO_SET_AS_DEFAULT'),
                              trigger: 'manual',
                              placement: 'left',
                              html: true,
                  public_html/layouts/basic/modules/Settings/LangManagement/resources/LangManagement.js on lines 188..200

                  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

                              mod = jQuery('.LangManagement ' + position + ' #mods_list').data('target')
                                  ? jQuery('.LangManagement ' + position + ' #mods_list').data('target')
                                  : jQuery('.LangManagement ' + position + ' #mods_list').val();
                  public_html/layouts/basic/modules/Settings/LangManagement/resources/LangManagement.js on lines 177..179

                  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

                              mod: $('.LangManagement ' + position + ' #mods_list').data('target')
                                  ? $('.LangManagement ' + position + ' #mods_list').data('target')
                                  : $('.LangManagement ' + position + ' #mods_list').val(),
                  public_html/layouts/basic/modules/Settings/LangManagement/resources/LangManagement.js on lines 147..149

                  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

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

                              AppConnector.request({
                                  module: 'YetiForce',
                                  parent: 'Settings',
                                  action: 'DownloadLanguage',
                                  prefix: $(e.target).data('prefix')
                  public_html/layouts/basic/modules/Settings/YetiForce/resources/DownloadLanguageModal.js on lines 21..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 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 3 locations. Consider refactoring.
                  Open

                          params.data = {
                              module: app.getModuleName(),
                              parent: app.getParentModuleName(),
                              action: 'SaveAjax',
                              mode: mode
                  public_html/layouts/basic/modules/Settings/CurrencyUpdate/resources/Index.js on lines 88..93
                  public_html/layouts/basic/modules/Settings/Dav/resources/Dav.js on lines 61..66

                  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

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

                          var progress = $.progressIndicator({
                              message: app.vtranslate('LBL_Loader'),
                              position: position,
                              blockInfo: {
                                  enabled: true
                  public_html/layouts/basic/modules/Settings/LangManagement/resources/LangManagement.js on lines 139..145
                  public_html/layouts/basic/modules/Settings/LangManagement/resources/LangManagement.js on lines 168..174

                  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

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

                          var progress = $.progressIndicator({
                              message: app.vtranslate('LBL_Loader'),
                              position: position,
                              blockInfo: {
                                  enabled: true
                  public_html/layouts/basic/modules/Settings/LangManagement/resources/LangManagement.js on lines 67..73
                  public_html/layouts/basic/modules/Settings/LangManagement/resources/LangManagement.js on lines 168..174

                  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

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

                          var progress = $.progressIndicator({
                              message: app.vtranslate('LBL_Loader'),
                              position: position,
                              blockInfo: {
                                  enabled: true
                  public_html/layouts/basic/modules/Settings/LangManagement/resources/LangManagement.js on lines 67..73
                  public_html/layouts/basic/modules/Settings/LangManagement/resources/LangManagement.js on lines 139..145

                  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