aboutsummaryrefslogtreecommitdiff
path: root/.gitlab
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2023-04-03 10:26:41 +0000
committerJan-Hendrik Willms <tleilax+studip@gmail.com>2023-04-03 10:26:41 +0000
commit89d3ea61712b700c06923301a59e5810f95faf89 (patch)
tree61fd5e82c27c732c0aaade38522700eb9365b253 /.gitlab
parent7fedee30bfa8cfa41809d53a7be7c69d0e82b4b3 (diff)
report linting errors as code quality issues, fixes #2500
Closes #2500 Merge request studip/studip!1691
Diffstat (limited to '.gitlab')
-rwxr-xr-x.gitlab/scripts/convert-phplint-report43
1 files changed, 43 insertions, 0 deletions
diff --git a/.gitlab/scripts/convert-phplint-report b/.gitlab/scripts/convert-phplint-report
new file mode 100755
index 0000000..b306b26
--- /dev/null
+++ b/.gitlab/scripts/convert-phplint-report
@@ -0,0 +1,43 @@
+#!/usr/bin/env php
+<?php
+function error(string $error, int $status = 1): void
+{
+ echo trim($error) . "\n";
+ exit($status);
+}
+
+$self = basename($argv[0]);
+
+if ($argc !== 2) {
+ error("Missing report file, use {$self} <filename>");
+}
+
+$report_file = $argv[1];
+if (!file_exists($report_file)) {
+ error("Report file {$report_file} does not exist");
+}
+if (!is_readable($report_file)) {
+ error("Report file {$report_file} is not readable");
+}
+
+$json = json_decode(file_get_contents($report_file), true);
+if ($json === false) {
+ error("Could not read json contents of {$report_file}");
+}
+
+$errors = [];
+foreach ($json['errors'] as $error) {
+ $errors[] = [
+ 'description' => $error['error'],
+ 'fingerprint' => md5("{$error['file_name']}:{$error['line']}"),
+ 'severity' => 'major',
+ 'location' => [
+ 'path' => $error['file_name'],
+ 'lines' => [
+ 'begin' => $error['line'],
+ ],
+ ],
+ ];
+}
+
+echo json_encode($errors);