Skip to content

Commit

Permalink
Add a warning when fixing unused code issues without accompanying det…
Browse files Browse the repository at this point in the history
…ection
  • Loading branch information
muglug committed Apr 30, 2019
1 parent d53ba0b commit 5674193
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/psalter.php
Expand Up @@ -325,6 +325,17 @@ function (string $line) : bool {


if ($find_unused_code) { if ($find_unused_code) {
$project_analyzer->getCodebase()->reportUnusedCode(); $project_analyzer->getCodebase()->reportUnusedCode();
} else {
foreach ($keyed_issues as $issue_name => $_) {
if (strpos($issue_name, 'Unused') !== false) {
die(
'Error: Psalm can only fix issue '
. $issue_name
. ' if you enable unused code detection with --find-unused-code'
. PHP_EOL
);
}
}
} }


$project_analyzer->alterCodeAfterCompletion( $project_analyzer->alterCodeAfterCompletion(
Expand Down

0 comments on commit 5674193

Please sign in to comment.