Language of file ‘Supporting Files/BridgeHeader.h‘ can not be decided as the file matches patterns o

在SonarQube分析C语言工程时遇到错误,错误信息表明文件匹配了C++和C的解析规则。解决方法是在sonar-project.properties文件中添加sonar.language=c,指定使用C语言插件进行分析,从而避免解析冲突。移除不必要的sonar-cxx-plugin配置也能解决问题。

sonarQube代码上传报错

ERROR: Error during SonarScanner execution
ERROR: Language of file 'Supporting Files/BridgeHeader.h' can not be decided as the file matches patterns of both sonar.lang.patterns.objc : **/*.h,**/*.m,**/*.mm and sonar.lang.patterns.c++ : **/*.cxx,**/*.cpp,**/*.cc,**/*.c,**/*.hxx,**/*.hpp,**/*.hh,**/*.h
ERROR:
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

解决方法
1,
运行到最后会报错,错误原因是不能决定使用sonar.lang.patterns.c++还是使用sonar.lang.patterns.c解析.c文件。这是因为前面安装的sonar-c-plugin和sonar-cxx-plugin插件都有对.c和.h扩展名的设置,因为我们分析的是C语言工程,可以将sonar-cxx-plugin的配置去掉,如下:
在这里插入图片描述

2,
在sonar-project.properties中添加sonar.language=c,指定使用c插件来运行

参考链接:https://www.freesion.com/article/3192617572/

在C#中,当遇到仅支持小于2GB文件操作限制的问题时,可采用以下几种方法解决: ### 分块处理 将大文件分割成较小的块,对每个块进行单独处理,最后合并处理结果。以下是示例代码: ```csharp using System; using System.IO; class Program { static void Main() { string largeFilePath = "path/to/largefile"; string outputFilePath = "path/to/outputfile"; int bufferSize = 1024 * 1024; // 1MB 块大小 byte[] buffer = new byte[bufferSize]; using (FileStream inputStream = new FileStream(largeFilePath, FileMode.Open, FileAccess.Read)) using (FileStream outputStream = new FileStream(outputFilePath, FileMode.Create, FileAccess.Write)) { int bytesRead; while ((bytesRead = inputStream.Read(buffer, 0, bufferSize)) > 0) { // 这里可以对 buffer 进行处理 outputStream.Write(buffer, 0, bytesRead); } } } } ``` ### 使用 `Stream` 类 `Stream` 类允许以流式方式处理文件,无需将整个文件加载到内存中。示例代码如下: ```csharp using System; using System.IO; class Program { static void Main() { string largeFilePath = "path/to/largefile"; using (FileStream fileStream = new FileStream(largeFilePath, FileMode.Open, FileAccess.Read)) { // 进行流式处理 byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) > 0) { // 处理读取的数据 } } } } ``` ### 使用 `MemoryMappedFile` `MemoryMappedFile` 可将文件映射到内存,以虚拟内存方式访问文件,避免一次性将整个文件加载到物理内存。示例代码如下: ```csharp using System; using System.IO.MemoryMappedFiles; class Program { static void Main() { string largeFilePath = "path/to/largefile"; using (MemoryMappedFile mmf = MemoryMappedFile.CreateFromFile(largeFilePath, FileMode.Open)) { using (MemoryMappedViewStream stream = mmf.CreateViewStream()) { // 进行流式处理 byte[] buffer = new byte[4096]; int bytesRead; while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0) { // 处理读取的数据 } } } } } ```
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值