我试着为我所有的c++项目设置sonarqube。它对所有项目都很好用,除了一个。
这个项目是唯一一个有子模块的项目。我有一个src文件夹,可以用这个脚本分析:
#!/bin/bash
curl -sSLo build-wrapper-linux-x86.zip https://openshift.lumiplan.com/sonarqube/static/cpp/build-wrapper-linux-x86.zip
unzip -o build-wrapper-linux-x86.zip
chmod +x build-wrapper-linux-x86/build-wrapper-linux-x86-64
build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output make
ls
cat bw-output/build-wrapper-dump.json
cd ../../src
wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.2.0.1873-linux.zip
mkdir sonar-scanner
unzip sonar-scanner-cli-4.2.0.1873-linux.zip
ls
mv sonar-scanner-4.2.0.1873-linux/* sonar-scanner/
rm sonar-scanner/conf/sonar-scanner.properties
cp ../sonar-project.properties sonar-scanner/conf/sonar-scanner.properties
sonar-scanner/bin/sonar-scanner -Dsonar.scm.exclusions.disabled=true -Dsonar.cfamily.build-wrapper-output=../projects/linux-arm/bw-output -Dsonar.projectKey=products_panel_lumiplay-engine_AYKR3Op6FUISUZul32ck -Dsonar.sources=. -Dsonar.login=14214a83196d3ae8f3507cff910c5da818e280a2 -Dsonar.host.url=https://openshift.lumiplan.com/sonarqube -Dsonar.branch.name=$1
字符串
但在src文件夹中我有以下内容:
- “API_asrcore”文件夹是git子模块
- “API_boost”文件夹,它是git子模块
- 我所有的代码都在不同的文件夹中,而不是git子模块
日志:
NFO: Using 1 thread for analysis according to value of "sonar.cfamily.threads" property.
15:59:20 WARN: Invalid character encountered in file /usr/src/lumiplan/src/specific/configuration_specific/source/configuration_specific.cpp at line 121 for encoding US-ASCII. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
15:59:20 WARN: Invalid character encountered in file /usr/src/lumiplan/src/specific/protocol/public/msg_plot_idbrndef.h at line 157 for encoding US-ASCII. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
15:59:20 WARN: Invalid character encountered in file /usr/src/lumiplan/src/specific/review/source/review_application_control.cpp at line 152 for encoding US-ASCII. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
15:59:20 WARN: Invalid character encountered in file /usr/src/lumiplan/src/specific/protocol/source/msg_plot_idbrndef.cpp at line 579 for encoding US-ASCII. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
15:59:20 WARN: Invalid character encountered in file /usr/src/lumiplan/src/specific/decodage/source/decodage_plot.cpp at line 294 for encoding US-ASCII. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
15:59:20 WARN: Invalid character encountered in file /usr/src/lumiplan/src/specific/decodage/public/decodage_plot.h at line 164 for encoding US-ASCII. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
INFO: PCH: unique=0 use=0 (forceInclude=0,throughHeader=0,firstInclude=0) out of 0 (forceInclude=0,throughHeader=0)
15:59:20 INFO: SE: 0 out of 0
15:59:20 INFO: Z3 refutation rate: 0 out of 0
15:59:20 INFO: Subprocess(es) done in 46ms
15:59:20 INFO: 0 compilation units analyzed
15:59:20 INFO: ------------------------------------------------------------------------
15:59:20 INFO: EXECUTION FAILURE
15:59:20 INFO: ------------------------------------------------------------------------
15:59:20 INFO: Total time: 48.891s
15:59:20 INFO: Final Memory: 63M/220M
15:59:20 INFO: ------------------------------------------------------------------------
15:59:20 ERROR: Error during SonarQube Scanner execution
15:59:20 java.lang.IllegalStateException: The "build-wrapper-dump.json" file was found but 0 C/C++/Objective-C files were analyzed.
型
在其他项目中,在“API_asrcore”之前至少有一个文件夹不是git子模块在下面的示例中,在子模块之前有一个“action_manager”和一个“annoncesonore_html”文件夹
日志:
INFO: Using 1 thread for analysis according to value of "sonar.cfamily.threads" property.
14:49:17 WARN: Invalid character encountered in file /usr/src/lumiplan/src/specific/decodage/source/decodage_plot.cpp at line 310 for encoding US-ASCII. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
14:49:17 WARN: Invalid character encountered in file /usr/src/lumiplan/src/specific/protocol/source/msg_plot_idbrndef.cpp at line 632 for encoding US-ASCII. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
14:49:17 WARN: Invalid character encountered in file /usr/src/lumiplan/src/specific/protocol/public/msg_plot_idbrndef.h at line 165 for encoding US-ASCII. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
14:49:17 WARN: Invalid character encountered in file /usr/src/lumiplan/src/specific/decodage/public/decodage_plot.h at line 166 for encoding US-ASCII. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
14:49:17 WARN: Invalid character encountered in file /usr/src/lumiplan/src/specific/synchronisation/source/synchronisation.cpp at line 68 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
14:49:17 WARN: Invalid character encountered in file /usr/src/lumiplan/src/specific/configuration_specific/source/configuration_specific.cpp at line 216 for encoding US-ASCII. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
14:49:17 WARN:
14:49:17 CFamily plugin supports incremental analysis with the use of a cache:
14:49:17
14:49:17 * if you do not want to enable cache
14:49:17 please explicitly disable it
14:49:17 by setting the following property to your analysis:
14:49:17 sonar.cfamily.cache.enabled=false
14:49:17
14:49:17 * to enable cache please specify the following 2 options:
14:49:17 sonar.cfamily.cache.enabled=true
14:49:17 sonar.cfamily.cache.path=relative_or_absolute_path_to_cache_location
14:49:17
14:49:17 * visit the documentation page for more information
14:49:17 https://openshift.lumiplan.com/sonarqube/documentation/analysis/languages/cfamily/
14:49:17
14:49:17 INFO: [pool-3-thread-1] /usr/src/lumiplan/projects/linux-arm/../../src/specific/action_manager/source/action_handler.cpp
14:49:17 INFO: [pool-3-thread-1] /usr/src/lumiplan/projects/linux-arm/../../src/specific/annoncesonore_html/sources/annoncesonore.cpp
14:49:17 INFO: PCH: unique=0 use=0 (forceInclude=0,throughHeader=0,firstInclude=0) out of 2 (forceInclude=0,throughHeader=0)
14:49:17 INFO: SE: 2 out of 2
14:49:17 INFO: Z3 refutation rate: 0 out of 3
型
在这种情况下,声纳分析是完整的,你知道为什么吗?(在这两种情况下都没有特定的sonar-project.properties)
1条答案
按热度按时间nr9pn0ug1#
我已经改变了我的策略。我已经创建了我的bash脚本来获取所有子模块路径,我已经将其添加到sona.exclusions路径(使用
第一个月
所以所有的子模块都必须验证它自己的代码质量,而不是主项目。