APTrust/dart

View on GitHub

Showing 166 of 237 total issues

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

        $(`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

    if (!profile) {
        let jsonFile = path.join(__dirname, '..', 'profiles', 'empty_profile.json');
        Context.logger.info(`Installing 'Empty Profile' from ${jsonFile}`);
        profile = BagItProfile.load(jsonFile);
        profile.isBuiltIn = true;
Severity: Major
Found in migrations/20200227T120404Z.js and 1 other location - About 4 hrs to fix
migrations/20200303T114404Z.js on lines 19..28

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

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 (!profile) {
        let jsonFile = path.join(__dirname, '..', 'profiles', 'btr-v0.1.json');
        Context.logger.info(`Installing 'BTR Profile' from ${jsonFile}`);
        profile = BagItProfile.load(jsonFile);
        profile.isBuiltIn = true;
Severity: Major
Found in migrations/20200303T114404Z.js and 1 other location - About 4 hrs to fix
migrations/20200227T120404Z.js on lines 18..27

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

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

function loadEmptyProfile() {
    let jsonFile = path.join(__dirname, '..', 'profiles', 'btr-v0.1.json');
    Context.logger.info(`Installing corrected BTR BagIt profile from ${jsonFile}`);
    let profile = BagItProfile.load(jsonFile);
    profile.isBuiltIn = false;
Severity: Major
Found in migrations/20220429T182345Z.js and 1 other location - About 3 hrs to fix
migrations/20200311T145456Z.js on lines 22..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 97.

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

function loadEmptyProfile() {
    let jsonFile = path.join(__dirname, '..', 'profiles', 'empty_profile.json');
    Context.logger.info(`Installing 'Empty Profile' from ${jsonFile}`);
    let profile = BagItProfile.load(jsonFile);
    profile.isBuiltIn = true;
Severity: Major
Found in migrations/20200311T145456Z.js and 1 other location - About 3 hrs to fix
migrations/20220429T182345Z.js on lines 18..25

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

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

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

    upload(filepathOrBuffer, keyname) {
        let sftp = this;
        if (!filepathOrBuffer) {
            throw new Error('Param filepathOrBuffer is required for upload.');
        }
Severity: Major
Found in plugins/network/sftp_client.js - About 2 hrs to fix

    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

        _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

            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

    Function _checkTagsRequiredByProfile has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        _checkTagsRequiredByProfile(profile, jobParamsArray) {
            // Get a list of required tags whose values must appear in the CSV file.
            for (let i=0; i < jobParamsArray.length; i++) {
                let params = jobParamsArray[i];
                for (let tag of profile.tags) {
    Severity: Minor
    Found in core/workflow_batch.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

    BagItProfileController has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class BagItProfileController extends BaseController {
    
        constructor(params) {
            super(params, 'Settings');
            /**
    Severity: Minor
    Found in ui/controllers/bagit_profile_controller.js - About 2 hrs to fix

      Function doUpload has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          doUpload(uploadOp) {
              let uploader = this;
              // Clear prior upload results. They may cause the UI to
              // report successful upload as failed, or vice-versa.
              uploadOp.results = [];
      Severity: Major
      Found in workers/uploader.js - About 2 hrs to fix

        Function _validateSerialization has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            _validateSerialization() {
                var validFormat = true;
                if (!this.disableSerializationCheck) {
                    var checkSerializationFormat = true;
                    var bagIsDirectory = fs.statSync(this.pathToBag).isDirectory();
        Severity: Minor
        Found in bagit/validator.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

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

            getSelectedType(rowNumber) {
                let element = $(`#objType_${rowNumber}`);
                return element.length > 0 ? element.val() : this.fields[`objType_${rowNumber}`].value;
            }
        Severity: Major
        Found in ui/forms/settings_questions_form.js and 2 other locations - About 2 hrs to fix
        ui/forms/settings_questions_form.js on lines 269..272
        ui/forms/settings_questions_form.js on lines 279..282

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

            getSelectedId(rowNumber) {
                let element = $(`#objId_${rowNumber}`);
                return element.length > 0 ? element.val() : this.fields[`objId_${rowNumber}`].value;
            }
        Severity: Major
        Found in ui/forms/settings_questions_form.js and 2 other locations - About 2 hrs to fix
        ui/forms/settings_questions_form.js on lines 259..262
        ui/forms/settings_questions_form.js on lines 279..282

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

            getSelectedField(rowNumber) {
                let element = $(`#field_${rowNumber}`);
                return element.length > 0 ? element.val() : this.fields[`field_${rowNumber}`].value;
            }
        Severity: Major
        Found in ui/forms/settings_questions_form.js and 2 other locations - About 2 hrs to fix
        ui/forms/settings_questions_form.js on lines 259..262
        ui/forms/settings_questions_form.js on lines 269..272

        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

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

            colorCodeJobs(jobs) {
                // TODO: This code has some overlap with DashboardController#formatJobOutcome.
                for(let i=0; i < jobs.length; i++) {
                    let job = Job.inflateFrom(jobs[i]);
                    job.pkgDate = '-';
        Severity: Minor
        Found in ui/controllers/job_controller.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 validateParams has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            validateParams() {
                let errors = [];
                for (let op of this.job.uploadOps) {
                    let opErrors = []
                    if (Util.isEmpty(op.storageServiceId)) {
        Severity: Minor
        Found in workers/uploader.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

        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

        Severity
        Category
        Status
        Source
        Language