Skip to content

Commit 6119eeb

Browse files
author
Gilles Grousset
committed
Merge branch 'release/0.3.2'
2 parents 7be990e + b45b804 commit 6119eeb

File tree

16 files changed

+803
-238
lines changed

16 files changed

+803
-238
lines changed

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# SonarQube Plugin for Flutter / Dart
22

3+
## 0.3.2
4+
5+
#### Breaking
6+
7+
- None.
8+
9+
#### Experimental
10+
11+
- None.
12+
13+
#### Enhancements
14+
15+
- Allow re-using an existing dartanalyzer report with `sonar.dart.analysis.reportPath` (thanks to [Peter Leibiger](https://github.com/kuhnroyal))
16+
- Add missing dart keywords `extension`, `on`, `mixin` (thanks to [Peter Leibiger](https://github.com/kuhnroyal))
17+
- Add pedantic 1.9.0 profile (thanks to [Daniel Morawetz](https://github.com/dmorawetz))
18+
- Faster analysis with 'flutter analyze' and support for different analysis modes with `sonar.flutter.analyzer.mode` (thanks to [Marc Reichelt](https://github.com/mreichelt))
19+
20+
#### Bug Fixes
21+
22+
- Ensure analyzer encoding is UTF-8 (thanks to [Daniel Morawetz](https://github.com/dmorawetz))
23+
24+
325
## 0.3.1
426

527
#### Breaking

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,19 @@ sonar.projectVersion=1.0
6969
# Use commas to specify more than one folder.
7070
sonar.sources=lib
7171
sonar.tests=test
72-
72+
7373
# Encoding of the source code. Default is default system encoding.
7474
sonar.sourceEncoding=UTF-8
75+
76+
# Allows reuse of an existing analyzer report
77+
# sonar.dart.analysis.reportPath=
78+
79+
# Analyzer mode
80+
# Can be:
81+
# - flutter (flutter analyze) - default
82+
# - dart (dart analyze)
83+
# - legacy (dartanalyzer)
84+
# sonar.flutter.analyzer.mode=
7585
```
7686

7787
*For a complete list of available options, please refer to the [SonarQube documentation](https://docs.sonarqube.org/latest/analysis/analysis-parameters/).*
@@ -84,10 +94,11 @@ Use the following commands from the root folder to start an analysis:
8494
```console
8595
# Download dependencies
8696
flutter pub get
87-
# Run tests
88-
flutter test --machine > tests.output
89-
# Compute coverage (--machine and --coverage cannot be run at once...)
90-
flutter test --coverage
97+
# Run tests with User feedback (in case some test are failing)
98+
flutter test
99+
# Run tests without user feedback regeneration tests.output and coverage/lcov.info
100+
flutter test --machine --coverage > tests.output
101+
91102
# Run the analysis and publish to the SonarQube server
92103
sonar-scanner
93104
```

dart-lang/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<artifactId>sonar-flutter</artifactId>
55
<groupId>fr.insideapp.sonarqube</groupId>
6-
<version>0.3.1</version>
6+
<version>0.3.2</version>
77
</parent>
88
<modelVersion>4.0.0</modelVersion>
99

dart-lang/src/main/java/fr/insideapp/sonarqube/dart/lang/DartSensor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class DartSensor implements Sensor {
4545
private static final Logger LOGGER = LoggerFactory.getLogger(DartSensor.class);
4646
private static final int EXECUTOR_TIMEOUT = 10000;
4747
public static final String DART_ANALYSIS_USE_EXISTING_OPTIONS_KEY = "sonar.dart.analysis.useExistingOptions";
48+
public static final String DART_ANALYSIS_USE_EXISTING_REPORT_PATH_KEY = "sonar.dart.analysis.reportPath";
4849

4950
@Override
5051
public void describe(SensorDescriptor sensorDescriptor) {

dart-lang/src/main/java/fr/insideapp/sonarqube/dart/lang/SourceLinesProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public SourceLine[] getLines(final InputStream inputStream, final Charset charse
5959
}
6060
sourceLines.add(new SourceLine(totalLines, count, global - count, global));
6161
} catch (final Throwable e) {
62-
LOGGER.warn("Error occured reading file", e);
62+
LOGGER.warn("Error occurred reading file", e);
6363
}
6464

6565
return sourceLines.toArray(new SourceLine[0]);
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* SonarQube Flutter Plugin
3+
* Copyright (C) 2020 inside|app
4+
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License as published by the Free Software Foundation; either
9+
* version 3 of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*/
20+
package fr.insideapp.sonarqube.dart.lang.issues;
21+
22+
import fr.insideapp.sonarqube.dart.lang.Dart;
23+
import fr.insideapp.sonarqube.dart.lang.issues.dartanalyzer.DartAnalyzerRulesDefinition;
24+
import org.slf4j.Logger;
25+
import org.slf4j.LoggerFactory;
26+
import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition;
27+
28+
public class DartProfilePedantic190 implements BuiltInQualityProfilesDefinition {
29+
30+
private static final Logger LOGGER = LoggerFactory.getLogger(DartProfile.class);
31+
public static final String DARTANALYZER_PROFILE_PATH = "fr/insideapp/sonarqube/dart/dartanalyzer/profile-pedantic.1.9.0.xml";
32+
33+
@Override
34+
public void define(BuiltInQualityProfilesDefinition.Context context) {
35+
36+
// dartanalyzer profile
37+
LOGGER.info("Creating dartanalyzer pedantic 1.9.0 Profile");
38+
NewBuiltInQualityProfile nbiqp = context.createBuiltInQualityProfile("dartanalyzer pedantic 1.9.0", Dart.KEY);
39+
XmlProfileParser.parse(DARTANALYZER_PROFILE_PATH, nbiqp);
40+
nbiqp.done();
41+
}
42+
}

dart-lang/src/main/java/fr/insideapp/sonarqube/dart/lang/issues/XmlProfileParser.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,23 @@ public static void parse(String path, NewBuiltInQualityProfile profile) {
4848
String repositoryKey = getChildContent(ruleElement, "repositoryKey");
4949
String key = getChildContent(ruleElement, "key");
5050

51-
NewBuiltInActiveRule newActiveRule = profile.activateRule(repositoryKey, key);
51+
try {
52+
NewBuiltInActiveRule newActiveRule = profile.activateRule(repositoryKey, key);
5253

53-
NodeList parameterNodeList = ruleElement.getElementsByTagName("parameter");
54-
XmlFile.asList(parameterNodeList).forEach(parameter -> {
55-
Element parameterElement = (Element) parameter;
56-
String paramKey = getChildContent(parameterElement, "key");
57-
String paramValue = getChildContent(parameterElement, "value");
58-
newActiveRule.overrideParam(paramKey, paramValue);
59-
});
54+
NodeList parameterNodeList = ruleElement.getElementsByTagName("parameter");
55+
XmlFile.asList(parameterNodeList).forEach(parameter -> {
56+
Element parameterElement = (Element) parameter;
57+
String paramKey = getChildContent(parameterElement, "key");
58+
String paramValue = getChildContent(parameterElement, "value");
59+
newActiveRule.overrideParam(paramKey, paramValue);
60+
});
6061

61-
Optional<String> priority = getOptionalChildContent(ruleElement, "priority");
62-
priority.ifPresent(newActiveRule::overrideSeverity);
62+
Optional<String> priority = getOptionalChildContent(ruleElement, "priority");
63+
priority.ifPresent(newActiveRule::overrideSeverity);
64+
} catch (IllegalArgumentException e) {
65+
// ignore, if rule was already registered in another profile
66+
}
67+
6368
});
6469

6570
} catch (IOException e) {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* SonarQube Flutter Plugin
3+
* Copyright (C) 2020 inside|app
4+
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License as published by the Free Software Foundation; either
9+
* version 3 of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*/
20+
21+
package fr.insideapp.sonarqube.dart.lang.issues.dartanalyzer;
22+
23+
public enum AnalyzerMode {
24+
flutter,
25+
dart,
26+
legacy;
27+
28+
public static final AnalyzerMode defaultMode = flutter;
29+
}

dart-lang/src/main/java/fr/insideapp/sonarqube/dart/lang/issues/dartanalyzer/DartAnalyzerReportParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public List<DartAnalyzerReportIssue> parse(String input) {
3131
List<DartAnalyzerReportIssue> issues = new ArrayList<>();
3232

3333
String[] lines = input.split(System.getProperty("line.separator"));
34-
Pattern pattern = Pattern.compile("(error|hint|lint)(.*)(-|•)(.*)(-|•)(.*):(.*):(.*)(-|•)(.*)");
34+
Pattern pattern = Pattern.compile("(hint|lint|info|warning|error)(.*)(-|•)(.*)(-|•)(.*):(.*):(.*)(-|•)(.*)");
3535
for (int i = 0; i < lines.length; i++) {
3636
Matcher matcher = pattern.matcher(lines[i]);
3737
while (matcher.find()) {

0 commit comments

Comments
 (0)