Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,27 @@ if (cli.flags.reporter && cli.flags.reporter !== 'json' && cli.flags.reporter !=
debug('Success');
switch(cli.flags.reporter) {
case 'xml':
var serializer = new EasyXml();
console.log(serializer.render(data));
var serializer = new EasyXml({
manifest: true
});

// Remove some heavy parts of the results object
delete data.toolsResults;
delete data.javascriptExecutionTree;

var xmlOutput = serializer.render(data);

// Remove special chars from XML tags: # [ ]
xmlOutput = xmlOutput.replace(/<([^>]*)#([^>]*)>/g, '<$1>');
xmlOutput = xmlOutput.replace(/<([^>]*)\[([^>]*)>/g, '<$1>');
xmlOutput = xmlOutput.replace(/<([^>]*)\]([^>]*)>/g, '<$1>');

// Remove special chars from text content: \n \0
xmlOutput = xmlOutput.replace(/(<[a-zA-Z]*>[^<]*)\n([^<]*<\/[a-zA-Z]*>)/g, '$1$2');
xmlOutput = xmlOutput.replace(/\0/g, '');
xmlOutput = xmlOutput.replace(/\uFFFF/g, '');

console.log(xmlOutput);
break;
default:
console.log(JSON.stringify(data, null, 2));
Expand Down
6 changes: 3 additions & 3 deletions front/src/views/rule.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ <h3 ng-if="rule.offendersObj.count >= 0"><ng-pluralize count="rule.offendersObj.
</div>
</div>

<div ng-repeat="(file, fileDetails) in rule.offendersObj.byFile track by $index">
<div ng-repeat="fileDetails in rule.offendersObj.byFile track by $index">
<h3>
<ng-pluralize count="fileDetails.count" when="{'one': '1 offender', 'other': '{} offenders'}"></ng-pluralize>
in
<url-link ng-if="file !== 'Inline CSS'" url="file" max-length="80"></url-link>
<span ng-if="file === 'Inline CSS'">inline CSS</span>
<url-link ng-if="fileDetails.url !== 'Inline CSS'" url="fileDetails.url" max-length="80"></url-link>
<span ng-if="fileDetails.url === 'Inline CSS'">inline CSS</span>
</h3>

<div class="offendersTable">
Expand Down
19 changes: 13 additions & 6 deletions lib/offendersHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,24 +207,31 @@ var OffendersHelpers = function() {
};

this.orderByFile = function(offenders) {
var byFile = {};
var byFileObj = {};

offenders.forEach(function(offender) {
var file = offender.file || 'Inline CSS';
delete offender.file;

if (!byFile[file]) {
byFile[file] = {
if (!byFileObj[file]) {
byFileObj[file] = {
url: file,
count: 0,
offenders: []
};
}

byFile[file].count ++;
byFile[file].offenders.push(offender);
byFileObj[file].count ++;
byFileObj[file].offenders.push(offender);
});

return {byFile: byFile};
// Transform object into array
var byFileArray = [];
for (var file in byFileObj) {
byFileArray.push(byFileObj[file]);
}

return {byFile: byFileArray};
};

};
Expand Down
Loading