Skip to content

Commit 7e7020e

Browse files
committed
Merge pull request #814 from guwirth/bugfix/773
fix #773
2 parents bfd2e53 + 4a741f3 commit 7e7020e

File tree

3 files changed

+60
-66
lines changed

3 files changed

+60
-66
lines changed

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ on_failure:
6565
- ps: Get-ChildItem cxx-squid\target\surefire-reports\*.txt | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
6666
- ps: Get-ChildItem cxx-checks\target\surefire-reports\*.txt | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
6767
- ps: Get-ChildItem sonar-cxx-plugin\target\surefire-reports\*.txt | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
68-
- ps: Get-ChildItem *_project_.log | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
68+
- ps: Get-ChildItem *.log | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
6969
- ps: Get-ChildItem C:\sonarqube-5.3\sonarqube-5.3\logs\* | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
7070

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,44 @@
1-
#Feature: cpp-multimodule-project
2-
#
3-
# Test multimodule project with reports at root of the project
4-
#
5-
# Scenario: cpp-multimodule-project-2
6-
# GIVEN the project "cpp-multimodule-project-2"
7-
# WHEN I run "sonar-runner -X"
8-
# THEN the analysis finishes successfully
9-
# AND the analysis in server has completed
10-
# AND the analysis log contains no error/warning messages except those matching:
11-
# """
12-
# .*WARN.*Unable to get a valid mac address, will use a dummy address
13-
# .*WARN.*cannot find the sources for '#include <gtest/gtest\.h>'
14-
# .*WARN.*cannot find the sources for '#include <iostream>'
15-
# .*WARN - Cannot find the file '.*', skipping violations
16-
# .*WARN.*to create a dependency with .*
17-
# .*WARN - the include root '.*' doesn't exist
18-
# .*WARN - .* cannot find the sources for .*
19-
# .*WARN - SCM provider autodetection failed.*
20-
# .*WARN.*Cannot find a report for '.*'
21-
# .*WARN.*- File access Failed '.*'
22-
# .*WARN.* A multi-module project can't have source folders, so '.*'
23-
# .*ERROR.*Invalid report baseDir '.*'
24-
# .*ERROR.*Using module base failed to find Path '.*'
25-
# """
26-
# AND the following metrics have following values:
27-
# | metric | value |
28-
# # size metrics
29-
# | ncloc | 12 |
30-
# | lines | 14 |
31-
# | statements | 4 |
32-
# | classes | 0 |
33-
# | files | 6 |
34-
# | directories | 4 |
35-
# | functions | 4 |
36-
# # complexity
37-
# | complexity | 4 |
38-
# | function_complexity | 1.0 |
39-
# | file_complexity | 0.7 |
40-
# # violations
41-
# | violations | 4 |
1+
Feature: cpp-multimodule-project
422

3+
Test multimodule project with reports at root of the project
434

5+
Scenario: cpp-multimodule-project-2
6+
7+
GIVEN the project "cpp-multimodule-project-2"
8+
and platform is not "Windows"
9+
10+
WHEN I run "sonar-runner -X"
11+
THEN the analysis finishes successfully
12+
AND the analysis in server has completed
13+
AND the analysis log contains no error/warning messages except those matching:
14+
"""
15+
.*WARN.*Unable to get a valid mac address, will use a dummy address
16+
.*WARN.*cannot find the sources for '#include <gtest/gtest\.h>'
17+
.*WARN.*cannot find the sources for '#include <iostream>'
18+
.*WARN - Cannot find the file '.*', skipping violations
19+
.*WARN.*to create a dependency with .*
20+
.*WARN - the include root '.*' doesn't exist
21+
.*WARN - .* cannot find the sources for .*
22+
.*WARN - SCM provider autodetection failed.*
23+
.*WARN.*Cannot find a report for '.*'
24+
.*WARN.*- File access Failed '.*'
25+
.*WARN.* A multi-module project can't have source folders, so '.*'
26+
.*ERROR.*Invalid report baseDir '.*'
27+
.*ERROR.*Using module base failed to find Path '.*'
28+
"""
29+
AND the following metrics have following values:
30+
| metric | value |
31+
# size metrics
32+
| ncloc | 12 |
33+
| lines | 14 |
34+
| statements | 4 |
35+
| classes | 0 |
36+
| files | 6 |
37+
| directories | 4 |
38+
| functions | 4 |
39+
# complexity
40+
| complexity | 4 |
41+
| function_complexity | 1.0 |
42+
| file_complexity | 0.7 |
43+
# violations
44+
| violations | 4 |

sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/CxxProjectBuilder.java

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ public CxxProjectBuilder() {
4949
public void build(Context context) {
5050
super.build(context);
5151

52-
ProjectDefinition definition = context.projectReactor().getRoot();
53-
5452
// collect all properties
5553
Map<String, String> envMap = System.getenv();
5654
for (Map.Entry<String, String> entry : envMap.entrySet()) {
@@ -65,33 +63,28 @@ public void build(Context context) {
6563
vars.put(key, value);
6664
}
6765

68-
props = definition.getProperties();
69-
for (String key : props.stringPropertyNames()) {
70-
String value = props.getProperty(key);
71-
vars.put(key, value);
66+
for (ProjectDefinition definition : context.projectReactor().getProjects()) {
67+
props = definition.getProperties();
68+
for (String key : props.stringPropertyNames()) {
69+
String value = props.getProperty(key);
70+
vars.put(key, value);
71+
}
7272
}
7373

7474
// replace placeholders
75-
for (String key : props.stringPropertyNames()) {
76-
String oldValue = props.getProperty(key);
77-
String newValue = expandVariables(oldValue);
78-
if (!oldValue.equals(newValue)) {
79-
definition.setProperty(key, newValue);
80-
LOG.debug("property expansion: key '{}'; value '{}' => '{}'", new Object[]{key, oldValue, newValue});
81-
}
82-
}
83-
84-
// add list of available property keys
85-
if (LOG.isDebugEnabled()) {
86-
StringBuilder sb = new StringBuilder("analysis parameters:\n");
75+
for (ProjectDefinition definition : context.projectReactor().getProjects()) {
76+
props = definition.getProperties();
8777
for (String key : props.stringPropertyNames()) {
88-
sb.append(" ");
89-
sb.append(key);
90-
sb.append("=");
91-
sb.append(props.getProperty(key));
92-
sb.append("\n");
78+
String oldValue = props.getProperty(key);
79+
String newValue = expandVariables(oldValue);
80+
if (!oldValue.equals(newValue)) {
81+
definition.setProperty(key, newValue);
82+
if (LOG.isDebugEnabled()) {
83+
LOG.debug("property expansion: project '{}'; key '{}'; value '{}' => '{}'",
84+
new Object[]{definition.getKey(), key, oldValue, newValue});
85+
}
86+
}
9387
}
94-
LOG.debug(sb.toString());
9588
}
9689
}
9790

0 commit comments

Comments
 (0)