Comparing version 1.0.5 to 1.0.6
@@ -33,3 +33,3 @@ #!/usr/bin/env node | ||
}).then(function (path) { | ||
let complexityReport = generateReport(path, reportsPath) | ||
let complexityReport = generateReport(path, reportsPath, gitUrl) | ||
Debug(JSON.stringify(complexityReport, null, 3)) | ||
@@ -36,0 +36,0 @@ }).catch(function (err) { |
'use strict' | ||
const Fse = require('fs-extra') | ||
const Path = require('path') | ||
const Util = require('./util') | ||
module.exports = function (path, reportsPath) { | ||
module.exports = function (path, reportsPath, gitUrl) { | ||
var complexityReport = {} | ||
@@ -11,14 +12,15 @@ complexityReport.report = [] | ||
var rep = {} | ||
rep.path = report.path | ||
rep.cyclomatic = report.cyclomatic | ||
rep.loc = report.loc | ||
rep.maintainability = report.maintainability | ||
rep.path = Util.getGitPath(gitUrl, report.path) | ||
rep.cyclomatic = +(report.cyclomatic.toFixed(2)) | ||
rep.loc = +(report.loc.toFixed(2)) | ||
rep.maintainability = +(report.maintainability.toFixed(2)) | ||
complexityReport.report.push(rep) | ||
}) | ||
complexityReport.cyclomatic = jsonReport.cyclomatic | ||
complexityReport.loc = jsonReport.loc | ||
complexityReport.maintainability = jsonReport.maintainability | ||
complexityReport.cyclomatic = +(jsonReport.cyclomatic.toFixed(2)) | ||
complexityReport.loc = +(jsonReport.loc.toFixed(2)) | ||
complexityReport.maintainability = +(jsonReport.maintainability.toFixed(2)) | ||
Fse.writeFileSync(Path.join(reportsPath, 'complexity-report.json'), JSON.stringify(complexityReport, null, 3)) | ||
console.log('Successfully wrote report at: ' + Path.join(reportsPath, 'complexity-report.json')) | ||
Fse.removeSync(Path.join(process.cwd(), 'cc.json')) | ||
return complexityReport | ||
} |
@@ -27,3 +27,11 @@ 'use strict' | ||
} | ||
}, | ||
getGitPath: function (gitUrl, localPath) { | ||
const pathToReplace = Path.join(process.cwd(), 'clonedrepos', GitUrlParse(gitUrl).pathname) | ||
const fileName = localPath.replace(pathToReplace, '') | ||
const git = GitUrlParse(gitUrl) | ||
const hash = (git.hash === '' ? 'master' : git.hash) | ||
return git.protocol + '://' + git.resource + '/' + git.pathname + '/blob/' + hash + fileName | ||
} | ||
} |
{ | ||
"name": "complan", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "COMPLexity ANalyzer Tool For Javascript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -53,5 +53,5 @@ # Complan | ||
-g, --gitUrl <path> specify the http url or the git url of the repository | ||
``` | ||
## License | ||
[MIT] | ||
[MIT] |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
57
1
45928
17
171