Skip to content

Commit 734d488

Browse files
committed
simplify
1 parent 39ac163 commit 734d488

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/DocGeneratorApplication.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@ public static void main(String[] args) throws IOException {
3030
String baseRepoPath = System.getProperty("basePath");
3131
if (baseRepoPath == null) {
3232
baseRepoPath = "./";
33+
} else {
34+
baseRepoPath += "/";
3335
}
3436

3537
FileManager fileManager = new FileManager(baseRepoPath);
3638
List<InstrumentationModule> modules = new InstrumentationAnalyzer(fileManager).analyze();
3739

3840
try (BufferedWriter writer =
3941
Files.newBufferedWriter(
40-
Paths.get(baseRepoPath + "/docs/instrumentation-list.yaml"),
41-
Charset.defaultCharset())) {
42+
Paths.get(baseRepoPath + "docs/instrumentation-list.yaml"), Charset.defaultCharset())) {
4243
writer.write("# This file is generated and should not be manually edited.\n");
4344
writer.write("# The structure and contents are a work in progress and subject to change.\n");
4445
writer.write(

instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/InstrumentationAnalyzer.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,7 @@ public static List<InstrumentationModule> convertToInstrumentationModules(
6363
}
6464

6565
private static String sanitizePathName(String rootPath, String path) {
66-
String result = path.replace(rootPath, "").replace("/javaagent", "").replace("/library", "");
67-
if (result.startsWith("/")) {
68-
result = result.substring(1);
69-
}
70-
return result;
66+
return path.replace(rootPath, "").replace("/javaagent", "").replace("/library", "");
7167
}
7268

7369
/**

instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/utils/FileManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public record FileManager(String rootDir) {
2121
private static final Logger logger = Logger.getLogger(FileManager.class.getName());
2222

2323
public List<InstrumentationPath> getInstrumentationPaths() throws IOException {
24-
Path rootPath = Paths.get(rootDir + "/instrumentation");
24+
Path rootPath = Paths.get(rootDir + "instrumentation");
2525

2626
try (Stream<Path> walk = Files.walk(rootPath)) {
2727
return walk.filter(Files::isDirectory)
@@ -77,7 +77,7 @@ public static boolean isValidInstrumentationPath(String filePath) {
7777
}
7878

7979
public List<String> findBuildGradleFiles(String instrumentationDirectory) {
80-
Path rootPath = Paths.get(rootDir + "/" + instrumentationDirectory);
80+
Path rootPath = Paths.get(rootDir + instrumentationDirectory);
8181

8282
try (Stream<Path> walk = Files.walk(rootPath)) {
8383
return walk.filter(Files::isRegularFile)
@@ -95,7 +95,7 @@ public List<String> findBuildGradleFiles(String instrumentationDirectory) {
9595

9696
@Nullable
9797
public String getMetaDataFile(String instrumentationDirectory) {
98-
String metadataFile = rootDir + "/" + instrumentationDirectory + "/metadata.yaml";
98+
String metadataFile = rootDir + instrumentationDirectory + "/metadata.yaml";
9999
if (Files.exists(Paths.get(metadataFile))) {
100100
return readFileToString(metadataFile);
101101
}

instrumentation-docs/src/test/java/io/opentelemetry/instrumentation/docs/utils/FileManagerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class FileManagerTest {
2424

2525
@BeforeEach
2626
void setUp() {
27-
fileManager = new FileManager(tempDir.toString());
27+
fileManager = new FileManager(tempDir.toString() + "/");
2828
}
2929

3030
@Test

0 commit comments

Comments
 (0)