fabiocicerchia/salmonjs

View on GitHub

Showing 51 of 88 total issues

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

    this.onLoadFinished = function () {
        if (settings.sanitise !== undefined && settings.sanitise.toString() === 'true') {
            var tmp_fn  = fs.workingDirectory + '/file_' + ((new Date()).getTime()) + '.html',
                args    = [ fs.workingDirectory + '/src/tidy.js', tmp_fn ],
                process;
Severity: Minor
Found in src/parser/phantom.js - About 1 hr to fix

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

    list: function (dir, done) {
        var FSWrapper = require('./fs'),
            fsWrapper = new FSWrapper(),
            results   = [],
            list      = fsWrapper.readdirSync(dir),
Severity: Minor
Found in src/glob.js - About 1 hr to fix

Function Crawler has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

var Crawler = function (config, spawn, test, client, winston, fs, optimist, utils) {
Severity: Major
Found in src/crawler.js - About 1 hr to fix

Avoid deeply nested control flow statements.
Open

                        if (report.resources[i].headers.hasOwnProperty(j)) {
                            html += report.resources[i].headers[j].name + ': ' + report.resources[i].headers[j].value + '\n';
                        }
Severity: Major
Found in src/reporter/report.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if (attribute.hasOwnProperty(attr)) {
                            elements = document.querySelectorAll(tag);
                            links = [];
                            if (elements.length > 0) {
                                links = [].map.call(elements, function (item) {
Severity: Major
Found in src/parser/phantom.js - About 45 mins to fix

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

var Session = function (client, fs, zlib, utils, conf, pool) {
Severity: Minor
Found in src/session.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if (events[curr_attr] === undefined) {
                            events[curr_attr] = [];
                        }
Severity: Major
Found in src/events.js - About 45 mins to fix

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

module.exports = function Parser() {
    /**
     * URL.
     *
     * @property url
Severity: Minor
Found in src/parser.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 parse has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    this.parse = function (url, type, data, evt, xPath) {
Severity: Minor
Found in src/parser.js - About 35 mins to fix

Function Test has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

var Test = function (fsWrapper, glob, mainDir, utils, cases_dir) {
Severity: Minor
Found in src/test.js - About 35 mins to fix

Avoid too many return statements within this function.
Open

            return;
Severity: Major
Found in src/pool.js - About 30 mins to fix
Severity
Category
Status
Source
Language