Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Added severity field in gitlab error formatter, GitLab 13.x expects t…
…he field in code quality reports
  • Loading branch information
stockalexander committed Apr 23, 2021
commit b80c5127100bd49d3ceb7e9fa37e47e86349bd41
6 changes: 2 additions & 4 deletions src/Command/ErrorFormatter/GitlabErrorFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function formatErrors(AnalysisResult $analysisResult, Output $output): in
]
)
),
'severity' => $fileSpecificError->canBeIgnored() ? 'major' : 'blocker',
'location' => [
'path' => $this->relativePathHelper->getRelativePath($fileSpecificError->getFile()),
'lines' => [
Expand All @@ -45,17 +46,14 @@ public function formatErrors(AnalysisResult $analysisResult, Output $output): in
],
];

if (!$fileSpecificError->canBeIgnored()) {
$error['severity'] = 'blocker';
}

$errorsArray[] = $error;
}

foreach ($analysisResult->getNotFileSpecificErrors() as $notFileSpecificError) {
$errorsArray[] = [
'description' => $notFileSpecificError,
'fingerprint' => hash('sha256', $notFileSpecificError),
'severity' => 'major',
'location' => [
'path' => '',
'lines' => [
Expand Down
14 changes: 14 additions & 0 deletions tests/PHPStan/Command/ErrorFormatter/GitlabFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function dataFormatterOutputProvider(): iterable
{
"description": "Foo",
"fingerprint": "e82b7e1f1d4255352b19ecefa9116a12f129c7edb4351cf2319285eccdb1565e",
"severity": "major",
"location": {
"path": "with space/and unicode 😃/project/folder with unicode 😃/file name with \"spaces\" and unicode 😃.php",
"lines": {
Expand All @@ -46,6 +47,7 @@ public function dataFormatterOutputProvider(): iterable
{
"description": "first generic error",
"fingerprint": "53ed216d77c9a9b21d9535322457ca7d7b037d6596d76484b3481f161adfd96f",
"severity": "major",
"location": {
"path": "",
"lines": {
Expand All @@ -65,6 +67,7 @@ public function dataFormatterOutputProvider(): iterable
{
"description": "Bar\nBar2",
"fingerprint": "034b4afbfb347494c14e396ed8327692f58be4cd27e8aff5f19f4194934db7c9",
"severity": "major",
"location": {
"path": "with space/and unicode 😃/project/folder with unicode 😃/file name with \"spaces\" and unicode 😃.php",
"lines": {
Expand All @@ -75,6 +78,7 @@ public function dataFormatterOutputProvider(): iterable
{
"description": "Foo",
"fingerprint": "e82b7e1f1d4255352b19ecefa9116a12f129c7edb4351cf2319285eccdb1565e",
"severity": "major",
"location": {
"path": "with space/and unicode 😃/project/folder with unicode 😃/file name with \"spaces\" and unicode 😃.php",
"lines": {
Expand All @@ -85,6 +89,7 @@ public function dataFormatterOutputProvider(): iterable
{
"description": "Foo",
"fingerprint": "93c79740ed8c6fbaac2087e54d6f6f67fc0918e3ff77840530f32e19857ef63c",
"severity": "major",
"location": {
"path": "with space/and unicode \ud83d\ude03/project/foo.php",
"lines": {
Expand All @@ -95,6 +100,7 @@ public function dataFormatterOutputProvider(): iterable
{
"description": "Bar\nBar2",
"fingerprint": "829f6c782152fdac840b39208c5b519d18e51bff2c601b6197812fffb8bcd9ed",
"severity": "major",
"location": {
"path": "with space/and unicode \ud83d\ude03/project/foo.php",
"lines": {
Expand All @@ -114,6 +120,7 @@ public function dataFormatterOutputProvider(): iterable
{
"description": "first generic error",
"fingerprint": "53ed216d77c9a9b21d9535322457ca7d7b037d6596d76484b3481f161adfd96f",
"severity": "major",
"location": {
"path": "",
"lines": {
Expand All @@ -124,6 +131,7 @@ public function dataFormatterOutputProvider(): iterable
{
"description": "second generic error",
"fingerprint": "f49870714e8ce889212aefb50f718f88ae63d00dd01c775b7bac86c4466e96f0",
"severity": "major",
"location": {
"path": "",
"lines": {
Expand All @@ -143,6 +151,7 @@ public function dataFormatterOutputProvider(): iterable
{
"description": "Bar\nBar2",
"fingerprint": "034b4afbfb347494c14e396ed8327692f58be4cd27e8aff5f19f4194934db7c9",
"severity": "major",
"location": {
"path": "with space/and unicode \ud83d\ude03/project/folder with unicode \ud83d\ude03/file name with \"spaces\" and unicode \ud83d\ude03.php",
"lines": {
Expand All @@ -153,6 +162,7 @@ public function dataFormatterOutputProvider(): iterable
{
"description": "Foo",
"fingerprint": "e82b7e1f1d4255352b19ecefa9116a12f129c7edb4351cf2319285eccdb1565e",
"severity": "major",
"location": {
"path": "with space/and unicode \ud83d\ude03/project/folder with unicode \ud83d\ude03/file name with \"spaces\" and unicode \ud83d\ude03.php",
"lines": {
Expand All @@ -163,6 +173,7 @@ public function dataFormatterOutputProvider(): iterable
{
"description": "Foo",
"fingerprint": "93c79740ed8c6fbaac2087e54d6f6f67fc0918e3ff77840530f32e19857ef63c",
"severity": "major",
"location": {
"path": "with space/and unicode \ud83d\ude03/project/foo.php",
"lines": {
Expand All @@ -173,6 +184,7 @@ public function dataFormatterOutputProvider(): iterable
{
"description": "Bar\nBar2",
"fingerprint": "829f6c782152fdac840b39208c5b519d18e51bff2c601b6197812fffb8bcd9ed",
"severity": "major",
"location": {
"path": "with space/and unicode \ud83d\ude03/project/foo.php",
"lines": {
Expand All @@ -183,6 +195,7 @@ public function dataFormatterOutputProvider(): iterable
{
"description": "first generic error",
"fingerprint": "53ed216d77c9a9b21d9535322457ca7d7b037d6596d76484b3481f161adfd96f",
"severity": "major",
"location": {
"path": "",
"lines": {
Expand All @@ -193,6 +206,7 @@ public function dataFormatterOutputProvider(): iterable
{
"description": "second generic error",
"fingerprint": "f49870714e8ce889212aefb50f718f88ae63d00dd01c775b7bac86c4466e96f0",
"severity": "major",
"location": {
"path": "",
"lines": {
Expand Down