APTrust/dart

View on GitHub
ui/controllers/settings_controller.js

Summary

Maintainability
D
2 days
Test Coverage

File settings_controller.js has 354 lines of code (exceeds 250 allowed). Consider refactoring.
Invalid

const $ = require('jquery');
const { AppSetting } = require('../../core/app_setting');
const { BagItProfile } = require('../../bagit/bagit_profile');
const { BaseController } = require('./base_controller');
const { Constants } = require('../../core/constants');
Severity: Minor
Found in ui/controllers/settings_controller.js - About 4 hrs to fix

    SettingsController has 28 functions (exceeds 20 allowed). Consider refactoring.
    Invalid

    class SettingsController extends BaseController {
    
        constructor(params) {
            super(params, 'Settings');
            this.questionsForm = null;
    Severity: Minor
    Found in ui/controllers/settings_controller.js - About 3 hrs to fix

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

          _processResponses(controller) {
              let form = new SettingsResponseForm(importedSettings);
              let responses = form.getResponses();
              let hasEmptyAnswers = false;
              let errors = '';
      Severity: Minor
      Found in ui/controllers/settings_controller.js - About 1 hr to fix

        Function _processResponses has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            _processResponses(controller) {
                let form = new SettingsResponseForm(importedSettings);
                let responses = form.getResponses();
                let hasEmptyAnswers = false;
                let errors = '';
        Severity: Minor
        Found in ui/controllers/settings_controller.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

        Function postRenderCallback has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            postRenderCallback(fnName) {
                let controller = this;
                if (fnName == 'import') {
                    this._attachImportHandlers();
                } else if (fnName == 'export') {
        Severity: Minor
        Found in ui/controllers/settings_controller.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

                $(`select[data-control-type=object-name][data-row-number=${rowNumber}]`).change(function() {
                    let fieldsList = controller.questionsForm.getFieldsList(rowNumber);
                    $(`#field_${rowNumber}`).empty();
                    $(`#field_${rowNumber}`).append(new Option());
                    for (let opt of fieldsList) {
        Severity: Major
        Found in ui/controllers/settings_controller.js and 1 other location - About 5 hrs to fix
        ui/controllers/settings_controller.js on lines 304..311

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

        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

                $(`select[data-control-type=object-type][data-row-number=${rowNumber}]`).change(function() {
                    let namesList = controller.questionsForm.getNamesList(rowNumber);
                    $(`#objId_${rowNumber}`).empty();
                    $(`#objId_${rowNumber}`).append(new Option());
                    for (let opt of namesList) {
        Severity: Major
        Found in ui/controllers/settings_controller.js and 1 other location - About 5 hrs to fix
        ui/controllers/settings_controller.js on lines 313..320

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

        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

            _showError(message) {
                $('#result').hide();
                $('#result').addClass('text-danger');
                $('#result').removeClass('text-success');
                $('#result').text(message);
        Severity: Major
        Found in ui/controllers/settings_controller.js and 1 other location - About 2 hrs to fix
        ui/controllers/settings_controller.js on lines 528..534

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

        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

            _showSuccess(message) {
                $('#result').hide();
                $('#result').removeClass('text-danger');
                $('#result').addClass('text-success');
                $('#result').text(message);
        Severity: Major
        Found in ui/controllers/settings_controller.js and 1 other location - About 2 hrs to fix
        ui/controllers/settings_controller.js on lines 541..547

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

        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

                try {
                    obj = JSON.parse(json);
                } catch (ex) {
                    let msg = Context.y18n.__("Error parsing JSON: %s. ", ex.message || ex);
                    if (settingsUrl) {
        Severity: Major
        Found in ui/controllers/settings_controller.js and 1 other location - About 2 hrs to fix
        ui/controllers/bagit_profile_controller.js on lines 477..485

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

        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

            _copyToClipboard() {
                var copyText = document.querySelector("#txtJson");
                copyText.select();
                document.execCommand("copy");
                $("#copied").show();
        Severity: Major
        Found in ui/controllers/settings_controller.js and 1 other location - About 2 hrs to fix
        ui/controllers/workflow_controller.js on lines 118..124

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

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

                    } else {
                        $("#btnNext").text(Context.y18n.__("Export"));
                        $("#btnNext").attr("href", "#Settings/showExportJson");
                    }
        Severity: Minor
        Found in ui/controllers/settings_controller.js and 1 other location - About 35 mins to fix
        ui/controllers/settings_controller.js on lines 257..260

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

                    if ($(`input[name="addQuestions"]`).is(':checked')) {
                        $("#btnNext").text(Context.y18n.__("Add Questions"));
                        $("#btnNext").attr("href", "#Settings/saveAndGoToQuestions");
                    } else {
        Severity: Minor
        Found in ui/controllers/settings_controller.js and 1 other location - About 35 mins to fix
        ui/controllers/settings_controller.js on lines 260..263

        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