fabiocicerchia/salmonjs

View on GitHub

Showing 51 of 88 total issues

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

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

Function analiseRedisResponse has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    this.analiseRedisResponse = function (err, reply, redisId, container) {
        var id               = redisId.substr(0, 8),
            winstonCrawlerId = '[' + id.cyan + '-' + currentCrawler.idCrawler.magenta + ']',
            newId;

Severity: Minor
Found in src/crawler.js - About 1 hr to fix

Function execSubProcess has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    this.execSubProcess = function () {
        var idRequest = utils.sha1(this.url + this.type + JSON.stringify(this.data) + this.evt + this.xPath),
            subprocess,
            params  = {
                idCrawler:       this.idUri,
Severity: Minor
Found in src/crawler.js - About 1 hr to fix

Function processQueue has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    this.processQueue = function () {
        if (currentPool.queue.length === 0) {
            return;
        }

Severity: Minor
Found in src/pool.js - About 1 hr to fix

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

    this.handleError = function () {
        var winstonCrawlerId = '[' + currentCrawler.idUri.cyan + '-' + this.idCrawler.magenta + ']';

        if (currentCrawler.tries < config.crawler.attempts) {
            winston.info('%s' + ' Trying again in %s msec'.grey, winstonCrawlerId, config.crawler.delay);
Severity: Minor
Found in src/crawler.js - About 1 hr to fix

Function parsePost has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    this.parsePost = function () {
        this.handleQueryString();

        this.setUpPage(this.page);

Severity: Minor
Found in src/parser/phantom.js - About 1 hr to fix

Function checkAndRun has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    this.checkAndRun = function (settings) {
        var container   = {},
            redisId,
            id,
            winstonCrawlerId;
Severity: Minor
Found in src/crawler.js - About 1 hr to fix

Function dump has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    this.dump = function (callback) {
        var dump = {conf: conf, redis: {}, pool: {}};

        dump.pool.size            = pool.size;
        dump.pool.queue           = pool.queue;
Severity: Minor
Found in src/session.js - About 1 hr to fix

Function start has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    this.start = function() {
        var uri = currentInstance.resolveURI(argv.uri);

        winston.info('Start processing "' + uri.green + '"...');

Severity: Minor
Found in src/main.js - About 1 hr to fix

Function parseGet has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    this.parseGet = function () {
        this.handleQueryString();

        // InitPhantomJs
        this.setUpPage(this.page);
Severity: Minor
Found in src/parser/phantom.js - About 1 hr to fix

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

    this.run = function (settings) {
        this.url   = settings.url;
        this.type  = settings.type || 'GET';
        this.data  = settings.data || {
            GET:     {},
Severity: Minor
Found in src/crawler.js - About 1 hr to fix

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

    this.onEvaluateNonHtml = function () {
        var urls          = {
                mixed_full: [],
                mixed_rel:  [],
            },
Severity: Minor
Found in src/parser/phantom.js - About 1 hr to fix
Severity
Category
Status
Source
Language