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

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

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

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

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

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

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

    _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

    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

    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

    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

    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

        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

        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

        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

        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

        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

        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
        Severity
        Category
        Status
        Source
        Language