Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

golang-cover-parse

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

golang-cover-parse - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

HISTORY.md

5

package.json
{
"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"
}
}

101

source/index.js

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc