fabiocicerchia/salmonjs

View on GitHub

Showing 88 of 88 total issues

Function PhantomParser has a Cognitive Complexity of 176 (exceeds 5 allowed). Consider refactoring.
Open

var PhantomParser = function (utils, spawn, page, settings) {
    /**
     * The WebPage element.
     *
     * @property page
Severity: Minor
Found in src/parser/phantom.js - About 3 days 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 PhantomParser has 456 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var PhantomParser = function (utils, spawn, page, settings) {
    /**
     * The WebPage element.
     *
     * @property page
Severity: Major
Found in src/parser/phantom.js - About 2 days to fix

Function Crawler has 421 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var Crawler = function (config, spawn, test, client, winston, fs, optimist, utils) {
    /**
     * Number of tries before stop to execute the same request.
     *
     * @property tries
Severity: Major
Found in src/crawler.js - About 2 days to fix

Function EventContainer has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring.
Open

var EventContainer = function () {
    /**
     * The Event Container.
     *
     * @property container
Severity: Minor
Found in src/events.js - About 1 day 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 Crawler has a Cognitive Complexity of 75 (exceeds 5 allowed). Consider refactoring.
Open

var Crawler = function (config, spawn, test, client, winston, fs, optimist, utils) {
    /**
     * Number of tries before stop to execute the same request.
     *
     * @property tries
Severity: Minor
Found in src/crawler.js - About 1 day 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 reporter has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring.
Open

var reporter = function (utils) {
    this.generateHTML = function (currentCrawler, reportName, report) {
        var i, j, failed, html = '<!DOCTYPE html>\n';

        html += '<html lang="en">\n';
Severity: Minor
Found in src/reporter/report.js - About 1 day 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 Utils has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
Open

var Utils = function (crypto) {
    /**
     * Serialise an object as questring.
     *
     * @method serialise
Severity: Minor
Found in src/utils.js - About 1 day 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 exports has 194 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(grunt) {
    grunt.initConfig({
        jasmine_node: {
            coverage: {
                report: [ 'lcov', 'html' ],
Severity: Major
Found in Gruntfile.js - About 7 hrs to fix

File phantom.js has 474 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 *               __                         _____ _______
 * .-----.---.-.|  |.--------.-----.-----._|     |     __|
 * |__ --|  _  ||  ||        |  _  |     |       |__     |
 * |_____|___._||__||__|__|__|_____|__|__|_______|_______|
Severity: Minor
Found in src/parser/phantom.js - About 7 hrs to fix

Function Utils has 184 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var Utils = function (crypto) {
    /**
     * Serialise an object as questring.
     *
     * @method serialise
Severity: Major
Found in src/utils.js - About 7 hrs to fix

Function reporter has 156 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var reporter = function (utils) {
    this.generateHTML = function (currentCrawler, reportName, report) {
        var i, j, failed, html = '<!DOCTYPE html>\n';

        html += '<html lang="en">\n';
Severity: Major
Found in src/reporter/report.js - About 6 hrs to fix

File crawler.js has 424 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 *               __                         _____ _______
 * .-----.---.-.|  |.--------.-----.-----._|     |     __|
 * |__ --|  _  ||  ||        |  _  |     |       |__     |
 * |_____|___._||__||__|__|__|_____|__|__|_______|_______|
Severity: Minor
Found in src/crawler.js - About 6 hrs to fix

Function generateHTML has 154 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    this.generateHTML = function (currentCrawler, reportName, report) {
        var i, j, failed, html = '<!DOCTYPE html>\n';

        html += '<html lang="en">\n';
        html += '    <head>\n';
Severity: Major
Found in src/reporter/report.js - About 6 hrs to fix

Function EventContainer has 141 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var EventContainer = function () {
    /**
     * The Event Container.
     *
     * @property container
Severity: Major
Found in src/events.js - About 5 hrs to fix

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

        for (var cookie in this.data.COOKIE) {
            if (this.data.COOKIE.hasOwnProperty(cookie)) {
                var domain = '';
                if (this.url.substr(0, 7) !== 'file://') {
                    domain = this.url.replace(/^http(s)?:\/\/([^\/]+)\/?.*$/, '$2');
Severity: Major
Found in src/parser/phantom.js and 1 other location - About 4 hrs to fix
src/parser/phantom.js on lines 206..219

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

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

        for (var cookie in this.data.COOKIE) {
            if (this.data.COOKIE.hasOwnProperty(cookie)) {
                var domain = '';
                if (this.url.substr(0, 7) !== 'file://') {
                    domain = this.url.replace(/^http(s)?:\/\/([^\/]+)\/?.*$/, '$2');
Severity: Major
Found in src/parser/phantom.js and 1 other location - About 4 hrs to fix
src/parser/phantom.js on lines 254..267

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

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

var SalmonJS = function (redis, argv) {
    // TODO: convert to this.*
    var IOC       = require('./ioc'),
        ioc       = new IOC(),
        logLevels = [ 'error', 'warn', 'info', 'debug' ],
Severity: Major
Found in src/main.js - About 4 hrs to fix

Function Test has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

var Test = function (fsWrapper, glob, mainDir, utils, cases_dir) {
    /**
     * Test case directory.
     *
     * @property TEST_CASE_DIRECTORY
Severity: Minor
Found in src/test.js - About 4 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

Function processPage has 112 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    this.processPage = function (content) {
        currentCrawler.processing = true;

        var result,
            links,
Severity: Major
Found in src/crawler.js - About 4 hrs to fix

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

    this.overrideAttributeHandler = function (object) {
        var prototype = object.prototype === undefined ? object : object.prototype;

        prototype._origSetAttribute    = prototype.setAttribute;
        prototype.setAttribute         = currentEventContainer.customSetAttribute;
Severity: Major
Found in src/events.js and 1 other location - About 3 hrs to fix
src/events.js on lines 240..247

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

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