zipfworks/ember-prerender

View on GitHub

Showing 22 of 22 total issues

Function beforeSend has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  beforeSend: function(req, res, page, next) {
    if (page.html) {
      var headerMatch = /<meta property=['"]prerender:([^'"]+)['"] content=['"]([^'"]+)['"]>/g;
      var head = page.html.split('</head>', 1).pop();
      var match;
Severity: Minor
Found in lib/plugins/httpHeaders.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

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

        function (html) {
          if (_this.hasPageCallback) {
            _this.hasPageCallback = false;
            _this.currentPage.statusCode = 200;
            _this.currentPage.html = html;
Severity: Major
Found in lib/engines/phantom.js and 1 other location - About 1 hr to fix
lib/engines/webdriver.js on lines 101..108

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

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

      _this.driver.getPageSource().then(function(html) {
        if (_this.hasPageCallback) {
          _this.hasPageCallback = false;
          _this.currentPage.statusCode = 200;
          _this.currentPage.html = html;
Severity: Major
Found in lib/engines/webdriver.js and 1 other location - About 1 hr to fix
lib/engines/phantom.js on lines 123..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 74.

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

PhantomEngine.prototype.init = function(appUrl, initCallback, errorCallback, beforeInitCallback) {
  var _this = this;

  this.initializationCallback = initCallback;
  this.hasInitializationCallback = true;
Severity: Minor
Found in lib/engines/phantom.js - About 1 hr to fix

    Function init has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    WebDriverEngine.prototype.init = function(appUrl, initCallback, errorCallback, beforeInitCallback) {
      var _this = this;
    
      this.initializationCallback = initCallback;
      this.hasInitializationCallback = true;
    Severity: Minor
    Found in lib/engines/webdriver.js - About 1 hr to fix

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

        this.phantom = phantom.create("--load-images=false", "--ignore-ssl-errors=true", "--ssl-protocol=any", this.engineSettings, function(ph) {
          _this.phantom.ph = ph;
          _this.phantom.ph.createPage(function(phantomPage) {
            _this.phantom.page = phantomPage;
      
      
      Severity: Minor
      Found in lib/engines/phantom.js - About 1 hr to fix

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

        JSDomEngine.prototype.init = function(appUrl, initCallback, errorCallback, beforeInitCallback) {
          var _this = this;
        
          this.initializationCallback = initCallback;
          this.hasInitializationCallback = true;
        Severity: Minor
        Found in lib/engines/jsdom.js - About 1 hr to fix

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

          PrerenderRenderer.prototype.afterRender = function(page) {
            var _this = this;
          
            clearTimeout(this.renderTimer);
            this.renderTimer = null;
          Severity: Minor
          Found in lib/renderer.js - About 1 hr to fix

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

              beforeSend: function(req, res, page, next) {
                if (page.html) {
                  var headerMatch = /<meta property=['"]prerender:([^'"]+)['"] content=['"]([^'"]+)['"]>/g;
                  var head = page.html.split('</head>', 1).pop();
                  var match;
            Severity: Minor
            Found in lib/plugins/httpHeaders.js - About 1 hr to fix

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

              PrerenderLogger.prototype.log = function(level) {
                var _this = this;
              
                if (this.levels[this.config.level] > this.levels[level]) {
                  return;
              Severity: Minor
              Found in lib/logger.js - About 1 hr to fix

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

                module.exports = function(environment) {
                  var ENV = {
                    modulePrefix: 'example',
                    environment: environment,
                    baseURL: '/',
                Severity: Minor
                Found in example/config/environment.js - About 1 hr to fix

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

                  JSDomEngine.prototype.onPageReady = function() {
                    var _this = this;
                  
                    if (this.hasInitializationCallback) {
                      this.hasInitializationCallback = false;
                  Severity: Minor
                  Found in lib/engines/jsdom.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

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

                    if (this.job) {
                      this.logger.log('error', "Timed out while rendering: " + this.job.page.url);
                      this.terminateActiveJob();
                    }
                  Severity: Minor
                  Found in lib/renderer.js and 1 other location - About 55 mins to fix
                  lib/renderer.js on lines 47..50

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

                  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 (this.job) {
                      this.logger.log('error', "Engine stopped before rendering: " + this.job.page.url);
                      this.terminateActiveJob();
                    }
                  Severity: Minor
                  Found in lib/renderer.js and 1 other location - About 55 mins to fix
                  lib/renderer.js on lines 198..201

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

                  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

                  PrerenderServer.prototype.hrtimeToMs = function(hr) {
                    return (hr[0] * 1000 + parseInt(hr[1] / 1000000, 10));
                  };
                  Severity: Minor
                  Found in lib/server.js and 1 other location - About 50 mins to fix
                  lib/renderer.js on lines 280..282

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

                  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

                  PrerenderRenderer.prototype.hrtimeToMs = function(hr) {
                    return (hr[0] * 1000 + parseInt(hr[1] / 1000000, 10));
                  };
                  Severity: Minor
                  Found in lib/renderer.js and 1 other location - About 50 mins to fix
                  lib/server.js on lines 169..171

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

                  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 (headerName === 'Location') {
                                  headerValue = decodeURIComponent(headerValue);
                                }
                  Severity: Major
                  Found in lib/plugins/httpHeaders.js - About 45 mins to fix

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

                    PrerenderServer.prototype.onRequest = function(req, res) {
                      var addr = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
                      var agent = req.headers['user-agent'] || "Unknown";
                      var user = addr + ' (' + agent + ')';
                      var reqUrl = this.parseURL(req.url);
                    Severity: Minor
                    Found in lib/server.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 pluginEvent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    PrerenderRenderer.prototype.pluginEvent = function(methodName, args, callback) {
                      var _this = this;
                      var index = 0;
                    
                      callback = callback || function() {};
                    Severity: Minor
                    Found in lib/renderer.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 onPageReady has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                    WebDriverEngine.prototype.onPageReady = function() {
                      var _this = this;
                    
                      if (this.hasInitializationCallback) {
                        this.hasInitializationCallback = false;
                    Severity: Minor
                    Found in lib/engines/webdriver.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