adamrenklint/asimov-static

View on GitHub

Showing 136 of 136 total issues

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

    if (!model) {

      model = collection.create({
        'name': name,
        'insertConstructor': params.construct,
Severity: Major
Found in lib/helpers/script.js and 1 other location - About 1 hr to fix
lib/helpers/style.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 68.

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 (!model) {

      model = collection.create({
        'name': name,
        'pageUrl': self.currentUrl,
Severity: Major
Found in lib/helpers/style.js and 1 other location - About 1 hr to fix
lib/helpers/script.js on lines 25..34

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

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

  'run': function (src, params) {

    var self = this;

    if (typeof src !== 'string') {
Severity: Minor
Found in lib/helpers/image.js - About 1 hr to fix

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

      'run': function (model) {
    
        var self = this;
        var deferred = self.deferred();
    
    
    Severity: Minor
    Found in lib/render/ScriptRenderJob.js - About 1 hr to fix

      Function run has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        'run': function (href, innerText, params, block) {
      
          var self = this;
      
          if (typeof href !== 'string') {
      Severity: Minor
      Found in lib/helpers/link.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 filter has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        'filter': function (test, options) {
      
          var self = this;
          options || (options = {});
      
      
      Severity: Minor
      Found in lib/nodes/PageNodesCollection.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 getNextBatch has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        'getNextBatch': function () {
      
          var self = this;
          var limit = self.limit;
          var models = [];
      Severity: Minor
      Found in lib/render/Queue.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 plugin has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function plugin () {
      
        asimov
          .config('defaultLangCode', 'en')
          .config('defaultLangFallback', true)
      Severity: Minor
      Found in index.js - About 1 hr to fix

        Function start has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          'start': function () {
        
            var self = this;
            var app = self.app = express();
        
        
        Severity: Minor
        Found in lib/server/Server.js - About 1 hr to fix

          Function destroy has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            destroy: function(options) {
              options = options ? _.clone(options) : {};
              var model = this;
              var success = options.success;
          
          
          Severity: Minor
          Found in lib/core/Model.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 recursiveDelete has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            'recursiveDelete': function (path) {
          
              var self = this;
          
              if (!self.pathExists(path)) return;
          Severity: Minor
          Found in lib/core/Filesystem.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 run has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            'run': function (src, params) {
          
              var self = this;
          
              if (typeof src !== 'string') {
          Severity: Minor
          Found in lib/helpers/image.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 html has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            'html': function (tagName, data) {
          
              var self = this;
          
              if (!tagName) {
          Severity: Minor
          Found in lib/helpers/Helper.js - About 1 hr to fix

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

              'parse': function (model, raw, dependencies) {
            
                var self = this;
                var attributes = model.attributes;
                raw = raw || attributes.raw;
            Severity: Minor
            Found in lib/parsers/ScriptParser.js - About 1 hr to fix

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

                'initialize': function () {
              
                  var self = this;
                  _super.initialize.apply(self, arguments);
              
              
              Severity: Minor
              Found in lib/_commands/Create.js - About 1 hr to fix

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

                  save: function(key, val, options) {
                    var attrs, method, xhr, attributes = this.attributes;
                
                    // Handle both `"key", value` and `{key: value}` -style arguments.
                    if (key == null || typeof key === 'object') {
                Severity: Minor
                Found in lib/core/Model.js - About 1 hr to fix

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

                    'getPathType': function (path) {
                  
                      var self = this;
                  
                      _.each(self.options.paths.initializers, function (initializersPath) {
                  Severity: Minor
                  Found in lib/watcher/Watcher.js - About 1 hr to fix

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

                      beforeEach(function () {
                    
                        var collection = new Collection();
                    
                        instance = new Active({
                    Severity: Major
                    Found in __tests/helpers/Active.test.js and 2 other locations - About 1 hr to fix
                    __tests/helpers/Children.test.js on lines 31..42
                    __tests/helpers/Menu.test.js on lines 31..42

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

                    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

                      beforeEach(function () {
                    
                        var queue = new Collection();
                    
                        instance = new Menu({
                    Severity: Major
                    Found in __tests/helpers/Menu.test.js and 2 other locations - About 1 hr to fix
                    __tests/helpers/Active.test.js on lines 10..21
                    __tests/helpers/Children.test.js on lines 31..42

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

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

                      'lazyLoadMiddleware': function (req, res, next) {
                    
                        var self = this;
                    
                        var middleware = self.resolveMiddleware(req.url) || [];
                    Severity: Minor
                    Found in lib/server/Server.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

                    Severity
                    Category
                    Status
                    Source
                    Language