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.81k stars 246 forks source link

Lizard Skips Odd function Declarations #353

Open MichaelBMiner opened 2 years ago

MichaelBMiner commented 2 years ago

I have a Jenkins pipeline which builds my application then runs various tools. Doxygen, CppCheck, Lizard Code complexity and a few others. In my code many functions are declared as static, this meads my unit tests (ceedling) cannot see them, or test them.

To make them visible for ceedling I have to declare each function as follows

#ifdef CEEDLING_TESTS
uint16_t ring_buffer_advance(uint16_t current_index, uint16_t buffer_size){
#else
static uint16_t ring_buffer_advance(uint16_t current_index, uint16_t buffer_size){
#endif
    if (buffer_size > 0) {
        current_index++;
        if (current_index >= buffer_size) {
            current_index = 0;
        }
    } else {
        printf("error - ring buffer max value can not be zero \n");
        current_index = 0;
    }

    return current_index;
}

Now in the c and h files I use ifdefs to create the appropriate function prototype. Lizard does not find these functions and does not generate a complexity report.