Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing named-capturing group 'column' in sonar.cxx.vc.regex creates an exception #2867

Open
Artemi645 opened this issue Feb 15, 2025 · 7 comments
Labels
Milestone

Comments

@Artemi645
Copy link

Hello! I am trying to use sonar-cxx, but it cant find any issues even with vs_project test project.

My steps:

  • I use default vs_project sonar-project.properties file with my url and token properties
  • Copied Sonar way CXX profile, named it CPP, activate 6200 rules and set it as default
    Image
    Image
  • Run sonar-scanner.bat -X with no additional arguments
    report.txt

And receive no issues

Image

Did I miss something when setting it up?
Also why do I get preprocessor warning in report about iostream?

  • OS Windows 11
  • SonarQube Community Build v25.2.0.102705
  • cxx plugin version 2.2.0.1110
  • sonar-scanner version 6.2.1.4610
  • Java SDK 17.0.12
@guwirth
Copy link
Collaborator

guwirth commented Feb 15, 2025

Hi,

in the LOG file I saw:

16:35:38.730 DEBUG 1008 rules for 'compiler-vc' were loaded from server
16:35:38.731 DEBUG Searching 'sonar.cxx.vc.reportPaths' files with Ant pattern '[./reports/warnings.log]'
16:35:38.731 DEBUG Search files(s) in path(s): 'C:/sonar/vs_project/reports/warnings.log'
16:35:38.740 DEBUG Found '1' file(s)
16:35:38.740 INFO  Processing report 'C:\sonar\vs_project\reports\warnings.log'
16:35:38.754 DEBUG Processing 'Visual C++' report 'C:\sonar\vs_project\reports\warnings.log', Encoding='UTF-16LE', Pattern='(.*>)?(?<file>.*)\((?<line>\d+),\d+\):\x20warning\x20(?<id>C\d+):\x20(?<message>.*)'
16:35:38.757 DEBUG named-capturing group 'column' is not used in regex.
java.lang.IllegalArgumentException: No group with name <column>
	at java.base/java.util.regex.Matcher.getMatchedGroupIndex(Unknown Source)
	at java.base/java.util.regex.Matcher.group(Unknown Source)
	at org.sonar.cxx.sensors.compiler.CxxCompilerSensor.getSubSequence(CxxCompilerSensor.java:192)
	at org.sonar.cxx.sensors.compiler.CxxCompilerSensor.processReport(CxxCompilerSensor.java:70)
	at org.sonar.cxx.sensors.utils.CxxIssuesReportSensor.executeReport(CxxIssuesReportSensor.java:197)
	at org.sonar.cxx.sensors.utils.CxxIssuesReportSensor.executeImpl(CxxIssuesReportSensor.java:92)
	at org.sonar.cxx.sensors.utils.CxxReportSensor.execute(CxxReportSensor.java:101)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)
	at org.sonar.scanner.sensor.ProjectSensorsExecutor.execute(ProjectSensorsExecutor.java:54)
	at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:173)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)
	at org.sonar.scanner.bootstrap.SpringScannerContainer.doAfterStart(SpringScannerContainer.java:350)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)
	at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:142)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)
	at org.sonar.scanner.bootstrap.ScannerMain.runScannerEngine(ScannerMain.java:151)
	at org.sonar.scanner.bootstrap.ScannerMain.run(ScannerMain.java:66)
	at org.sonar.scanner.bootstrap.ScannerMain.main(ScannerMain.java:52)

16:35:38.760 WARN  Cannot find the file 'C:/projects/sonar-cxx/integration-tests/testdata/vs_project/src/main.cpp' in project 'vs_project' with baseDir 'C:\sonar\vs_project', skipping

Think that is the reason?

  • Is your VC report with or without column numbers?
  • Did you set the regex or is it the default?

Regards,

@Artemi645
Copy link
Author

Regex is default as well as VC report.
I tried another expamples and its works fine.
So, I think the problem was with the old regex.

But what about with include warning? In another examples the same problem

@guwirth
Copy link
Collaborator

guwirth commented Feb 15, 2025

But what about with include warning? In another examples the same problem

Maybe this page helps https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Detect-and-fix-parsing-errors

@guwirth
Copy link
Collaborator

guwirth commented Feb 15, 2025

So, I think the problem was with the old regex.

This one:

sonar.cxx.vc.regex=(.*>)?(?<file>.*)\\((?<line>\\d+),\\d+\\):\\x20warning\\x20(?<id>C\\d+):\\x20(?<message>.*)

@Artemi645
Copy link
Author

Okay, i will check it

Thank you!

@guwirth guwirth changed the title no issues found with sonar-cxx Missing named-capturing group 'column' in sonar.cxx.vc.regex creates an exception Feb 15, 2025
@guwirth guwirth added bug and removed question labels Feb 15, 2025
@guwirth guwirth added this to the 2.2.0 milestone Feb 15, 2025
@guwirth guwirth reopened this Feb 15, 2025
@guwirth
Copy link
Collaborator

guwirth commented Feb 15, 2025

Todo:

  • verify missing named-capturing group 'column' in sonar.cxx.vc.regex
  • repair integration test vc_project

@guwirth
Copy link
Collaborator

guwirth commented Feb 15, 2025

Should work without exception in LOG file

LOG.debug("named-capturing group '{}' is not used in regex.", groupName, e);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants