SonarOpenCommunity / sonar-cxx

SonarQube C++ Community plugin (cxx plugin): This plugin adds C++ support to SonarQube with the focus on integration of existing C++ tools.
GNU Lesser General Public License v3.0
1k stars 365 forks source link

GCC Compiler Warnings skipped by sonar-cxx #1923

Closed olsson-s closed 4 years ago

olsson-s commented 4 years ago

I'm not sure if this is a sonar-cxx issue or a general sonar issue. The problem occurs when using the sonar.cxx directives.

# Import gcc compiler warnings
sonar.cxx.gcc.reportPath=**/build_component.log
sonar.cxx.gcc.charset=UTF-8
sonar.cxx.gcc.regex=(?<file>.*):(?<line>[0-9]+):\\x20warning:\\x20(?<message>.*)\\x20\\[(?<id>.*)\\]

The debug info in the log file could help to solve or locate the issue.

Description

When I try to import GCC compiler warnings, I get the following error for every C++ file with warnings that is in my build:

[2020-08-19T03:40:10.823Z] INFO: Processing report '/skyline/workspace/SP7_Pipeline_Inspection_Branch_Tester/adapt_classes/rdp_classes/src/build_component.log'
[2020-08-19T03:40:10.823Z] INFO: Parsing 'GCC' initialized with report '/skyline/workspace/SP7_Pipeline_Inspection_Branch_Tester/adapt_classes/rdp_classes/src/build_component.log', Charset= 'UTF-8'
[2020-08-19T03:40:10.823Z] INFO: Using pattern : '(?<file>.*):(?<line>[0-9]+):\x20warning:\x20(?<message>.*)\x20\[(?<id>.*)\]'
[2020-08-19T03:40:10.823Z] WARN: Cannot find the file 'message_broker_product.cpp:161' in module 'KZ' base dir '/skyline/workspace/SP7_Pipeline_Inspection_Branch_Tester', skipping violations.

I believe the problem is that although sonar finds the log file in /skyline/workspace/SP7_Pipeline_Inspection_Branch_Tester/adapt_classes/rdp_classes/src/build_component.log, it does not check that same directory or its DB for the source file associated with the warning. In the case above, _message_brokerproduct.cpp is in _/skyline/workspace/SP7_Pipeline_Inspection_Branch_Tester/adapt_classes/rdpclasses/src/, but the plugin doesn't look there for it, or check the sonar-scanner DB for the source file with that name.

It looks like sonar requires absolute path names in the warnings, but from what I found, GCC can't provide absolute paths. Maybe there is some way to workaround this in sonar-cxx?

Steps to reproduce the problem

  1. Run sonar-scanner against my build with the sonar-project.properties listed below. My script creates defines, includes and excludes and these are passed in at command line (see attached debug for more info)
  2. Check the log file and note the "WARN: Cannot find the file" message above
  3. Check Sonarqube website for this build and note that compilergcc-W* errors are not imported

Expected behavior

Based on the sonar-project.properties, I hoped that sonar gcc compiler warnings parser would be able to find my cpp files and provide these warnings in Sonarqube website.

Actual behavior

Sonar GCC compiler warnings parser does not find the cpp files

Known workarounds

None that I know of, but since it appears to be a path issue, I guess I could copy also source files to the base of the project, but I don't think that will help me in the end.

LOG file

I listed the warnings above and attached DEBUG below. Here is my full sonar-project.properties file and my command line arguments for sonar-scanner which adds several other properties via command-line.

sonar.login=e1119ff1cc8f28fac0a57fbc1ac5b6219c160fe2
sonar.host.url=https://dev.skyline.leidos.com/sonarqube
sonar.projectKey=KZ
sonar.projectName=KZ-SP7
# Comma-separated paths to directories with sources (required)
sonar.sources=.
sonar.inclusions=**/*.cpp,**/*.h,**/*.hh,**/*.inl,**/*.hpp,**/*.cc,**/*.c,**/*.C,**/*.java
sonar.coverage.exclusions=**/*
# The following line helps with debugging
#sonar.verbose=true
sonar.cxx.suffixes.sources=.cxx,.cpp,.cc,.c,.C
sonar.cxx.suffixes.headers=.hxx,.hpp,.hh,.h,.inl
# Import gcc compiler warnings
sonar.cxx.gcc.reportPath=**/build_component.log
sonar.cxx.gcc.charset=UTF-8
sonar.cxx.gcc.regex=(?<file>.*):(?<line>[0-9]+):\\x20warning:\\x20(?<message>.*)\\x20\\[(?<id>.*)\\]
sonar.java.file.suffixes=.jav,.java
sonar.java.binaries=**/classes
sonar.java.libraries=/usr/java/latest/jre/lib/ext/jfxrt.jar,/usr/share/java/eclipselink.jar,/usr/share/java/javax.persistence.jar,/usr/share/java/postgresql.jdbc.jar,/usr/share/java/annotations.jar,/usr/share/java/jsr305.jar,/usr/share/java/log4j-2.0/log4j-api-2.0.jar,/usr/share/java/log4j-2.0/log4j-core-2.0.jar
# Uncomment the next line for debugging
# sonar.scanner.dumpToFile=sonar-project.properties.dump
# Encoding of the source files
sonar.sourceEncoding=UTF-8
12:14:03.112 INFO: Processing report '/home/users/gbg/olssons/clone/dup-workspace/adapt_classes/rdp_classes/src/build_component.log'
12:14:03.112 INFO: Parsing 'GCC' initialized with report '/home/users/gbg/olssons/clone/dup-workspace/adapt_classes/rdp_classes/src/build_component.log', Charset= 'UTF-8'
12:14:03.112 INFO: Using pattern : '(?<file>.*):(?<line>[0-9]+):\x20warning:\x20(?<message>.*)\x20\[(?<id>.*)\]'
12:14:03.139 DEBUG: Scanner-matches file='message_broker_product.cpp:161' line='21' id='-Wsign-compare' msg=comparison between signed and unsigned integer expressions
12:14:03.139 DEBUG: Unable to get the real path: module 'KZ', baseDir '/home/users/gbg/olssons/clone/dup-workspace', path 'message_broker_product.cpp:161', exception '/home/users/gbg/olssons/clone/dup-workspace/message_broker_product.cpp:161'
12:14:03.139 WARN: Cannot find the file 'message_broker_product.cpp:161' in module 'KZ' base dir '/home/users/gbg/olssons/clone/dup-workspace', skipping violations.
12:14:03.139 DEBUG: Scanner-matches file='/home/users/gbg/olssons/clone/dup-workspace/sdr_ifs/sdr_ifs/src/././././././diag_log.h:220' line='36' id='-Wwrite-strings' msg=deprecated conversion from string constant to ‘char*’
12:14:03.139 DEBUG: Unable to get the real path: module 'KZ', baseDir '/home/users/gbg/olssons/clone/dup-workspace', path '/home/users/gbg/olssons/clone/dup-workspace/sdr_ifs/sdr_ifs/src/././././././diag_log.h:220', exception '/home/users/gbg/olssons/clone/dup-workspace/sdr_ifs/sdr_ifs/src/diag_log.h:220'
12:14:03.139 WARN: Cannot find the file '/home/users/gbg/olssons/clone/dup-workspace/sdr_ifs/sdr_ifs/src/././././././diag_log.h:220' in module 'KZ' base dir '/home/users/gbg/olssons/clone/dup-workspace', skipping violations.
12:14:03.140 DEBUG: Scanner-matches file='message_broker_product.cpp:1' line='17' id='-Wunused-variable' msg=‘{anonymous}::__route_expansion_features’ defined but not used
12:14:03.140 DEBUG: Unable to get the real path: module 'KZ', baseDir '/home/users/gbg/olssons/clone/dup-workspace', path 'message_broker_product.cpp:1', exception '/home/users/gbg/olssons/clone/dup-workspace/message_broker_product.cpp:1'
12:14:03.140 WARN: Cannot find the file 'message_broker_product.cpp:1' in module 'KZ' base dir '/home/users/gbg/olssons/clone/dup-workspace', skipping violations.
12:14:03.140 DEBUG: CXX-COMPILER-GCC processed = 0

Command Line arguments:

/skyline/sonar-scanner/jre/bin/java -Djava.awt.headless=true -classpath /skyline/sonar-scanner/lib/sonar-scanner-cli-4.2.0.1873.jar -Dscanner.home=/skyline/sonar-scanner -Dproject.home=/home/users/gbg/olssons/clone/dup-workspace org.sonarsource.scanner.cli.Main -X -Dproject.settings=./spt/tool_config/sonarqube/sonar-project.properties -Dsonar.projectVersion=dup-workspace -Dsonar.exclusions=**/spt/spt_adapt/src/ProC/**/*,**/spt/spt_adapt/src/VET/**/*,**/spt/spt_dra/**/*,**/adapt_classes/common_classes/test/**/*,**/adapt_classes/cwp_classes/test/**/*,**/adapt_classes/dlp_classes/test/**/*,**/adapt_classes/fdp_classes/test/**/*,**/adapt_classes/sim_classes/test/**/*,**/ais_ifs/ais_ifs/test/**/*,**/base/asterix/test/**/*,**/base/base_math/test/**/*,**/base/icao_base/test/**/*,**/base/porting/test/**/*,**/base/standard/test/**/*,**/base/system_ifs/test/**/*,**/byp_ifs/byp_ifs/test/**/*,**/cnsatm/cnsatm/test/**/*,**/communications/combase/test/**/*,**/communications/if_base/test/**/*,**/communications/nextcom/test/**/*,**/cwp/fsp/test/**/*,**/cwp/hci/test/**/*,**/data_mgmt/collections/test/**/*,**/data_mgmt/data_mgmt/test/**/*,**/data_mgmt/indices/test/**/*,**/dlp/adm/test/**/*,**/dlp/cdm/test/**/*,**/dlp/dlm/test/**/*,**/dlp/dlp_common/test/**/*,**/dlp/dtm/test/**/*,**/dlp_ifs/dlp_ifs/test/**/*,**/documentation/test/**/*,**/ext_comm/ext_comm/test/**/*,**/fdp/aidc/test/**/*,**/fdp/aim/test/**/*,**/fdp/cof/test/**/*,**/fdp/db/test/**/*,**/fdp/ext_ifs/test/**/*,**/fdp/fltdata/test/**/*,**/fdp/fn_support/test/**/*,**/fdp/functions/test/**/*,**/fdp/icao/test/**/*,**/fdp/msg/test/**/*,**/fdp/pla/test/**/*,**/fdp/plb/test/**/*,**/fdp/protocols/test/**/*,**/fdp/rim/test/**/*,**/fdp/std/test/**/*,**/fdp/sup/test/**/*,**/fdp/traj_model/test/**/*,**/fdp_ifs/fdp_ifs/test/**/*,**/ncon_ifs/ncon_ifs/test/**/*,**/rdp/mearts/test/**/*,**/sdr/sdr/test/**/*,**/sdr_ifs/sdr_ifs/test/**/*,**/sim/ads_simulator/pilot_simulator/test/**/*,**/sim/ads_simulator/test/**/*,**/sim/arinc_gw_ifs/test/**/*,**/spt/spt_adapt/test/**/*,**/spt/spt_dra/test/**/*,**/IT/swac/gtest/**/*,**/adapt_classes/rdp_classes/gtest/**/*,**/base/asterix/gtest/**/*,**/sdr/sdr/gtest/**/*,**/sdr/xifp/gtest/**/*,**/sdr_ifs/sdr_ifs/gtest/**/*,**/base/ntl/tst/**/*,**/cwp/hqi/tst/**/*,**/base/unit_test/**/*,**/IT/it_tools/documentation/**/*,**/adapt_classes/common_classes/documentation/**/*,**/adapt_classes/cwp_classes/documentation/**/*,**/adapt_classes/fdp_classes/documentation/**/*,**/adapt_data/common_data/documentation/**/*,**/adapt_data/fdp_data/documentation/**/*,**/adapt_data/rdp_data/documentation/**/*,**/base/asterix/documentation/**/*,**/base/base_math/documentation/**/*,**/base/event_core/documentation/**/*,**/base/icao_base/documentation/**/*,**/base/porting/documentation/**/*,**/base/standard/documentation/**/*,**/base/utilities/documentation/**/*,**/byp/byp/documentation/**/*,**/byp/qnh/documentation/**/*,**/byp_ifs/byp_ifs/documentation/**/*,**/communications/combase/documentation/**/*,**/communications/if_base/documentation/**/*,**/communications/nextcom/documentation/**/*,**/cwp/fsp/documentation/**/*,**/cwp/hci/documentation/**/*,**/data_mgmt/data_mgmt/documentation/**/*,**/dlp/cdm/documentation/**/*,**/documentation/**/*,**/fdp/aim/documentation/**/*,**/fdp/chkpt/documentation/**/*,**/fdp/cod/documentation/**/*,**/fdp/cof/documentation/**/*,**/fdp/csp/documentation/**/*,**/fdp/db/documentation/**/*,**/fdp/dev_tools/documentation/**/*,**/fdp/documentation/**/*,**/fdp/ext_ifs/documentation/**/*,**/fdp/fltdata/documentation/**/*,**/fdp/fn_support/documentation/**/*,**/fdp/functions/documentation/**/*,**/fdp/icao/documentation/**/*,**/fdp/msg/documentation/**/*,**/fdp/pla/documentation/**/*,**/fdp/plb/documentation/**/*,**/fdp/protocols/documentation/**/*,**/fdp/rim/documentation/**/*,**/fdp/std/documentation/**/*,**/fdp/sup/documentation/**/*,**/fdp/sysconf/documentation/**/*,**/fdp/tools/documentation/**/*,**/fdp/traj_model/documentation/**/*,**/fdp/trkdata/documentation/**/*,**/fdp_ifs/fdp_ifs/documentation/**/*,**/framework/framework/documentation/**/*,**/mc_ifs/mc_ifs/documentation/**/*,**/ncon/ncon/documentation/**/*,**/ncon_ifs/ncon_ifs/documentation/**/*,**/rdp/mearts/documentation/**/*,**/rdp/swx/documentation/**/*,**/rdp_ifs/rdp_ifs/documentation/**/*,**/sdr/sdr/documentation/**/*,**/sdr/tdm/documentation/**/*,**/sdr_ifs/sdr_ifs/documentation/**/*,**/spt/install/documentation/**/*,**/spt/product_cm/documentation/**/*,**/spt/spt_adapt/documentation/**/*,**/spt/spt_adapt/src/documentation/**/*,**/spt/spt_adapt/src/vit/documentation/**/*,**/spt/spt_dra/documentation/**/*,**/spt/tsf_adapt/documentation/**/*,**/fdp/oip/**/*, -Dsonar.cxx.includeDirectories=/home/users/gbg/olssons/clone/dup-workspace,/home/users/gbg/olssons/clone/dup-workspace/adapt_classes/common_classes/src,/home/users/gbg/olssons/clone/dup-workspace/adapt_classes/cwp_classes/src,/home/users/gbg/olssons/clone/dup-workspace/adapt_classes/dlp_classes/src,/home/users/gbg/olssons/clone/dup-workspace/adapt_classes/ext_comm_classes/src,/home/users/gbg/olssons/clone/dup-workspace/adapt_classes/fdp_classes/src,/home/users/gbg/olssons/clone/dup-workspace/adapt_classes/mc_classes/src,/home/users/gbg/olssons/clone/dup-workspace/adapt_classes/rdp_classes/src,/home/users/gbg/olssons/clone/dup-workspace/adapt_classes/sim_classes/src,/home/users/gbg/olssons/clone/dup-workspace/ais_ifs/ais_ifs/src,/home/users/gbg/olssons/clone/dup-workspace/base/asterix/src,/home/users/gbg/olssons/clone/dup-workspace/base/base_math/src,/home/users/gbg/olssons/clone/dup-workspace/base/event_core/src,/home/users/gbg/olssons/clone/dup-workspace/base/icao_base/src,/home/users/gbg/olssons/clone/dup-workspace/base/ntl/src,/home/users/gbg/olssons/clone/dup-workspace/base/ntl/src/nt,/home/users/gbg/olssons/clone/dup-workspace/base/ntl/src/rw,/home/users/gbg/olssons/clone/dup-workspace/base/porting/src,/home/users/gbg/olssons/clone/dup-workspace/base/standard/src,/home/users/gbg/olssons/clone/dup-workspace/base/system_ifs/src,/home/users/gbg/olssons/clone/dup-workspace/base/utilities/src,/home/users/gbg/olssons/clone/dup-workspace/byp/byp_common/src,/home/users/gbg/olssons/clone/dup-workspace/byp_ifs/byp_ifs/src,/home/users/gbg/olssons/clone/dup-workspace/cnsatm/cnsatm/src,/home/users/gbg/olssons/clone/dup-workspace/communications/combase/src,/home/users/gbg/olssons/clone/dup-workspace/communications/if_base/src,/home/users/gbg/olssons/clone/dup-workspace/communications/nextcom/src,/home/users/gbg/olssons/clone/dup-workspace/cwp/hci/ods_dev,/home/users/gbg/olssons/clone/dup-workspace/cwp/hci/src,/home/users/gbg/olssons/clone/dup-workspace/cwp_ifs/cwp_ifs/src,/home/users/gbg/olssons/clone/dup-workspace/data_mgmt/collections/src,/home/users/gbg/olssons/clone/dup-workspace/data_mgmt/data_mgmt/src,/home/users/gbg/olssons/clone/dup-workspace/data_mgmt/indices/src,/home/users/gbg/olssons/clone/dup-workspace/dlp/cdm/src,/home/users/gbg/olssons/clone/dup-workspace/dlp/dlp_common/src,/home/users/gbg/olssons/clone/dup-workspace/dlp_ifs/dlp_ifs/src,/home/users/gbg/olssons/clone/dup-workspace/ext_comm/ext_comm/src,/home/users/gbg/olssons/clone/dup-workspace/fdp/aidc/src,/home/users/gbg/olssons/clone/dup-workspace/fdp/db/src,/home/users/gbg/olssons/clone/dup-workspace/fdp/ext_ifs/src,/home/users/gbg/olssons/clone/dup-workspace/fdp/fltdata/src,/home/users/gbg/olssons/clone/dup-workspace/fdp/fn_support/src,/home/users/gbg/olssons/clone/dup-workspace/fdp/functions/src,/home/users/gbg/olssons/clone/dup-workspace/fdp/icao/src,/home/users/gbg/olssons/clone/dup-workspace/fdp_ifs/fdp_ifs/src,/home/users/gbg/olssons/clone/dup-workspace/fdp/msg/src,/home/users/gbg/olssons/clone/dup-workspace/fdp/oldi/src,/home/users/gbg/olssons/clone/dup-workspace/fdp/radar_handover/src,/home/users/gbg/olssons/clone/dup-workspace/fdp/std/src,/home/users/gbg/olssons/clone/dup-workspace/fdp/traj_model/src,/home/users/gbg/olssons/clone/dup-workspace/fdp/trkdata/src,/home/users/gbg/olssons/clone/dup-workspace/framework/framework/src,/home/users/gbg/olssons/clone/dup-workspace/IT/perfmon/src,/home/users/gbg/olssons/clone/dup-workspace/IT/swac/formats,/home/users/gbg/olssons/clone/dup-workspace/kacc_comm_ifs/efs_ifs/src,/home/users/gbg/olssons/clone/dup-workspace/kacc_comm_ifs/kacc_comm_ifs/src,/home/users/gbg/olssons/clone/dup-workspace/kacc_comm/kacc_comm/src,/home/users/gbg/olssons/clone/dup-workspace/mc_ifs/mc_ifs/src,/home/users/gbg/olssons/clone/dup-workspace/ncon_ifs/ncon_ifs/src,/home/users/gbg/olssons/clone/dup-workspace/rcom_ifs/rcom_ifs/src,/home/users/gbg/olssons/clone/dup-workspace/rcom/rcom_common/src,/home/users/gbg/olssons/clone/dup-workspace/rcom/translators/src,/home/users/gbg/olssons/clone/dup-workspace/rdp_ifs/rdp_ifs/src,/home/users/gbg/olssons/clone/dup-workspace/rdp/mearts/src,/home/users/gbg/olssons/clone/dup-workspace/sdr_ifs/sdr_ifs/src,/home/users/gbg/olssons/clone/dup-workspace/sim/arinc_gw_ifs/src,/home/users/gbg/olssons/clone/dup-workspace/sim/events/src,/home/users/gbg/olssons/clone/dup-workspace/sim/interfaces/src,/home/users/gbg/olssons/clone/dup-workspace/sim/profile_event/src,/home/users/gbg/olssons/clone/dup-workspace/sim/radar/src,/home/users/gbg/olssons/clone/dup-workspace/sim/responders/src,/home/users/gbg/olssons/clone/dup-workspace/sim/scenario/src,/home/users/gbg/olssons/clone/dup-workspace/sim/sim_ifs/src,/home/users/gbg/olssons/clone/dup-workspace/smc/common/src,/home/users/gbg/olssons/clone/dup-workspace/smc/mcbase/src,/home/users/gbg/olssons/clone/dup-workspace/smc/mcmsg/src,/home/users/gbg/olssons/clone/dup-workspace/smc/mcview/ods_dev,/home/users/gbg/olssons/clone/dup-workspace/smc/snmpapi/src,/opt/isode/include/isode/x400sdk,/Tools/atcoach/include,/Tools/atcoach/include_4.42,/Tools/odsADE/include,/Tools/protoc-2.5.0/include/google/protobuf,/Tools/protoc-2.5.0/include/google/protobuf/io,/Tools/protoc-2.5.0/include/google/protobuf/stubs,/usr/include,/usr/include/amqpcpp,/usr/include/amqpcpp/linux_tcp,/usr/include/arpa,/usr/include/asm,/usr/include/asm-generic,/usr/include/bits,/usr/include/c++/4.4.4,/usr/include/c++/4.4.4/backward,/usr/include/c++/4.4.4/bits,/usr/include/c++/4.4.4/debug,/usr/include/c++/4.4.4/ext,/usr/include/c++/4.4.4/tr1_impl,/usr/include/c++/4.4.4/x86_64-redhat-linux/bits,/usr/include/gnu,/usr/include/linux,/usr/include/net,/usr/include/netinet,/usr/include/net-snmp,/usr/include/net-snmp/agent,/usr/include/net-snmp/library,/usr/include/net-snmp/machine,/usr/include/net-snmp/system,/usr/include/rpc,/usr/include/sys,/usr/include/X11,/usr/include/X11/extensions,/usr/include/X11/ICE,/usr/include/X11/SM,/usr/include/X11/Xaw,/usr/include/X11/Xmu,/usr/include/Xbae,/usr/include/Xm,/usr/lib/gcc/x86_64-redhat-linux/4.4.4/include,/usr/lib/x86_64-redhat-linux5E/include,/usr/lib/x86_64-redhat-linux5E/include/bits,/usr/lib/x86_64-redhat-linux5E/include/gnu,/usr/lib/x86_64-redhat-linux5E/include/sys,/usr/pti/include,/usr/pti/rdr/include,/usr/pgsql-9.3/include,/Tools/protoc-2.5.0/include,/usr/include/qt5,/usr/include/qt5/QtCore,/usr/include/qt5/QtWidgets,/usr/include/qt5/QtGui,cwp/hqi/src,cwp/hqi/src/model,cwp/hqi/src/build,smc/mcview/src,spt/spt_adapt/src/vit/src,sdr/sdr,sdr/xifp,sdr_ifs/sdr_ifs,IT/swac,adapt_classes/rdp_classes, -Dsonar.cxx.defines=__linux__ ?_POSIX_SOURCE ?__PERFORMANCE__ ?__SKYLINE_DEBUG__ 1 ?DEBUG_ON ?__OLDI_COORDINATION__ ?__AIDC_COORDINATION__ ?__ICAO_COORDINATION__ ?IPT_PRODUCT ?__CYRILLIC_SUPPORT__ ?__IFPS_SUPPORT__ ?NET_SNMP  -Dsonar.cxx.cppcheck.reportPath=./reports/cppcheck-report.xml

Related information

guwirth commented 4 years ago

Hi @olsson-s,

Please read:

gcc reports filenames in diagnostics in the same form they are specified on the command line, so if you specify them as full pathnames in the command you'll get them that way in the diagnostics.

Hope that helps.

Regards,

olsson-s commented 4 years ago

Thanks @guwirth.

OK, I had read those documents before, but some of it sinks in more as I read it again. I think I've done the Compiler part correctly. The path separator is the problem. I guess in my C++ makefile, I could find a way to force the full path of the filename being compiled somehow. The gcc will then use this full path name instead of relative to the directory where the warnings were found (e.g. my build_component.log file).

As another option, for example, if I add all my source directories to sonar.sources= directive, would that help my situation? Right now I use:

sonar.sources=.

I've already added all the sonar.cxx.includeDirectories set to a full list of my include locations so maybe I just need to do the same for sources?

Or that wouldn't help? Somehow forcing gcc to provide a full path or path relative to ProjectDir is the only way?

-Sten

guwirth commented 4 years ago

Hi @olsson-s,

SQ read reports always in two steps:

In case of absolute paths, the paths must exactly match. In case of relative paths in the report the path is made absolute relative to the root folder. Root folder is where sonar-project.properties is or https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/. Other settings are only to narrow the focus: https://docs.sonarqube.org/latest/project-administration/narrowing-the-focus/

After the sensor made the path absolute the path must match with the indexed path.

Regards,

olsson-s commented 4 years ago

Thank you, @guwirth. I think the issue must be closed then. It seems like there will be no easy way to import the filenames. I'm building 350 components with thousands of source files and I was hoping there would be a way to configure the tool instead of changing how the builds are done. I understand this is a difference in my config though and others that build with absolute filenames or filenames relative to the root folder don't have this problem.

I have an idea how to fix it. After I build all the software, I can run perl or python script on all my build_component.log(s) and swap the file name for it's absolute location.

Thanks again for your help. Please close this issue. -Sten

olsson-s commented 4 years ago

Looks like I can close it :)

guwirth commented 4 years ago

Hi @olsson-s,

I’m not familiar with gcc and cmake but I’m quite sure there is a solution. Please ask in a cmake forum how to setup cmake to get absolute paths or path relative to root.

Regards,