terryyin / lizard

A simple code complexity analyser without caring about the C/C++ header files or Java imports, supports most of the popular languages.
Other
1.85k stars 250 forks source link

Drop the implementation for Python NS metric #155

Closed rakhimov closed 7 years ago

rakhimov commented 8 years ago

As noted in #154, pylint already provides this metric. There's no need to duplicate the effort since pylint is widely available. There are some non-trivial difficulties implementing NS for Python with partial parsers as issued in #141.

This commit fixes #141, closes #154, closes #153, closes #142.


This change is Reviewable

rakhimov commented 8 years ago

@terryyin I am not sure where to stick the runtime warning.

rakhimov commented 8 years ago

@terryyin Any opinion on this?

terryyin commented 7 years ago

please allow me more time. Sorry.

jderehag commented 7 years ago

I would hope that you keep it (NS was added to lizard as a thesis work, but with the long-term intention of adding NS metric to https://github.com/jderehag/swat) which heavily relies on lizard (and partial parsers).

The reason for why partial parsers is a requirement in swat is because of how we parse version-control-systems. We essentially do it file-by-file (and version by verison), and for instance in the git case, checking out a complete repo to analyze a single version is simply to costly if you have millions of versions of something.

Apart from that, I think it makes architectural (and end-user) sense to make sure that every metric should be available on all languagues. Otherwise it might end up so that we have very distinctly different parsers (with a potentially different api) for each language, and keeping up with what is supported where is going to be very complicated to explain and maintain.

rakhimov commented 7 years ago

I would hope that you keep it (NS was added to lizard as a thesis work, but with the long-term intention of adding NS metric to https://github.com/jderehag/swat) which heavily relies on lizard (and partial parsers).

@jderehag As the author of the NS implementation in lizard, I am a bit confused with this statement. Are you sure you mean the Nested Structures metric?

jderehag commented 7 years ago

@rakhimov oops, I got NS confused with the nesting-depth added by @mehrdad89. Sorry about that!

rakhimov commented 7 years ago

I guess I know how to solve this. The heuristic would be to consider tokens that don't start with new line an expression since expressions are preceded by statements, and Python has one statement per line. I had missed this major difference that would help separate the token roles.