Consensys / vscode-solidity-auditor

Solidity language support and visual security auditor for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=tintinweb.solidity-visual-auditor
GNU General Public License v3.0
569 stars 60 forks source link

Cyclomatic complexity detection #111

Open pedrohba1 opened 1 year ago

pedrohba1 commented 1 year ago

In the same way that an UML can be generated, I think it would be great to detect cyclomatic complexities.

I think that somehow detecting Cyclomatic complexities might be good because of the following exempt from wikipedia:

Correlation to number of defects A number of studies have investigated the correlation between McCabe's cyclomatic complexity number with the frequency of defects occurring in a function or method.[11] Some studies[12] find a positive correlation between cyclomatic complexity and defects: functions and methods that have the highest complexity tend to also contain the most defects.

A better explanation of it: https://en.wikipedia.org/wiki/Cyclomatic_complexity#Limiting_complexity_during_development

tintinweb commented 1 year ago

hey @pedrohba1 🙌 ,

cyclomatic complexity is a little more complex to calculate that's why I took the shortcut with statement-based complexity scoring. statements that increase complexity add score to the function (https://github.com/ConsenSys/vscode-solidity-auditor/issues/62).

happy to take a PR if someone want's to take this on.

cheers, tin