Understanding Code Complexity and using Static Analysis to measure it

Submitted by hussainweb on Fri, 05/31/2019 - 23:31
Session Track
Code & development
Skill level
Advanced

Experienced programmers can often look at a piece of code and know what’s wrong, or feel what’s wrong. But people are known to miss things or overestimate the impact of any piece of code. Fortunately, mathematics comes to our rescue.

Engineers and mathematicians have tried to measure code complexity based on various factors and give a metric. These metrics help in understanding if the code in question is maintainable or has a lot of dependencies or even if it is too complex to test efficiently. This formal approach at understanding code complexity helps us in removing subjectivity and also allows us to automate using CI.

In this session, we will learn:

  • Some of the more common code complexity metrics.

  • Tools like phpmd and others which helps us in measuring code complexity.

  • Customise phpmd and other wrapper tools to check for precisely the metrics we care about.

  • Integrating these tools in your CI environment with a Docker image built for this purpose.