@@ -58,21 +58,22 @@ private fun registerLogEnvVarUsages(target: Project, extension: SupportedTracerC
5858 val repoRoot = target.projectDir.toPath()
5959 val tokenRegex = Regex (" \" (?:DD_|OTEL_)[A-Za-z0-9_]+\" " )
6060
61- val violations = mutableListOf<String >()
62- javaFiles.files.forEach { f ->
63- val rel = repoRoot.relativize(f.toPath()).toString()
64- var inBlock = false
65- f.readLines().forEachIndexed { i, raw ->
66- val trimmed = raw.trim()
67- if (trimmed.startsWith(" //" )) return @forEachIndexed
68- if (! inBlock && trimmed.contains(" /*" )) inBlock = true
69- if (inBlock) {
70- if (trimmed.contains(" */" )) inBlock = false
71- return @forEachIndexed
72- }
73- tokenRegex.findAll(raw).forEach { m ->
74- val token = m.value.trim(' "' )
75- if (token !in supported) violations + = " $rel :${i + 1 } -> Unsupported token '$token '"
61+ val violations = buildList {
62+ javaFiles.files.forEach { f ->
63+ val rel = repoRoot.relativize(f.toPath()).toString()
64+ var inBlock = false
65+ f.readLines().forEachIndexed { i, raw ->
66+ val trimmed = raw.trim()
67+ if (trimmed.startsWith(" //" )) return @forEachIndexed
68+ if (! inBlock && trimmed.contains(" /*" )) inBlock = true
69+ if (inBlock) {
70+ if (trimmed.contains(" */" )) inBlock = false
71+ return @forEachIndexed
72+ }
73+ tokenRegex.findAll(raw).forEach { m ->
74+ val token = m.value.trim(' "' )
75+ if (token !in supported) add(" $rel :${i + 1 } -> Unsupported token'$token '" )
76+ }
7677 }
7778 }
7879 }
@@ -104,13 +105,13 @@ private fun registerCheckEnvironmentVariablesUsage(project: Project) {
104105 }
105106
106107 val pattern = Regex (""" EnvironmentVariables\.get\s*\(""" )
107- val matches = mutableListOf< String >()
108-
109- javaFiles.forEach { f ->
110- val relative = repoRoot.relativize(f.toPath())
111- f.readLines().forEachIndexed { idx, line ->
112- if (pattern.containsMatchIn(line)) {
113- matches + = " $relative : ${idx + 1 } -> ${line.trim()} "
108+ val matches = buildList {
109+ javaFiles.forEach { f ->
110+ val relative = repoRoot.relativize(f.toPath())
111+ f.readLines().forEachIndexed { idx, line ->
112+ if (pattern.containsMatchIn( line)) {
113+ add( " $relative : ${idx + 1 } -> ${line.trim()} " )
114+ }
114115 }
115116 }
116117 }
0 commit comments