Skip to content

Commit

Permalink
up-to-date report list
Browse files Browse the repository at this point in the history
  • Loading branch information
llaville committed Jun 2, 2024
1 parent fbf07db commit c4c674b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
16 changes: 1 addition & 15 deletions src/Psalm/Internal/Analyzer/ProjectAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,21 +329,7 @@ public static function getFileReportOptions(array $report_file_paths, bool $show
{
$report_options = [];

$mapping = [
'checkstyle.xml' => Report::TYPE_CHECKSTYLE,
'sonarqube.json' => Report::TYPE_SONARQUBE,
'codeclimate.json' => Report::TYPE_CODECLIMATE,
'summary.json' => Report::TYPE_JSON_SUMMARY,
'junit.xml' => Report::TYPE_JUNIT,
'.xml' => Report::TYPE_XML,
'.json' => Report::TYPE_JSON,
'.txt' => Report::TYPE_TEXT,
'.emacs' => Report::TYPE_EMACS,
'.pylint' => Report::TYPE_PYLINT,
'.console' => Report::TYPE_CONSOLE,
'.sarif' => Report::TYPE_SARIF,
'count.txt' => Report::TYPE_COUNT,
];
$mapping = Report::getMapping();

foreach ($report_file_paths as $report_file_path) {
foreach ($mapping as $extension => $type) {
Expand Down
8 changes: 6 additions & 2 deletions src/Psalm/Internal/Cli/Psalm.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

use function array_filter;
use function array_key_exists;
use function array_keys;
use function array_map;
use function array_merge;
use function array_slice;
Expand Down Expand Up @@ -1264,6 +1265,10 @@ private static function getHelpText(): string
sort($formats);
$outputFormats = wordwrap(implode(', ', $formats), 75, "\n ");

$reports = array_keys(Report::getMapping());
sort($reports);
$reportFormats = wordwrap('"' . implode('", "', $reports) . '"', 75, "\n ");

return <<<HELP
Usage:
psalm [options] [file...]
Expand Down Expand Up @@ -1362,8 +1367,7 @@ private static function getHelpText(): string
Reports:
--report=PATH
The path where to output report file. The output format is based on the file extension.
(Currently supported formats: ".json", ".xml", ".txt", ".emacs", ".pylint", ".console",
".sarif", "checkstyle.xml", "sonarqube.json", "codeclimate.json", "summary.json", "junit.xml")
(Currently supported formats: $reportFormats)
--report-show-info[=BOOLEAN]
Whether the report should include non-errors in its output (defaults to true)
Expand Down
20 changes: 20 additions & 0 deletions src/Psalm/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,24 @@ protected function xmlEncode(string $data): string
}

abstract public function create(): string;

public static function getMapping(): array
{
return [
'checkstyle.xml' => self::TYPE_CHECKSTYLE,
'sonarqube.json' => self::TYPE_SONARQUBE,
'codeclimate.json' => self::TYPE_CODECLIMATE,
'summary.json' => self::TYPE_JSON_SUMMARY,
'junit.xml' => self::TYPE_JUNIT,
'.xml' => self::TYPE_XML,
'.sarif.json' => self::TYPE_SARIF,
'.json' => self::TYPE_JSON,
'.txt' => self::TYPE_TEXT,
'.emacs' => self::TYPE_EMACS,
'.pylint' => self::TYPE_PYLINT,
'.console' => self::TYPE_CONSOLE,
'.sarif' => self::TYPE_SARIF,
'count.txt' => self::TYPE_COUNT,
];
}
}

0 comments on commit c4c674b

Please sign in to comment.