adamrenklint/asimov-static

View on GitHub

Showing 59 of 136 total issues

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

  'initialize': function () {

    var self = this;
    _super.initialize.apply(self, arguments);

Severity: Minor
Found in lib/helpers/Helper.js - About 1 hr to fix

    Function where has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      where: function(attrs, first) {
        if (_.isEmpty(attrs)) return first ? void 0 : [];
        return this[first ? 'find' : 'filter'](function(model) {
          for (var key in attrs) {
            if (attrs[key] !== model.get(key)) return false;
    Severity: Minor
    Found in lib/core/Collection.js - About 55 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

    Function parse has a Cognitive Complexity of 8 (exceeds 5 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 45 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

    Function filename has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          var filename = match.replace(regExp, function (match, prefix, firstQuote, name, lastChar, lastQuote) {
    Severity: Minor
    Found in lib/parsers/StyleSheetParser.js - About 45 mins to fix

      Function parse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        'parse': function (model, raw, dependencies) {
      
          var self = this;
          var attributes = model.attributes;
          raw = self.assertAttributes(attributes, raw);
      Severity: Minor
      Found in lib/parsers/TemplateParser.js - About 45 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

      Consider simplifying this complex logical expression.
      Open

          if (options.autoEncode && (self.hasFileExtension(filename, 'txt') || self.hasFileExtension(filename, 'tmpl') || self.hasFileExtension(filename, 'html') || self.hasFileExtension(filename, 'styl') || self.hasFileExtension(filename, 'js'))) {
            return fs.readFileSync(path, 'utf8');
          }
          else {
            return fs.readFileSync(path);
      Severity: Major
      Found in lib/core/Filesystem.js - About 40 mins to fix

        Function create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          create: function(model, options) {
            options = options ? _.clone(options) : {};
            if (!(model = this._prepareModel(model, options))) return false;
            if (!options.wait) this.add(model, options);
            var collection = this;
        Severity: Minor
        Found in lib/core/Collection.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

        Function notFoundMiddleware has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = function notFoundMiddleware (req, res, next) {
        
          var urlLangCode = getUrlLangCode(req.url);
          var defaultLangCode = asimov.config('defaultLangCode');
          var supported = new locale.Locales(asimov.config('languages'));
        Severity: Minor
        Found in lib/middleware/languageRedirect.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

        Function remove has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          remove: function(models, options) {
            models = _.isArray(models) ? models.slice() : [models];
            options || (options = {});
            var i, l, index, model;
            for (i = 0, l = models.length; i < l; i++) {
        Severity: Minor
        Found in lib/core/Collection.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

        Function changedAttributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          changedAttributes: function(diff) {
            if (!diff) return this.hasChanged() ? _.clone(this.changed) : false;
            var val, changed = false;
            var old = this._changing ? this._previousAttributes : this.attributes;
            for (var attr in diff) {
        Severity: Minor
        Found in lib/core/Model.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

        Avoid too many return statements within this function.
        Open

              return 'script';
        Severity: Major
        Found in lib/watcher/Watcher.js - About 30 mins to fix

          Function getPathType has a Cognitive Complexity of 6 (exceeds 5 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 25 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

          Function mergeDefaultLangAttributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            'mergeDefaultLangAttributes': function (attributes) {
              var self = this;
              if (asimov.config('defaultLangFallback') && attributes.langCode !== asimov.config('defaultLangCode')) {
                var defaultLangUrl = '/' + attributes.url.split('/').slice(2).join('/');
                var defaultLangPage = self.get(defaultLangUrl);
          Severity: Minor
          Found in lib/nodes/PageNodesCollection.js - About 25 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

          Function fetch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            fetch: function(options) {
              options = options ? _.clone(options) : {};
              if (options.parse === void 0) options.parse = true;
              var model = this;
              var success = options.success;
          Severity: Minor
          Found in lib/core/Model.js - About 25 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

          Function _onModelEvent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            _onModelEvent: function(event, model, collection, options) {
              if ((event === 'add' || event === 'remove') && collection !== this) return;
              if (event === 'destroy') this.remove(model, options);
              if (model && event === 'change:' + model.idAttribute) {
                delete this._byId[model.previous(model.idAttribute)];
          Severity: Minor
          Found in lib/core/Collection.js - About 25 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

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

            'run': function (adress, params, block) {
          
              var self = this;
          
              if (typeof adress !== 'string') {
          Severity: Minor
          Found in lib/helpers/email.js - About 25 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

          Function fetch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            fetch: function(options) {
              options = options ? _.clone(options) : {};
              if (options.parse === void 0) options.parse = true;
              var success = options.success;
              var collection = this;
          Severity: Minor
          Found in lib/core/Collection.js - About 25 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

          Function healthCheckMiddleware has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          function healthCheckMiddleware (req, res, next) {
          
            if (req.url === '/health' || req.url === '/api/health') {
              if (healthy) {
                res.send(up);
          Severity: Minor
          Found in lib/middleware/health.js - About 25 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

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

            'run': function (url, params, block) {
          
              var self = this;
              var children = [];
              var langCode = 'en';
          Severity: Minor
          Found in lib/helpers/menu.js - About 25 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