7 ms·
GNU complexity 1.5
- wspeirs 11y agoHow has this been here for 30+ minutes and no one has posted the complexity of the Linux kernel, gcc compiler, and of course the complexity program itself?
- anc84 11y agoHow is your comment 24 minutes old and you haven't done it yourself? ;)
- wspeirs 11y agoHa... I started on the kernel, but it couldn't parse it, so I gave up :-(
- dalke 11y agohttp://www.cnx-software.com/2016/03/01/gnu-complexity-command-line-tool-measures-complexity-of-c-code/ http://www.cnx-software.com/2016/03/01/gnu-complexity-comman... looks at part of the Linux kernel using this specific version of GNU complexity. Complexity analysis of this sort is decades old. McCabe complexity is from 1976. So it's not like no one has done something like this before. Some papers which have done a complexity analysis of the Linux kernel are: http://oai.dtic.mil/oai/oai?verb=getRecord&metadataPrefix=html&identifier=ADA403525 http://oai.dtic.mil/oai/oai?verb=getRecord&metadataPrefix=ht... and http://www.cs.huji.ac.il/~feit/papers/MCC12ICPC.pdf http://www.cs.huji.ac.il/~feit/papers/MCC12ICPC.pdf . For more examples, see https://scholar.google.com/scholar?q=complexity+of+the+Linux+kernel+McCabe&btnG= https://scholar.google.com/scholar?q=complexity+of+the+Linux... . The documentation includes an example of running the complexity program on itself. http://www.gnu.org/software/complexity/manual/complexity.html#Example-Output http://www.gnu.org/software/complexity/manual/complexity.htm... If it's that interesting to you, why not do it for yourself and report the results.
- jhallenworld 11y agoWell I had to try this on JOE, the highest score is: 1613 359 325 regex.c(1260): joe_regexec The manual has: ‘50-99’ Unmaintainable code. ‘100-199’ Crazy making difficult code. ‘200+’ I only wish I were kidding. Score | ln-ct | nc-lns| file-name(line): proc-name 4707 3815 2838 lib/vasnprintf.c(1747): VASNPRINTF The golang compiler should include this technology and refuse to compile files which it decides are too complex for you to maintain.
- mmargerum 11y agoDoesn't go compile itself now?
- Narann 11y agoNaive question: What the practical usage of this? Detect complex functions in huge code base?
- pnathan 11y agoWhen you're estimating the maintainability of a codebase over time and identifing modules that are overly complex (i.e., buggy), these kinds of tools are invaluable.
- Narann 11y agoYou mean, for example, running this once a month and keep stats to follow how complexity increase over time or when, in time, it suddenly increase to detect badly merged code?
- pnathan 11y agoGot it in one. Another example: http://betterembsw.blogspot.com/2014/06/avoid-high-cyclomatic-complexity.html http://betterembsw.blogspot.com/2014/06/avoid-high-cyclomati... Keep in mind that these sorts of practices are often used in serious-minded projects where development is intentional and the people doing the work are reflective on the process.
- CyberDildonics 11y agoWhy would you run it only once a month?
- deleted 11y ago[deleted]
- mikegerwitz 11y agoIt's common practice to run tools to calculate complexity as a CI (continuous integration) task. For example, at the company I work for, we check code complexity every time someone pushes to certain branches in our repositories, and mark the build as unstable if the score is too high. In that case, the only acceptable solution is refactoring; all builds must be stable before the task associated with the change can be considered complete. It's not reasonable to run it once a month or longer---by then we've moved on, context and focus have been lost, and refactoring is considerably more expensive (both for development and because it has to go back through QA) than if it were done immediately.
- deleted 11y ago[deleted]
- justifier 11y agoassumed it was going to have something to do with computational complexity is there similar software that one can pass source code to and get a detailed look at the overall and individual computational complexity?
- hjek 11y agoIs there anything like this for Javascript?
- dalke 11y agoPerhaps one of the ones in http://stackoverflow.com/questions/100645/calculate-cyclomatic-complexity-for-javascript http://stackoverflow.com/questions/100645/calculate-cyclomat... ?