APTrust/dart

View on GitHub

Showing 166 of 237 total issues

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

    try {
        var reader = fs.createReadStream(data.bagItFile.absSourcePath);

        reader.on('error', function(err) {
            data.errFn(err);
Severity: Major
Found in plugins/formats/write/tar_writer.js and 1 other location - About 1 hr to fix
plugins/formats/write/file_system_writer.js on lines 119..126

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

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

    constructor(params) {
        super(params, 'Jobs');
        this.model = Job;
        this.job = Job.find(this.params.get('id'));
    }
Severity: Major
Found in ui/controllers/job_metadata_controller.js and 2 other locations - About 1 hr to fix
ui/controllers/job_packaging_controller.js on lines 27..31
ui/controllers/job_upload_controller.js on lines 22..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 61.

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 (data.action == 'fileAdded') {
            let shortName = Util.trimToLength(data.msg, 80, 'middle');
            detailDiv.text(Context.y18n.__('Added file %s', shortName));
            this.setProgressBar(progressBar, data);
        } else if (data.action == 'completed') {
Severity: Major
Found in ui/controllers/running_jobs_controller.js and 1 other location - About 1 hr to fix
ui/controllers/running_jobs_controller.js on lines 120..130

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

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 (data.action == 'checksum') {
            let shortName = Util.trimToLength(data.msg, 80, 'middle');
            detailDiv.text(Context.y18n.__('Validating %s', shortName));
            this.setProgressBar(progressBar, data);
        } else if (data.action == 'completed') {
Severity: Major
Found in ui/controllers/running_jobs_controller.js and 1 other location - About 1 hr to fix
ui/controllers/running_jobs_controller.js on lines 100..115

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

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

    constructor(params) {
        super(params, 'Jobs');
        this.model = Job;
        this.job = Job.find(this.params.get('id'));
    }
Severity: Major
Found in ui/controllers/job_upload_controller.js and 2 other locations - About 1 hr to fix
ui/controllers/job_metadata_controller.js on lines 26..30
ui/controllers/job_packaging_controller.js on lines 27..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 61.

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

    constructor(params) {
        super(params, 'Jobs');
        this.model = Job;
        this.job = Job.find(this.params.get('id'));
    }
Severity: Major
Found in ui/controllers/job_packaging_controller.js and 2 other locations - About 1 hr to fix
ui/controllers/job_metadata_controller.js on lines 26..30
ui/controllers/job_upload_controller.js on lines 22..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 61.

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

    _upload(xfer) {
        var s3Client = this;
        var minioClient = s3Client._getClient();
        // Metadata works with fPutObject, but not with putObject,
        // so this is commented out for now. We can delete it if we
Severity: Minor
Found in plugins/network/s3_client.js - About 1 hr to fix

    Function postRenderCallback has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        postRenderCallback(fnName) {
            let controller = this;
            $('#pathToBag').on('change',function(e){
                let element = document.getElementById('pathToBag');
                if (element && element.files && element.files[0]) {
    Severity: Minor
    Found in ui/controllers/bag_validation_controller.js - About 1 hr to fix

      Function parseFromDOM has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          parseFromDOM() {
              // This is required for jest tests.
              if ($ === undefined) {
                  var $ = require('jquery');
              }
      Severity: Minor
      Found in ui/forms/form.js - About 1 hr 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 _mergeTagSet has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          _mergeTagSet(bagItProfile, tags, profileTags) {
              let firstInstanceOfTag = null;
              for (let i = 0; i < tags.length; i++) {
                  let tag = tags[i];
                  if (profileTags.length > i) {
      Severity: Minor
      Found in core/job_params.js - About 1 hr 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 guessProfileType has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          static guessProfileType(obj) {
              let type = 'unknown';
              if (Array.isArray(obj['tags'])) {
                  type = 'dart';
              } else if (Array.isArray(obj['ordered'])) {
      Severity: Minor
      Found in bagit/bagit_util.js - About 1 hr 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 _setBagInfoAutoValues has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          _setBagInfoAutoValues() {
              var profile = this.job.bagItProfile;
              var baggingDate = profile.firstMatchingTag('tagName', 'Bagging-Date');
              if (baggingDate) {
                  baggingDate.userValue = dateFormat(Date.now(), 'isoUtcDateTime');
      Severity: Minor
      Found in bagit/bagger.js - About 1 hr 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 31 lines of code (exceeds 25 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 1 hr to fix

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

            constructor(bagItFile) {
                /**
                  * bagItFile is the file that will be parsed.
                  * When parsing is complete, bagItFile.keyValueCollection
                  * will be populated with relative file paths and
        Severity: Minor
        Found in bagit/manifest_parser.js - About 1 hr to fix

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

              constructor(name, writeFn) {
                  super();
          
                  if (typeof writeFn != 'function') {
                      throw new Error(Context.y18n.__('Param %s must be a function', 'writeFn'));
          Severity: Minor
          Found in plugins/formats/write/base_writer.js - About 1 hr to fix

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

                async _writeManifests(payloadOrTag) {
                    var profile = this.job.bagItProfile;
                    var manifestAlgs = profile.chooseManifestAlgorithms('manifest');
                    var fileNamePrefix = 'manifest';
                    if (payloadOrTag == 'tag') {
            Severity: Minor
            Found in bagit/bagger.js - About 1 hr to fix

              Function chooseManifestAlgorithms has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  chooseManifestAlgorithms(whichType) {
                      if (whichType != 'manifest' && whichType != 'tagmanifest') {
                          throw Context.y18n.__("Param whichType must be either 'manifest' or 'tagmanifest'");
                      }
                      let required = this.manifestsRequired;
              Severity: Minor
              Found in bagit/bagit_profile.js - About 1 hr to fix

                Function _listBagItSerializations has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    _listBagItSerializations() {
                        let none = Context.y18n.__('None');
                        let formats = [{ id: '', name: none }];
                        let profile = null;
                        if (this.fields.bagItProfileId.value) {
                Severity: Minor
                Found in ui/forms/job_package_op_form.js - About 1 hr to fix

                  Function run has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function run() {
                      process.on('uncaughtException', function (error) {
                          console.error(error);
                          Context.logger.error(error);
                      });
                  Severity: Minor
                  Found in main.js - About 1 hr to fix

                    Function createWindow has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function createWindow() {
                        // Create the browser window.
                        win = new BrowserWindow({
                            width: 1200,
                            height: 900,
                    Severity: Minor
                    Found in ui/main.js - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language