From 8898b271bbffbc1c7bef9dd924fd4fbc1a2cce19 Mon Sep 17 00:00:00 2001 From: soulgalore Date: Fri, 15 Aug 2014 09:14:35 +0200 Subject: [PATCH] jshint --- lib/collectors/assets.js | 4 ++-- lib/conf.js | 12 ++++++++---- lib/hb-helpers.js | 7 ++++--- lib/junitRenderer.js | 23 ++++++++++++++--------- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/lib/collectors/assets.js b/lib/collectors/assets.js index 5de06a67b..4ba222eea 100644 --- a/lib/collectors/assets.js +++ b/lib/collectors/assets.js @@ -11,7 +11,7 @@ var assets = {}; exports.processPage = function(pageData) { if (pageData.yslow) { pageData.yslow.comps.forEach(function(comp) { - if (comp.type != "doc") { + if (comp.type !== 'doc') { var url = comp.url; var asset = assets[url]; @@ -39,7 +39,7 @@ exports.generateResults = function() { }); return { - id: "assets", + id: 'assets', list: values }; }; diff --git a/lib/conf.js b/lib/conf.js index a6ac29e63..710b5fed3 100644 --- a/lib/conf.js +++ b/lib/conf.js @@ -20,16 +20,18 @@ config = require('nomnom').options({ metavar: '', help: 'The path to a plain text file with one URL on each row. Each line must end with a new line in the file.', callback: function(file) { - if (!fs.existsSync(file)) + if (!fs.existsSync(file)) { return 'Could not find the file:' + file; + } } }, sites: { metavar: '', help: 'The path to a plain text file with one URL on each row. Each line must end with a new line in the file.', callback: function(file) { - if (!fs.existsSync(file)) + if (!fs.existsSync(file)) { return 'Couldnt find the file:' + file; + } } }, version: { @@ -161,10 +163,12 @@ config = require('nomnom').options({ default: 3, help: 'The number of times you should test each URL when fetching timing metrics. Default is three times', callback: function(n) { - if (n !== parseInt(n)) + if (n !== parseInt(n)) { return 'You must specify an integer'; - else if (parseInt(n) <= 0) + } + else if (parseInt(n) <= 0) { return 'You must specify a positive integer'; + } } }, screenshot: { diff --git a/lib/hb-helpers.js b/lib/hb-helpers.js index 5fd75d6ca..52b88f827 100644 --- a/lib/hb-helpers.js +++ b/lib/hb-helpers.js @@ -265,11 +265,12 @@ module.exports.registerHelpers = function registerHelpers() { var itemsLastRow = size % perRow; // TODO make this generic, now it's hardcoded to 3 per row - if(size - index <= itemsLastRow) { - if (itemsLastRow === 2) + if (size - index <= itemsLastRow) { + if (itemsLastRow === 2) { return 6; - else + } else { return 12; + } } return 4; diff --git a/lib/junitRenderer.js b/lib/junitRenderer.js index c754aa8ed..313701e04 100644 --- a/lib/junitRenderer.js +++ b/lib/junitRenderer.js @@ -10,8 +10,6 @@ var builder = require('xmlbuilder'), path = require('path'), util = require('./util'); -module.exports = JUnitRenderer; - function JUnitRenderer(collector) { this.collector = collector; this.ruleTestsuites = builder.create('testsuites', { @@ -80,9 +78,8 @@ function generateBrowserTimeTestSuitePerPage(browserTimeData, timingTestsuites) } function generateTimingTestCase(stats, timing, run, testsuite, limit) { - var browser = run.pageData.browserName, - version = run.pageData.browserVersion, - url = run.pageData.url; + var browser = run.pageData.browserName; + var version = run.pageData.browserVersion; // The time in Jenkins needs to be in seconds var testCase = testsuite.ele('testcase', { @@ -170,10 +167,15 @@ function generateRuleTestSuitePerPage(url, score, rules, ruleDictionary, function isFailure(ruleid, value) { if (config.thresholds) { - if (config.thresholds.hasOwnProperty(ruleid)) + if (config.thresholds.hasOwnProperty(ruleid)) { return (value < config.thresholds[ruleid]); - else return (value < config.threshold); - } else return (value < config.threshold); + } + else { + return (value < config.threshold); + } + } else { + return (value < config.threshold); + } } JUnitRenderer.prototype.renderAfterFullAnalyse = function(cb) { @@ -197,6 +199,9 @@ JUnitRenderer.prototype.renderAfterFullAnalyse = function(cb) { }; function renderXMLFile(xml, fileName) { - console.log("Writing " + fileName); + console.log('Writing ' + fileName); fs.outputFileSync(path.join(config.run.absResultDir,fileName), xml); } + + +module.exports = JUnitRenderer;