Can not runt this tool
agirorn opened this issue · 2 comments
I wanted to try this tool and it just bombes brakes when I try to collect the complexity.
./node_modules/.bin/code-complexity . --details
(node:11696) UnhandledPromiseRejectionWarning: Error: stdout maxBuffer exceeded
at Socket.onChildStdout (child_process.js:329:14)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:246:13)
at Socket.Readable.push (_stream_readable.js:208:10)
at Pipe.onread (net.js:601:20)
(node:11696) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:11696) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.What works it the following
./node_modules/.bin/code-complexity --help
Usage: code-complexity <dir>
Measure projects complexity based on files sloc and commit count.
Options:
-l, --limit [limit] Limit the number of files to output
-d, --details Show the number of commit and computed sloc
-c, --commit Show the number of commits
-s, --sloc Show the computed sloc
-i, --since [since] Limit the age of the commit analyzed
-n, --no-first-parent Do not use the git-log flag '--first-parent' when counting commits
--sort [sort] Sort results by commit, complexity, file or sloc
--min [min] Exclude results below <min>
--max [max] Exclude results above <max>
-h, --help output usage information
Examples:
$ code-complexity /path/to/git/directory
$ code-complexity /path/to/git/directory --limit 3
$ code-complexity /path/to/git/directory --details
$ code-complexity /path/to/git/directory --min 10 --max 50node -v // => v8.12.0
npm -v // => 6.4.1
uname -a // => Linux agirorn 4.15.0-38-generic #41-Ubuntu SMP Wed Oct 10 10:59:38 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
I know it's an old issue but I ran into the same as I wanted to try the tool and I understood why.
If the project is very old, that's a lot of git commits to analyze. So it overflows the buffer.
You can certainly get some useful answers by limiting the analysis to the past year.
Try to use: ./node_modules/.bin/code-complexity . --details --since 2019-01-01
Note you can now use npx so you don't have to install it.
Adapt the date and launch from anywhere the following command, you'll get useful results:
npx code-complexity . --details --sort complexity --limit 10 --since 2019-01-01
As @nicoespeon said, it's a bug when you try to analyze too many commits at once. I added a Troubleshooting section with a workaround while I try to find a workaround.