Skip to content

Support MacOS EOLs #20

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

Merged
merged 4 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Inspired by https://github.com/SonarCommunity/sonar-github

# Current version


## Version 5.1.2

* merged [Support MacOS EOLs](https://github.com/javamachr/sonar-gitlab-plugin/pull/20)

## Version 5.1.1

* merged [On branch limit analysis to new issues since last leak period](https://github.com/javamachr/sonar-gitlab-plugin/pull/16)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static final Set<IGitLabApiWrapper.Line> getPositionsFromPatch(String pat
Set<IGitLabApiWrapper.Line> positions = new HashSet<>();

int currentLine = -1;
for (String line : patch.split("\\n|\\r\\n")) {
for (String line : patch.split("[\\r\\n]+")) {
if (line.startsWith("@")) {
Matcher matcher = PATCH_PATTERN.matcher(line);
if (!matcher.matches()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void testWrong() {
}

@Test
public void testCorrect() {
public void testCorrectUnixEOL() {
Assertions.assertThat(PatchUtils.getPositionsFromPatch("@@ -78,6 +78,27 @@\n" +
"\t\t\t\t\"src/styles.scss\",\n" +
" \"src/cordova-styles.scss\"\n" +
Expand Down Expand Up @@ -73,4 +73,76 @@ public void testCorrect() {
);
}


@Test
public void testCorrectMacEOL() {
Assertions.assertThat(PatchUtils.getPositionsFromPatch("@@ -78,6 +78,27 @@\r" +
"\t\t\t\t\"src/styles.scss\",\r" +
" \"src/cordova-styles.scss\"\r" +
" ]\r" +
" },\r" +
"+ \"prod-cordova\": {\r" +
"+ \"optimization\": true,\r" +
"+ \"outputHashing\": \"all\",\r" +
" \"sourceMap\": false,\r" +
" \"extractCss\": true,\r" +
" \"namedChunks\": false,\r" +
" \"aot\": true,\r" +
" \"extractLicenses\": true,\r" +
" \"vendorChunk\": false,\r" +
" \"buildOptimizer\": true,\r" +
" \"fileReplacements\": [\r" +
" {\r" +
" \"replace\": \"src/environments/environment.ts\",\r" +
" \"with\": \"src/environments/environment.prod-cordova.ts\"\r" +
" }\r" +
" ],\r" +
" \"styles\": [\r" +
" \"src/styles.scss\",\r" +
" \"src/cordova-styles.scss\"\r" +
" ]\r" +
" }\r" +
" }\r" +
" },")).isNotEmpty().hasSize(3).containsExactlyInAnyOrder(
new IGitLabApiWrapper.Line(83, " \"outputHashing\": \"all\","),
new IGitLabApiWrapper.Line(82, " \"optimization\": true,"),
new IGitLabApiWrapper.Line(81, " \"prod-cordova\": {")
);
}

@Test
public void testCorrectWindowsEOL() {
Assertions.assertThat(PatchUtils.getPositionsFromPatch("@@ -78,6 +78,27 @@\n" +
"\t\t\t\t\"src/styles.scss\",\r\n" +
" \"src/cordova-styles.scss\"\r\n" +
" ]\r\n" +
" },\r\n" +
"+ \"prod-cordova\": {\r\n" +
"+ \"optimization\": true,\r\n" +
"+ \"outputHashing\": \"all\",\r\n" +
" \"sourceMap\": false,\r\n" +
" \"extractCss\": true,\r\n" +
" \"namedChunks\": false,\r\n" +
" \"aot\": true,\r\n" +
" \"extractLicenses\": true,\r\n" +
" \"vendorChunk\": false,\r\n" +
" \"buildOptimizer\": true,\r\n" +
" \"fileReplacements\": [\r\n" +
" {\r\n" +
" \"replace\": \"src/environments/environment.ts\",\r\n" +
" \"with\": \"src/environments/environment.prod-cordova.ts\"\r\n" +
" }\r\n" +
" ],\r\n" +
" \"styles\": [\rn" +
" \"src/styles.scss\",\r\n" +
" \"src/cordova-styles.scss\"\r\n" +
" ]\r\n" +
" }\r\n" +
" }\r\n" +
" },")).isNotEmpty().hasSize(3).containsExactlyInAnyOrder(
new IGitLabApiWrapper.Line(83, " \"outputHashing\": \"all\","),
new IGitLabApiWrapper.Line(82, " \"optimization\": true,"),
new IGitLabApiWrapper.Line(81, " \"prod-cordova\": {")
);
}
}