How can I disable pvs-studio specific warnings for a cmake project?

181 views Asked by At

I want to completely disable certain diagnostics without changing the source code. How do I do that?

I looked through the documentation, but it's pretty confusing. I see three options such as: use cfg files (cfg or pvsconfig) with two different formats or a json file without mentioning its format.

My development environment is linux, vscode, cmake. Part of my CMakeList.txt:

pvs_studio_add_target(TARGET parser.analyze ALL
                    CONFIG ${PROJECT_SOURCE_DIR}/rules.pvsconfig
                    OUTPUT
                    HIDE_HELP
                    FORMAT errorfile-verbose
                    ANALYZE ${PROJECT_NAME}
                    MODE GA:1,2
                    )

where rules.pvsconfig:

//-V::730

Thanks!

1

There are 1 answers

0
AndreyKarpov On BEST ANSWER

If you already have the *.pvsconfig file with comments about turning off diagnostic rules, you can put it into pvs_studio_add_target through the ARGS option:

pvs_studio_add_target(TARGET parser.analyze ALL
                      ARGS --rules-config "${PROJECT_SOURCE_DIR}/rules.pvsconfig"
                      OUTPUT
                      HIDE_HELP
                      FORMAT errorfile-verbose
                      ANALYZE ${PROJECT_NAME}
                      MODE GA:1,2
)

Note that the CONFIG option defines a *.cfg file which is a slightly different entity. You can read more about that here.