golang-cover-parse
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "golang-cover-parse", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Parse Go coverage to JavaSript object, based on output from lcov-parse", | ||
@@ -21,5 +21,4 @@ "main": "source/index.js", | ||
"dependencies": { | ||
"mocha": "^2.2.5", | ||
"xml2js": "^0.4.9" | ||
"mocha": "^2.2.5" | ||
} | ||
} |
@@ -17,9 +17,5 @@ "use strict"; | ||
var lines = modes[ 1 ].replace( "\r\n", "\n" ).split( /[\n\r]/g ); | ||
lines = lines.slice( 1 ); // the first line is just the mode type | ||
lines.forEach( function ( line ) | ||
modes.forEach( function ( mode ) | ||
{ | ||
var parts = line.split( ":" ); | ||
if( !parts.length ) | ||
if( !mode.length ) | ||
{ | ||
@@ -29,54 +25,67 @@ return; | ||
var path = parts[ 0 ]; | ||
var values = parts[ 1 ]; | ||
var lines = mode.replace( "\r\n", "\n" ).split( /[\n\r]/g ); | ||
lines = lines.slice( 1 ); // the first line is just the mode type | ||
if( !path || !values ) | ||
lines.forEach( function ( line ) | ||
{ | ||
return; | ||
} | ||
var parts = line.split( ":" ); | ||
if( !parts.length ) | ||
{ | ||
return; | ||
} | ||
if( !files[ files.length - 1 ] || files[ files.length - 1 ].file !== path ) | ||
{ | ||
var name = path.split( "/" ); | ||
name = name[ name.length - 1 ]; | ||
var path = parts[ 0 ]; | ||
var values = parts[ 1 ]; | ||
files.push( { | ||
title: name, | ||
file: path, | ||
lines: { | ||
found: 0, | ||
hit: 0, | ||
details: [] | ||
} | ||
} ); | ||
} | ||
if( !path || !values ) | ||
{ | ||
return; | ||
} | ||
var file = files[ files.length - 1 ]; | ||
if( !files[ files.length - 1 ] || files[ files.length - 1 ].file !== path ) | ||
{ | ||
var name = path.split( "/" ); | ||
name = name[ name.length - 1 ]; | ||
var startLine = Number( values.split( "," )[ 0 ].split( "." )[ 0 ] ); | ||
var endLine = Number( values.split( "," )[ 1 ].split( "." )[ 0 ] ); | ||
var hit = Number( values.split( " " )[ 2 ] ); | ||
files.push( { | ||
title: name, | ||
file: path, | ||
lines: { | ||
found: 0, | ||
hit: 0, | ||
details: [] | ||
} | ||
} ); | ||
} | ||
file.lines.found += endLine - startLine + 1; | ||
for( var lineNumber = startLine; lineNumber <= endLine; lineNumber++ ) | ||
{ | ||
var existingLine = file.lines.details.filter( function ( ex ) | ||
var file = files[ files.length - 1 ]; | ||
var startLine = Number( values.split( "," )[ 0 ].split( "." )[ 0 ] ); | ||
var endLine = Number( values.split( "," )[ 1 ].split( "." )[ 0 ] ); | ||
var hit = Number( values.split( " " )[ 2 ] ); | ||
file.lines.found += endLine - startLine + 1; | ||
for( var lineNumber = startLine; lineNumber <= endLine; lineNumber++ ) | ||
{ | ||
return ex.line === lineNumber; | ||
} )[ 0 ]; | ||
var existingLine = file.lines.details.filter( function ( ex ) | ||
{ | ||
return ex.line === lineNumber; | ||
} )[ 0 ]; | ||
if( existingLine ) | ||
{ | ||
existingLine.hit += hit; | ||
if( existingLine ) | ||
{ | ||
existingLine.hit += hit; | ||
} | ||
else | ||
{ | ||
file.lines.details.push( { | ||
line: lineNumber, | ||
hit: hit | ||
} ); | ||
} | ||
} | ||
else | ||
{ | ||
file.lines.details.push( { | ||
line: lineNumber, | ||
hit: hit | ||
} ); | ||
} | ||
} | ||
} ); | ||
} ); | ||
files.forEach( function ( file ) | ||
@@ -83,0 +92,0 @@ { |
@@ -14,3 +14,3 @@ "use strict"; | ||
assert.equal( err, null ); | ||
assert.equal( result.length, 2 ); | ||
assert.equal( result.length, 5 ); | ||
assert.equal( result[ 0 ].lines.found, 210 ); | ||
@@ -17,0 +17,0 @@ assert.equal( result[ 0 ].lines.hit, 111 ); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14003
1
10
112
- Removedxml2js@^0.4.9
- Removedsax@1.4.1(transitive)
- Removedxml2js@0.4.23(transitive)
- Removedxmlbuilder@11.0.1(transitive)