NateFerrero/amna

View on GitHub

Showing 93 of 93 total issues

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

            doc.save(function (err) {
                if (err) {
                    log('<fail> save decaying set key', this.key, err);
                    return done(err);
                }
Severity: Major
Found in src/lib/cache.js and 1 other location - About 2 hrs to fix
src/lib/cache.js on lines 79..86

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

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

    var setupDocumentPost = function (collection, options) {
        /**
         * POST /collection/:id
         */
        if (!options.readOnly && options.documentPost !== false) {
Severity: Major
Found in src/lib/collection.js and 2 other locations - About 2 hrs to fix
src/lib/collection.js on lines 194..203
src/lib/collection.js on lines 205..214

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

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

File collection.js has 262 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

/**
 * AMNA: Amazing Mongoose Node.js API
 *
Severity: Minor
Found in src/lib/collection.js - About 2 hrs to fix

    Function setClass has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            setClass: function(element, add, remove, options) {
              options = parseAnimateOptions(options);
    
              var STORAGE_KEY = '$$animateClasses';
              element = angular.element(element);
    Severity: Major
    Found in examples/uploader/public/js/angular-animate.js - About 2 hrs to fix

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

              beforeRemoveClass: function(element, className, animationCompleted, options) {
                options = options || {};
                var cancellationMethod = animateBefore('removeClass', element, suffixClasses(className, '-remove'), options.from);
                if (cancellationMethod) {
                  afterReflow(element, animationCompleted);
      Severity: Major
      Found in examples/uploader/public/js/angular-animate.js and 1 other location - About 2 hrs to fix
      examples/uploader/public/js/angular-animate.js on lines 2082..2091

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

      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

              beforeAddClass: function(element, className, animationCompleted, options) {
                options = options || {};
                var cancellationMethod = animateBefore('addClass', element, suffixClasses(className, '-add'), options.from);
                if (cancellationMethod) {
                  afterReflow(element, animationCompleted);
      Severity: Major
      Found in examples/uploader/public/js/angular-animate.js and 1 other location - About 2 hrs to fix
      examples/uploader/public/js/angular-animate.js on lines 2093..2102

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

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

      module.exports = function () {
      
          var Stack = function Stack() {
              this.stack = [];
          };
      Severity: Minor
      Found in src/lib/stack.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 2 locations. Consider refactoring.
      Open

      module.exports = function (amna) {
          return function get() {
              var args = Array.prototype.slice.call(arguments);
              return amna.$express.get.apply(amna.$express, args);
          };
      Severity: Major
      Found in src/lib/get.js and 1 other location - About 2 hrs to fix
      src/lib/set.js on lines 11..16

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

      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

      module.exports = function (amna) {
          return function set() {
              var args = Array.prototype.slice.call(arguments);
              return amna.$express.set.apply(amna.$express, args);
          };
      Severity: Major
      Found in src/lib/set.js and 1 other location - About 2 hrs to fix
      src/lib/get.js on lines 11..16

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

      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 (!self.permissionGranted &&
                          (!self.doc.createdBy || !self.req.user._id.equals(self.doc.createdBy))) {
                          return self.noaccess();
                      }
      Severity: Major
      Found in src/lib/collection.js and 1 other location - About 2 hrs to fix
      src/lib/collection.js on lines 282..285

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

                      if (!self.permissionGranted &&
                          (!self.doc.createdBy || !self.req.user._id.equals(self.doc.createdBy))) {
                          return self.noaccess();
                      }
      Severity: Major
      Found in src/lib/collection.js and 1 other location - About 2 hrs to fix
      src/lib/collection.js on lines 247..250

      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

      Function exports has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports = function (amna, log) {
      
          /**
           * Ensure requests fail until mongo is available
           */
      Severity: Minor
      Found in src/lib/mongo.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 pageAndDeleteQuery has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          amna.pageAndDeleteQuery = function (self) {
              var query = {};
              var qOpts = self.req.jsonQueryOptions;
      
              /**
      Severity: Minor
      Found in src/lib/collection.js - About 1 hr to fix

        Function exports has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function (amna, passport) {
            if (typeof amna.authentication.facebook !== 'function') {
                throw new Error('amna.authentication.facebook must be: function  (profile, tokens, done)');
            }
        
        
        Severity: Minor
        Found in src/lib/authentication-facebook.js - About 1 hr to fix

          Function animateSetup has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                function animateSetup(animationEvent, element, className, styles) {
                  var structural = ['ng-enter','ng-leave','ng-move'].indexOf(className) >= 0;
          
                  var cacheKey = getCacheKey(element);
                  var eventCacheKey = cacheKey + ' ' + className;
          Severity: Minor
          Found in examples/uploader/public/js/angular-animate.js - About 1 hr to fix

            Function exports has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function (amna, log) {
            
                var Route = function Route(method, url, handler) {
                    this.method = method;
                    this.url = url;
            Severity: Minor
            Found in src/lib/route.js - About 1 hr to fix

              Function encodeJsonSchema has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  MongooseThing.encodeJsonSchema = function (schema) {
                      var json;
              
                      if (schema && schema.ref) {
                          return {type: 'reference', thing: schema.ref};
              Severity: Minor
              Found in src/lib/thing-mongoose.js - About 1 hr to fix

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

                        function run(fns, cancellations, allCompleteFn) {
                          var animations = [];
                          forEach(fns, function(animation) {
                            animation.fn && animations.push(animation);
                          });
                Severity: Minor
                Found in examples/uploader/public/js/angular-animate.js - About 1 hr to fix

                  Function exports has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  module.exports = function (amna, log) {
                  
                      amna.$MODULES_DIR = 'amna_modules';
                  
                      amna.$modules = [];
                  Severity: Minor
                  Found in src/lib/registerModules.js - About 1 hr to fix

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

                        amna.things.Upload.model.find(query, function(err, result) {
                            if (err) {
                                return self.err(err);
                            } else {
                                return self.done(result);
                    Severity: Major
                    Found in examples/uploader/amna_modules/upload.js and 1 other location - About 1 hr to fix
                    examples/chat/server.js on lines 29..35

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

                    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