Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/134.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ SonarQube拦截器:使用;tm";函数内声明_C++_Sonarqube - Fatal编程技术网

C++ SonarQube拦截器:使用;tm";函数内声明

C++ SonarQube拦截器:使用;tm";函数内声明,c++,sonarqube,C++,Sonarqube,在头文件中使用以下函数声明之一 time\u t MyFunction(tm*time) time\u t MyFunction(struct tm*time) 我发现了以下声纳拦截器问题: 将保留名称“tm”更改为非保留名称 我尝试在标题中包含,但这并没有奏效。奇怪的是,相应的函数定义本身没有这样的问题;声纳没有对此抱怨 关于为什么,我怎么可能绕过它?< /p> < p>你在编译C或C++代码时,不是在写。在后一种情况下,我建议使用ctime.h头,然后使用std::tm。也许这会对分析起作用

在头文件中使用以下函数声明之一

time\u t MyFunction(tm*time)

time\u t MyFunction(struct tm*time)

我发现了以下声纳拦截器问题:

将保留名称“tm”更改为非保留名称

我尝试在标题中包含
,但这并没有奏效。奇怪的是,相应的函数定义本身没有这样的问题;声纳没有对此抱怨


关于为什么,我怎么可能绕过它?< /p> < p>你在编译C或C++代码时,不是在写。在后一种情况下,我建议使用
ctime.h
头,然后使用
std::tm
。也许这会对分析起作用。 如果你仍然需要使用声纳忽略这些线,你可以使用

time_t MyFunction (tm* time); // NOSONAR
AFAIK无需进一步配置即可工作。我们正在使用

//sonarqube ingore on
time_t MyFunction (tm* time);
//sonarqube ingore off
忽略代码块。然而,这可能需要一个sonarqube配置,以使标志为人所知。我们在pom.xml中使用了以下内容,在您的环境中可能有所不同但相似:

<sonar.issue.ignore.block>e1</sonar.issue.ignore.block>
<sonar.issue.ignore.block.e1.beginBlockRegexp>sonarqube ignore on</sonar.issue.ignore.block.e1.beginBlockRegexp>
<sonar.issue.ignore.block.e1.endBlockRegexp>sonarqube ignore off</sonar.issue.ignore.block.e1.endBlockRegexp>
e1
不可忽视
声纳可以忽略掉
不幸的是,SQ文档更多地关注如何在项目配置中而不是在代码中处理规则及其异常,因此这些信息并不容易找到


关于您的另一个问题:根据我的经验,SQ只会在声明中抱怨类似您的代码味道,因此您不会在c/cpp文件中收到相同的警告。

您可以添加忽略规则作为最后一个警告resort@adnankamili我完全可以求助于此。在C++声纳中有没有忽略特定行的方法?