|
8 | 8 | use App\Utils\TestingDay; |
9 | 9 | use CDash\Database; |
10 | 10 | use CDash\Model\Build; |
11 | | -use CDash\Model\CoverageFile; |
12 | | -use CDash\Model\CoverageFileLog; |
13 | 11 | use CDash\Model\Project; |
14 | | -use Exception; |
15 | 12 | use Illuminate\Http\JsonResponse; |
16 | 13 | use Illuminate\Http\RedirectResponse; |
17 | 14 | use Illuminate\Support\Facades\Auth; |
@@ -455,98 +452,6 @@ public function viewCoverage(): View|RedirectResponse |
455 | 452 | ->with('xsl_content', generate_XSLT($xml, 'viewCoverage', true)); |
456 | 453 | } |
457 | 454 |
|
458 | | - public function viewCoverageFile(): View |
459 | | - { |
460 | | - $this->setBuildById(intval($_GET['buildid'] ?? 0)); |
461 | | - |
462 | | - $fileid = intval($_GET['fileid'] ?? 0); |
463 | | - |
464 | | - $db = Database::getInstance(); |
465 | | - |
466 | | - $role = 0; |
467 | | - $user2project = $db->executePreparedSingleRow(' |
468 | | - SELECT role |
469 | | - FROM user2project |
470 | | - WHERE |
471 | | - userid=? |
472 | | - AND projectid=? |
473 | | - ', [intval(Auth::id() ?? 0), $this->project->Id]); |
474 | | - if (!empty($user2project)) { |
475 | | - $role = $user2project['role']; |
476 | | - } |
477 | | - if (!$this->project->ShowCoverageCode && $role < 2) { |
478 | | - abort(403, "This project doesn't allow display of coverage code. Contact the administrator of the project."); |
479 | | - } |
480 | | - |
481 | | - // Load coverage file. |
482 | | - $coverageFile = new CoverageFile(); |
483 | | - $coverageFile->Id = $fileid; |
484 | | - $coverageFile->Load(); |
485 | | - |
486 | | - // Split on all forms of line breaks |
487 | | - $file_array = preg_split('/\R/', rtrim($coverageFile->File)); |
488 | | - if ($file_array === false) { |
489 | | - throw new Exception('Error parsing coverage file.'); |
490 | | - } |
491 | | - $i = 0; |
492 | | - |
493 | | - // Load the coverage info. |
494 | | - $log = new CoverageFileLog(); |
495 | | - $log->BuildId = $this->build->Id; |
496 | | - $log->FileId = $fileid; |
497 | | - $log->Load(); |
498 | | - |
499 | | - // Detect if we have branch coverage or not. |
500 | | - $hasBranchCoverage = false; |
501 | | - if (!empty($log->Branches)) { |
502 | | - $hasBranchCoverage = true; |
503 | | - } |
504 | | - |
505 | | - foreach ($file_array as $line) { |
506 | | - $linenumber = $i + 1; |
507 | | - $line = htmlentities($line); |
508 | | - |
509 | | - $file_array[$i] = '<span class="warning">' . str_pad(strval($linenumber), 5, ' ', STR_PAD_LEFT) . '</span>'; |
510 | | - |
511 | | - if ($hasBranchCoverage) { |
512 | | - if (array_key_exists("$i", $log->Branches)) { |
513 | | - $code = $log->Branches["$i"]; |
514 | | - |
515 | | - // Branch coverage data is stored as <# covered> / <total branches>. |
516 | | - $branchCoverageData = explode('/', $code); |
517 | | - if ($branchCoverageData[0] != $branchCoverageData[1]) { |
518 | | - $file_array[$i] .= '<span class="error">'; |
519 | | - } else { |
520 | | - $file_array[$i] .= '<span class="normal">'; |
521 | | - } |
522 | | - $file_array[$i] .= str_pad($code, 5, ' ', STR_PAD_LEFT) . '</span>'; |
523 | | - } else { |
524 | | - $file_array[$i] .= str_pad('', 5, ' ', STR_PAD_LEFT); |
525 | | - } |
526 | | - } |
527 | | - |
528 | | - if (array_key_exists($i, $log->Lines)) { |
529 | | - $code = $log->Lines[$i]; |
530 | | - if ($code == 0) { |
531 | | - $file_array[$i] .= '<span class="error">'; |
532 | | - } else { |
533 | | - $file_array[$i] .= '<span class="normal">'; |
534 | | - } |
535 | | - $file_array[$i] .= str_pad($code, 5, ' ', STR_PAD_LEFT) . ' | ' . $line; |
536 | | - $file_array[$i] .= '</span>'; |
537 | | - } else { |
538 | | - $file_array[$i] .= str_pad('', 5, ' ', STR_PAD_LEFT) . ' | ' . $line; |
539 | | - } |
540 | | - $i++; |
541 | | - } |
542 | | - |
543 | | - $file = implode('<br>', $file_array); |
544 | | - |
545 | | - return $this->view('coverage.coverage-file', 'Coverage') |
546 | | - ->with('coverage_file', $coverageFile) |
547 | | - ->with('log', $file); |
548 | | - } |
549 | | - |
550 | 455 | public function ajaxGetViewCoverage(): JsonResponse |
551 | 456 | { |
552 | 457 | @set_time_limit(0); |
@@ -663,7 +568,7 @@ public function ajaxGetViewCoverage(): JsonResponse |
663 | 568 | $coveragefile = $db->executePrepared(" |
664 | 569 | SELECT |
665 | 570 | cf.fullpath, |
666 | | - c.fileid, |
| 571 | + c.id AS fileid, |
667 | 572 | c.locuntested, |
668 | 573 | c.loctested, |
669 | 574 | c.branchestested, |
@@ -914,7 +819,7 @@ public function ajaxGetViewCoverage(): JsonResponse |
914 | 819 | } elseif (!$covfile['covered'] || !($this->project->ShowCoverageCode || $role >= EloquentProject::PROJECT_ADMIN)) { |
915 | 820 | $row[] = $covfile['fullpath']; |
916 | 821 | } else { |
917 | | - $row[] = '<a class="cdash-link" href="viewCoverageFile.php?buildid=' . $this->build->Id . '&fileid=' . $covfile['fileid'] . '">' . $covfile['fullpath'] . '</a>'; |
| 822 | + $row[] = '<a class="cdash-link" href="' . url('/builds/' . $this->build->Id . '/coverage/' . $covfile['fileid']) . '">' . $covfile['fullpath'] . '</a>'; |
918 | 823 | } |
919 | 824 |
|
920 | 825 | // Second column (Status) |
|
0 commit comments