<commit_before>



var f = function(){
	var sonarResults = {};

	return {
		addResult : function(fileName, data) {
			sonarResults[fileName] =  data;
		},
		saveReport : function(outputDir, stripFilePrefix){
			stripFilePrefix = /^\/jvmc\//; //TODO acutally use the parameters
	        var keys = Object.getOwnPropertyNames(sonarResults);
    	    var outputFile = '/tmp/coverage.lcov'; //TODO acutally use the parameters
        	var fs = require('fs');
        	fs.writeFileSync(outputFile, '');
        	keys.forEach(function(k){
            	var file = k.replace(stripFilePrefix, '');
            	var data = sonarResults[k];
            	fs.appendFileSync(outputFile, 'SF:'+file+'\n');

	            data.forEach(function(line, num){
	                num++;
	                if(data[num] !== undefined && data[num] !== null && data[num] !== '' ){
	                    fs.appendFileSync(outputFile, 'DA:' + num + ',' + data[num] + '\n');
	                }
	            });
	            fs.appendFileSync(outputFile, 'end_of_record\n');
	        });
		}
	}
}

module.exports = f;<commit_msg>make the module actually work<commit_after>'use strict';

var f = function(){
	var sonarResults = {};

	return {
		addResult : function(fileName, data) {
			sonarResults[fileName] =  data;
		},
		saveReport : function(outputDir, stripFilePrefix){
			stripFilePrefix = /^\/jmvc\//; //TODO acutally use the parameters
	        var keys = Object.getOwnPropertyNames(sonarResults);
    	    var outputFile = '/tmp/coverage.lcov'; //TODO acutally use the parameters
        	var fs = require('fs');
        	fs.writeFileSync(outputFile, '');
        	keys.forEach(function(k){
            	var file = k.replace(stripFilePrefix, '');
            	var data = sonarResults[k];
            	fs.appendFileSync(outputFile, 'SF:'+file+'\n');

	            data.forEach(function(line, num){
	                num++;
	                if(data[num] !== undefined && data[num] !== null && data[num] !== '' ){
	                    fs.appendFileSync(outputFile, 'DA:' + num + ',' + data[num] + '\n');
	                }
	            });
	            fs.appendFileSync(outputFile, 'end_of_record\n');
	        });
		}
	};
};
 
module.exports = f();
{'fraction_non_alphanumeric': 0.15616561656165617, 'fraction_numerical': 0.0, 'mean_word_length': 2.144271570014144, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1423009', 'n_tokens_mistral': 719, 'n_tokens_neox': 673, 'n_words': 130}