fabiocicerchia/salmonjs

View on GitHub

Showing 88 of 88 total issues

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

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

        prototype._origAddEventListener    = prototype.addEventListener;
        prototype.addEventListener         = currentEventContainer.customAddEventListener;
Severity: Major
Found in src/events.js and 1 other location - About 3 hrs to fix
src/events.js on lines 257..264

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

Function Test has 85 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var Test = function (fsWrapper, glob, mainDir, utils, cases_dir) {
    /**
     * Test case directory.
     *
     * @property TEST_CASE_DIRECTORY
Severity: Major
Found in src/test.js - About 3 hrs to fix

Function FSWrapper has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

var FSWrapper = function (fs) {
    if (fs === undefined) {
        fs = require('fs');
    }

Severity: Minor
Found in src/fs.js - About 3 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

        this.report = {
            errors:     [],
            alerts:     [],
            confirms:   [],
            prompts:    [],
Severity: Major
Found in src/parser/phantom.js and 1 other location - About 3 hrs to fix
src/parser.js on lines 91..105

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

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.report = {
        errors:     [],
        alerts:     [],
        confirms:   [],
        prompts:    [],
Severity: Major
Found in src/parser.js and 1 other location - About 3 hrs to fix
src/parser/phantom.js on lines 553..567

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

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

        if (report.alerts.length > 0) {
            for (i in report.alerts) {
                if (report.alerts.hasOwnProperty(i)) {
                    html += '                <li>\n';
                    html += '                    <code>' + report.alerts[i] + '</code>\n';
Severity: Major
Found in src/reporter/report.js and 2 other locations - About 3 hrs to fix
src/reporter/report.js on lines 83..93
src/reporter/report.js on lines 113..123

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

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

        if (report.errors.length > 0) {
            for (i in report.errors) {
                if (report.errors.hasOwnProperty(i)) {
                    html += '                <li>\n';
                    html += '                    <pre>' + report.errors[i] + '</pre>\n';
Severity: Major
Found in src/reporter/report.js and 2 other locations - About 3 hrs to fix
src/reporter/report.js on lines 98..108
src/reporter/report.js on lines 113..123

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

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

        if (report.confirms.length > 0) {
            for (i in report.confirms) {
                if (report.confirms.hasOwnProperty(i)) {
                    html += '                <li>\n';
                    html += '                    <code>' + report.confirms[i] + '</code>\n';
Severity: Major
Found in src/reporter/report.js and 2 other locations - About 3 hrs to fix
src/reporter/report.js on lines 83..93
src/reporter/report.js on lines 98..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 99.

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

module.exports = function Parser() {
    /**
     * URL.
     *
     * @property url
Severity: Major
Found in src/parser.js - About 3 hrs to fix

Function onEvaluate has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    this.onEvaluate = function () {
        var urls = {},
            currentUrl = document.location.href,
            attribute,
            tag,
Severity: Major
Found in src/parser/phantom.js - About 2 hrs to fix

Function FSWrapper has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var FSWrapper = function (fs) {
    if (fs === undefined) {
        fs = require('fs');
    }

Severity: Major
Found in src/fs.js - About 2 hrs to fix

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

        if (links.hasOwnProperty('mixed_full')) {
            currentParser.links.mixed_full = [].map.call(links.mixed_full, function (item) {
                return utils.normaliseUrl(item, url);
            }).concat(currentParser.links.mixed_full).filter(utils.onlyUnique);
        }
Severity: Major
Found in src/parser/phantom.js and 1 other location - About 2 hrs to fix
src/parser/phantom.js on lines 702..706

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

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 (links.hasOwnProperty(tag) && tag !== 'form') {
                    currentParser.links[tag] = [].map.call(links[tag], function (item) {
                        return utils.normaliseUrl(item, url);
                    }).concat(currentParser.links[tag]).filter(utils.onlyUnique);
                }
Severity: Major
Found in src/parser/phantom.js and 1 other location - About 2 hrs to fix
src/parser/phantom.js on lines 727..731

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

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

var Pool = function (os, config, fork) {
    /**
     * Settings queue.
     *
     * @property queue
Severity: Major
Found in src/pool.js - About 2 hrs to fix

Function Session has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var Session = function (client, fs, zlib, utils, conf, pool) {
    /**
     * Dump the Redis DB.
     *
     * @method dump
Severity: Major
Found in src/session.js - About 2 hrs to fix

Function parsePage has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    this.parsePage = function (page) {
        var url, links = {}, events;

        currentParser.report.content = page.content;

Severity: Major
Found in src/parser/phantom.js - About 2 hrs to fix

Function parseINIString has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    this.parseINIString = function (data) {
        var regex   = {
                section: /^\s*\[\s*([^\]]*)\s*\]\s*$/,
                param:   /^\s*([\w\.\-\_\[\]]+)\s*=\s*(.*?)\s*$/,
                comment: /^\s*;.*$/
Severity: Minor
Found in src/utils.js - About 1 hr to fix

Function SalmonJS has a Cognitive Complexity of 15 (exceeds 5 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: Minor
Found in src/main.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 Pool has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

var Pool = function (os, config, fork) {
    /**
     * Settings queue.
     *
     * @property queue
Severity: Minor
Found in src/pool.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 createNewCaseFile has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    this.createNewCaseFile = function (url, name, data, callback) {
        if (currentTest.TEST_CASE_DIRECTORY === undefined) {
            return;
        }

Severity: Minor
Found in src/test.js - About 1 hr to fix
Severity
Category
Status
Source
Language