YouTransfer/YouTransfer

View on GitHub

Showing 61 of 61 total issues

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

    self.upload = function(file, bundle, next) {
        self.settings.get(function(err, settings) {
            var basedir = settings.storage.localstoragepath;
            var retention = {};
            retention[settings.storage.retentionUnit] = parseInt(settings.storage.retention);
Severity: Minor
Found in lib/youtransfer.js - About 1 hr to fix

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

    Router.prototype.settingsGetTemplateByName = function() {
        return function(req, res, next) {
    
            req.errors.register([
                new Error('An error occurred while trying to retrieve the template'),
    Severity: Minor
    Found in lib/routes.js - About 1 hr to fix

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

                          if(context.expires) {
                              var expires = new Date(context.expires);
                              if(Date.compare(expires, new Date()) < 0) {
                                  throw new Error('The requested file is no longer available.');
                              }
      Severity: Major
      Found in lib/s3storage.js and 3 other locations - About 1 hr to fix
      lib/localstorage.js on lines 110..115
      lib/localstorage.js on lines 187..192
      lib/s3storage.js on lines 107..112

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

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

                              if(bundle.expires) {
                                  var expires = new Date(bundle.expires);
                                  if(Date.compare(expires, new Date()) < 0) {
                                      throw new Error('The requested bundle is no longer available.');
                                  }
      Severity: Major
      Found in lib/localstorage.js and 3 other locations - About 1 hr to fix
      lib/localstorage.js on lines 187..192
      lib/s3storage.js on lines 107..112
      lib/s3storage.js on lines 157..162

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

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

                          if(context.expires) {
                              var expires = new Date(context.expires);
                              if(Date.compare(expires, new Date()) < 0) {
                                  throw new Error('The requested file is no longer available.');
                              }
      Severity: Major
      Found in lib/localstorage.js and 3 other locations - About 1 hr to fix
      lib/localstorage.js on lines 110..115
      lib/s3storage.js on lines 107..112
      lib/s3storage.js on lines 157..162

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

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

                          if(bundle.expires) {
                              var expires = new Date(bundle.expires);
                              if(Date.compare(expires, new Date()) < 0) {
                                  throw new Error('The requested bundle is no longer available.');
                              }
      Severity: Major
      Found in lib/s3storage.js and 3 other locations - About 1 hr to fix
      lib/localstorage.js on lines 110..115
      lib/localstorage.js on lines 187..192
      lib/s3storage.js on lines 157..162

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

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

      module.exports = (function() {
      
          var self = require('passport');
      
          // Serialization
      Severity: Minor
      Found in lib/passport.js - About 1 hr to fix

        Function get has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Settings.prototype.get = function(next) {
            var self = this;
        
            self.cache.get('settings', function(err, cached) {
                if(_.isUndefined(cached)) {
        Severity: Minor
        Found in lib/settings.js - About 1 hr to fix

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

              self.archive = function(token, res, next) {
                  self.storageFactory.get(function(err, factory) {
                      factory.archive(token, res, next);
                  });    
              };
          Severity: Minor
          Found in lib/youtransfer.js and 1 other location - About 55 mins to fix
          lib/youtransfer.js on lines 194..198

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

          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

              self.download = function(token, res, next) {
                  self.storageFactory.get(function(err, factory) {
                      factory.download(token, res, next);
                  });
              };
          Severity: Minor
          Found in lib/youtransfer.js and 1 other location - About 55 mins to fix
          lib/youtransfer.js on lines 200..204

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

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

          $(document).on('xhr.loaded', function() {
              $(COMPONENT_SELECTOR).each(function(index, element) {
                  return new TemplateEditor(element);
              });
          });
          Severity: Major
          Found in src/js/components/templateEditor/templateEditor.js and 3 other locations - About 50 mins to fix
          src/js/components/alerts/alerts.js on lines 41..45
          src/js/components/dropdown/dropdown.js on lines 30..34
          src/js/components/jsonly/jsonly.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 52.

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

          $(document).on('xhr.loaded', function() {
              $(COMPONENT_SELECTOR).each(function(index, element) {
                  return new Alerts(element);
              });
          });
          Severity: Major
          Found in src/js/components/alerts/alerts.js and 3 other locations - About 50 mins to fix
          src/js/components/dropdown/dropdown.js on lines 30..34
          src/js/components/jsonly/jsonly.js on lines 27..31
          src/js/components/templateEditor/templateEditor.js on lines 36..40

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

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

          $(document).on('xhr.loaded', function() {
              $(COMPONENT_SELECTOR).each(function(index, element) {
                  return new JSOnly(element);
              });
          });
          Severity: Major
          Found in src/js/components/jsonly/jsonly.js and 3 other locations - About 50 mins to fix
          src/js/components/alerts/alerts.js on lines 41..45
          src/js/components/dropdown/dropdown.js on lines 30..34
          src/js/components/templateEditor/templateEditor.js on lines 36..40

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

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

          $(document).on('xhr.loaded', function() {
              $(COMPONENT_SELECTOR).each(function(index, element) {
                  return new Dropdown(element);
              });
          });
          Severity: Major
          Found in src/js/components/dropdown/dropdown.js and 3 other locations - About 50 mins to fix
          src/js/components/alerts/alerts.js on lines 41..45
          src/js/components/jsonly/jsonly.js on lines 27..31
          src/js/components/templateEditor/templateEditor.js on lines 36..40

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

          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

                  req.errors.register([
                      new Error('An error occurred while trying to save the template'),
                      {
                          code: 'ENOENT',
                          message: 'An invalid template has been selected. Please try again.',
          Severity: Minor
          Found in lib/routes.js and 1 other location - About 45 mins to fix
          lib/routes.js on lines 176..187

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

          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

                                      var completed = _.after(bundle.files.length, function() {
                                          archive.pipe(res);
                                          archive.finalize();
                                      });
          Severity: Minor
          Found in lib/localstorage.js and 1 other location - About 45 mins to fix
          lib/s3storage.js on lines 120..123

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

          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

                  req.errors.register([
                      new Error('An error occurred while trying to retrieve the template'),
                      {
                          code: 'ENOENT',
                          message: 'An invalid template has been selected. Please try again.',
          Severity: Minor
          Found in lib/routes.js and 1 other location - About 45 mins to fix
          lib/routes.js on lines 209..220

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

          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

          Avoid deeply nested control flow statements.
          Open

                                                  if(settings.email.sendCopy) {
                                                      email.cc = settings.email.sender;
                                                  }
          Severity: Major
          Found in lib/youtransfer.js - About 45 mins to fix

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

                                    var completed = _.after(bundle.files.length, function() {
                                        archive.pipe(res);
                                        archive.finalize();
                                    });
            Severity: Minor
            Found in lib/s3storage.js and 1 other location - About 45 mins to fix
            lib/localstorage.js on lines 124..127

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

            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 a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            Router.prototype.upload = function() {
                return function(req, res, next) {
            
                    req.errors.register(new Error('An error occurred while uploading your file(s).'));
                    var payload = req.files.payload || req.files['dz-payload'];
            Severity: Minor
            Found in lib/routes.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

            Severity
            Category
            Status
            Source
            Language