Skip to content

Commit

Permalink
JS-385 Fix SonarLint ITS (#4889)
Browse files Browse the repository at this point in the history
  • Loading branch information
vdiez authored Nov 1, 2024
1 parent 6126c52 commit 12baa4d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
1 change: 0 additions & 1 deletion its/plugin/sonarlint-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

<artifactId>javascript-it-plugin-sonarlint-tests</artifactId>
<name>JavaScript :: IT :: Plugin :: SonarLint Tests</name>
<packaging>pom</packaging>

<properties>
<surefire.argLine>-server</surefire.argLine>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

package com.sonar.javascript.it.plugin.sonarlint.tests;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.tuple;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

package com.sonar.javascript.it.plugin.sonarlint.tests;

import static org.assertj.core.api.Assertions.assertThat;

import java.nio.file.Files;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import static java.util.Objects.requireNonNull;

package com.sonar.javascript.it.plugin.sonarlint.tests;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Objects;
import java.util.regex.Pattern;
import org.sonarsource.sonarlint.core.analysis.api.ClientInputFile;

Expand All @@ -42,14 +41,14 @@ public class TestUtils {
*
*/
private static Path artifact() {
var target = homeDir()
.resolve("../../../../../../sonar-plugin/sonar-javascript-plugin/target")
.normalize();
try (var stream = Files.walk(target, 1)) {
return stream
.filter(p -> pluginFilenameMatcher().matcher(p.getFileName().toString()).matches())
.findAny()
.orElseThrow(() -> new IllegalStateException("Cannot find plugin artifact in " + target));
try {
var target = Path.of("../../../sonar-plugin/sonar-javascript-plugin/target").toRealPath();
try (var stream = Files.walk(target, 1)) {
return stream
.filter(p -> pluginFilenameMatcher().matcher(p.getFileName().toString()).matches())
.findAny()
.orElseThrow(() -> new IllegalStateException("Cannot find plugin artifact in " + target));
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
Expand All @@ -61,14 +60,6 @@ private static Pattern pluginFilenameMatcher() {
: Pattern.compile("sonar-javascript-plugin-[0-9.]*(?:-SNAPSHOT)?\\.jar");
}

public static Path homeDir() {
try {
return Path.of(requireNonNull(TestUtils.class.getResource("TestUtils.txt")).toURI());
} catch (URISyntaxException e) {
throw new IllegalStateException(e);
}
}

public static Path projectDir(String projectName) {
var file = Path.of("../projects").resolve(projectName);
if (!Files.exists(file)) {
Expand Down

0 comments on commit 12baa4d

Please sign in to comment.