How To Install pmccabe on Ubuntu 22.04

In this tutorial we learn how to install pmccabe on Ubuntu 22.04. pmccabe is McCabe-style function complexity and line counting for C and C++

Introduction

In this tutorial we learn how to install pmccabe on Ubuntu 22.04.

What is pmccabe

pmccabe is:

Pmccabe calculates McCabe-style cyclomatic complexity for C and C++ source code. Per-function complexity may be used for spotting likely trouble spots and for estimating testing effort.

Pmccabe also includes a non-commented line counter compatible with anac, ‘decomment’ which only removes comments from source code; ‘codechanges’, a program to calculate the amount of change which has occurred between two source trees or files; and ‘vifn’, to invoke ‘vi’ given a function name rather than a file name.

Pmccabe attempts to calculate the apparent complexity rather than the complexity following the C++ and/or cpp preprocessors. This causes Pmccabe to become confused with cpp constructs which cause unmatched curly braces - most of which can profitably be rewritten so they won’t confuse prettyprinters anyway. Pmccabe prints C-compiler-style error messages when the parser gets confused so they may be browsed with standard tools.

Two types of cyclomatic complexity are generated - one type counts each switch() statement as regardless of the number of cases included and the other more traditional measure counts each case within the switch(). Pmccabe also calculates the starting line for each function, the number of lines consumed by the function, and the number of C statements within the function.

There are three methods to install pmccabe on Ubuntu 22.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install pmccabe Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install pmccabe using apt-get by running the following command:

sudo apt-get -y install pmccabe

Install pmccabe Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install pmccabe using apt by running the following command:

sudo apt -y install pmccabe

Install pmccabe Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install pmccabe using aptitude by running the following command:

sudo aptitude -y install pmccabe

How To Uninstall pmccabe on Ubuntu 22.04

To uninstall only the pmccabe package we can use the following command:

sudo apt-get remove pmccabe

Uninstall pmccabe And Its Dependencies

To uninstall pmccabe and its dependencies that are no longer needed by Ubuntu 22.04, we can use the command below:

sudo apt-get -y autoremove pmccabe

Remove pmccabe Configurations and Data

To remove pmccabe configuration and data from Ubuntu 22.04 we can use the following command:

sudo apt-get -y purge pmccabe

Remove pmccabe configuration, data, and all of its dependencies

We can use the following command to remove pmccabe configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge pmccabe

References

Summary

In this tutorial we learn how to install pmccabe package on Ubuntu 22.04 using different package management tools: apt, apt-get and aptitude.