UNPKG

jscpd

Version:

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

32 lines (27 loc) 1.37 kB
// Generated by CoffeeScript 1.10.0 (function() { var Promise, _; _ = require('underscore'); Promise = require('bluebird'); module.exports = function(options) { var clone, fn, i, len, ref, xmlDoc; xmlDoc = "<?xml version='1.0' encoding='UTF-8' ?>"; if (options['xsl-href']) { xmlDoc += '<?xml-stylesheet type="text/xsl" href="' + options['xsl-href'] + '"?>'; } xmlDoc += '<pmd-cpd>'; ref = this.map.clones; fn = function(clone) { var firstFragment, secondFragment; firstFragment = _.escape(clone.getLines(true)); secondFragment = _.escape(clone.getLines(false)); return xmlDoc = xmlDoc + " <duplication lines='" + clone.linesCount + "' tokens='" + clone.tokensCount + "'> <file path='" + clone.firstFile + "' line='" + clone.firstFileStart + "'>" + clone.firstFileAnnotatedCode + " <codefragment><![CDATA[" + firstFragment + "]]></codefragment> </file> <file path='" + clone.secondFile + "' line='" + clone.secondFileStart + "'>" + clone.secondFileAnnotatedCode + " <codefragment><![CDATA[" + secondFragment + "]]></codefragment> </file> <codefragment><![CDATA[" + firstFragment + "]]></codefragment> </duplication>"; }; for (i = 0, len = ref.length; i < len; i++) { clone = ref[i]; fn(clone); } xmlDoc = xmlDoc + '</pmd-cpd>'; return [xmlDoc]; }; }).call(this);