如何在 C++ 中禁用 CodeSonar 警告 [英] How to disable a CodeSonar warning in C++

查看:45
本文介绍了如何在 C++ 中禁用 CodeSonar 警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题说明了一切......我有一个项目需要清理 MISRA 2004,公司被告知 CodeSonar 是一个很好的静态分析工具.

The title says it all... I have project which needs to MISRA 2004 clean, and the company was told CodeSonar was a good tool to do the static analysis.

在其他静态分析工具上,您可以添加一个魔术注释来禁用对下一行\代码块的分析,(PC-Lint 是 //lint -esym(42),CStat 使用 #pragma cstat_suppress="MISRAC++2008-6-4-1") 但 CodeSonar 似乎没有任何等效项 - 请告诉我我错了!

On other static analysis tools you can add a magic comment to disable analysis for the next line\block of code, (PC-Lint is //lint -esym(42), CStat uses #pragma cstat_suppress="MISRAC++2008-6-4-1") but CodeSonar doesn't appear to have any equivalent - please tell me I'm wrong!

我已经看到提到 //NOSONAR 但这似乎不适用于 CodeSonar 5.1

I've seen mention of a // NOSONAR but that does not appear work on CodeSonar 5.1

(我很快得出结论,CS 是一堆垃圾,这些人从来没有在现实世界中使用 SVN 和多个程序员进行过编程,当你合并时,在花哨的 UI 中禁用警告会变得很疯狂分支到主干,所有行号都改变了.)

(I'm rapidly coming to the conclusion CS is a pile junk written by people who have never programmed in the real world with SVN and multiple programmers, where disabling warnings in a fancy UI goes down the swanny when you're merging branches into trunk and all the line numbers change.)

推荐答案

自 CodeSonar 4.0.0 起,在 WARNING_FILTER 中添加了一个新的过滤器选项:line_content 允许你添加了一个神奇的评论".

Since CodeSonar 4.0.0, there is a new filter option added to WARNING_FILTER: line_content that allows you add a "magic comment".

将以下行添加到您的 proj_name.conf:

Add the following line to your proj_name.conf:

WARNING_FILTER += line_contents:"NOLINT"

这将禁用以 //NOLINT

这篇关于如何在 C++ 中禁用 CodeSonar 警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆