tomasbjerre / violations-lib

Java library for parsing report files from static code analysis.
Apache License 2.0
148 stars 39 forks source link

gcc, ARM-Gcc and Doxygen #38

Closed stoesselt closed 6 years ago

stoesselt commented 6 years ago

Hi, the idea is to be able to recognize compiler warnings as well. Compiler warnings can also be seen as static code analysis results providing valuable hints where problems can hide.

In an environment of continuous integration, various builds with different compiler flags can be executed ending in possibly different warnings. Also compilation with different compilers may be necessary. Adding support for compiler warnings in this lib would eliminate the need to compile these things manually and enable to comment on pull requests for compiler warnings (Bitbucket Server in my case).

In detail, as I am working on C++ projects, I am very interested in support for GCC compiler and Doxygen generation warnings.

tomasbjerre commented 6 years ago

Can you provide some output from GCC and Doxygen?

stoesselt commented 6 years ago

Example output: gcc 7.3.0:

../../../pump/source/util/FormattedDate.cpp:82:44: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
../../../pump/source/util/profile/profile_function_overlay.cpp:112:25: warning: variable 'exceedingDuration' set but not used [-Wunused-but-set-variable]

ARM-Gcc (4.9 2015q3):

../../external/specific/arm/cmsis/arm_math.h:5774:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
../../external/generic/boost/boost/type_traits/intrinsics.hpp:321:0: warning: "BOOST_HAS_TRIVIAL_DESTRUCTOR" redefined
../../external/generic/boost/boost/type_traits/intrinsics.hpp:128:0: note: this is the location of the previous definition
../../source/startup/controller/DebugConsole.c:49:5: error: 'dmax' undeclared (first use in this function)

Doxygen has the ability to change the warning format. The default format is: "$file:$line: $text". Doxygen:

./pump/external/specific/arm/cmsis_dsp/StatisticsFunctions/arm_min_q7.c:48: warning: argument 'index' of command @param is not found in the argument list of arm_min_q7(q7_t *pSrc, uint32_t blockSize, q7_t *pResult, uint32_t *pIndex)
./pump/external/specific/arm/stm32f4xx/libinc/stm32f4xx_flash.h:354: warning: The following parameters of FLASH_ITConfig(uint32_t FLASH_IT, FunctionalState NewState) are not documented:
 parameter 'NewState'
./pump/external/specific/arm/stm32f4xx/libsrc/stm32f4xx_gpio.c:518: warning: End of list marker found without any preceding list items
tomasbjerre commented 6 years ago

Should be simple to add. Looks a lot like this:

stoesselt commented 6 years ago

You are right. A particularitiy of Doxygen is that there are warning messages over multiple lines (2nd warning).

tomasbjerre commented 6 years ago

I implementing it without supporting the whole message from Doxygen. Perhaps someone can add that later. Now I'm just including the first line because that was a very simple thing to support. And it is supported with the CLANG parser.

tomasbjerre commented 6 years ago

Released in the plugins now.