UNPKG

jscpd

Version:

Copy/paste detector for programming code, support JavaScript, CoffeeScript, PHP, Ruby, Python, Less, Go, Java, Yaml, C#, C++, C languages

47 lines (39 loc) 1.19 kB
// Generated by CoffeeScript 1.10.0 (function() { var Map; Map = (function() { function Map() { this.clones = []; this.clonesByFile = {}; this.numberOfDuplication = 0; this.numberOfLines = 0; this.numberOfFiles = 0; } Map.prototype.addClone = function(clone) { this.clones.push(clone); this.numberOfDuplication = this.numberOfDuplication + clone.linesCount; if (clone.firstFile in this.clonesByFile) { this.clonesByFile[clone.firstFile].push(clone.firstFile); } else { this.clonesByFile[clone.firstFile] = [clone.firstFile]; this.numberOfFiles++; } if (clone.secondFile in this.clonesByFile) { return this.clonesByFile[clone.secondFile].push(clone); } else { this.clonesByFile[clone.secondFile] = [clone]; return this.numberOfFiles++; } }; Map.prototype.getPercentage = function() { var result; result = 0; if (this.numberOfLines > 0) { result = this.numberOfDuplication / this.numberOfLines * 100; } return result.toFixed(2); }; return Map; })(); exports.Map = Map; }).call(this);