|
1 | 1 | package org.utbot.sarif |
2 | 2 |
|
| 3 | +import mu.KotlinLogging |
3 | 4 | import org.utbot.common.PathUtil.fileExtension |
4 | 5 | import org.utbot.common.PathUtil.toPath |
5 | 6 | import org.utbot.framework.UtSettings |
6 | 7 | import org.utbot.framework.plugin.api.* |
7 | 8 | import java.nio.file.Path |
8 | 9 | import kotlin.io.path.nameWithoutExtension |
9 | 10 |
|
| 11 | +internal val logger = KotlinLogging.logger {} |
| 12 | + |
10 | 13 | /** |
11 | 14 | * Used for the SARIF report creation by given test cases and generated tests code. |
12 | 15 | * SARIF is a JSON-based format for presenting static analyzer results. |
@@ -328,7 +331,7 @@ class SarifReport( |
328 | 331 | message = Message("$classFqn.$methodName($sourceFileName:$lineNumber)"), |
329 | 332 | physicalLocation = SarifPhysicalLocation( |
330 | 333 | SarifArtifact(uri = sourceFilePath), |
331 | | - SarifRegion(startLine = lineNumber) |
| 334 | + SarifRegion(startLine = lineNumber) // lineNumber is one-based |
332 | 335 | ) |
333 | 336 | )) |
334 | 337 | } |
@@ -440,15 +443,15 @@ class SarifReport( |
440 | 443 | val lastCoveredInstruction = coveredInstructions?.lastOrNull() |
441 | 444 | if (lastCoveredInstruction != null) |
442 | 445 | return Pair( |
443 | | - lastCoveredInstruction.lineNumber, |
| 446 | + lastCoveredInstruction.lineNumber, // .lineNumber is one-based |
444 | 447 | lastCoveredInstruction.className.replace('/', '.') |
445 | 448 | ) |
446 | 449 |
|
447 | 450 | // if for some reason we can't extract the last line from the coverage |
448 | 451 | val lastPathElementLineNumber = try { |
449 | 452 | // path/fullPath might be empty when engine executes in another process - |
450 | 453 | // soot entities cannot be passed to the main process because kryo cannot deserialize them |
451 | | - (utExecution as? UtSymbolicExecution)?.path?.lastOrNull()?.stmt?.javaSourceStartLineNumber |
| 454 | + (utExecution as? UtSymbolicExecution)?.path?.lastOrNull()?.stmt?.javaSourceStartLineNumber // one-based |
452 | 455 | } catch (t: Throwable) { |
453 | 456 | null |
454 | 457 | } |
|
0 commit comments