Skip to content
Permalink
Browse files

Fix #1586 - allow use of --find-unused-code as alternative to --find-…

…dead-code
  • Loading branch information...
muglug committed Apr 30, 2019
1 parent 1c160da commit 2fe5a72ab7f115aafccb7c731a5a931643f81e9c
Showing with 14 additions and 2 deletions.
  1. +6 −0 src/Psalm/Internal/Analyzer/ProjectAnalyzer.php
  2. +8 −2 src/psalm.php
@@ -709,6 +709,12 @@ public function checkPaths(array $paths_to_check)
}
$this->codebase->analyzer->analyzeFiles($this, $this->threads, $this->codebase->alter_code);
if ($this->output_format === ProjectAnalyzer::TYPE_CONSOLE && $this->codebase->collect_references) {
echo PHP_EOL . 'To whom it may concern: Psalm cannot detect unused classes, methods and properties'
. PHP_EOL . 'when running analyzing individual files and folders. Run on the full project to'
. PHP_EOL . 'enable complete unused code detection.' . PHP_EOL;
}
}
/**
@@ -30,6 +30,7 @@
'diff-methods',
'disable-extension:',
'find-dead-code::',
'find-unused-code::',
'find-references-to:',
'help',
'ignore-baseline',
@@ -183,7 +184,8 @@ function ($arg) use ($valid_long_options, $valid_short_options) {
Changes the output format. Possible values: compact, console, emacs, json, pylint, xml
--find-dead-code[=auto]
Look for dead code. Options are 'auto' or 'always'. If no value is specified, default is 'auto'
--find-unused-code[=auto]
Look for unused code. Options are 'auto' or 'always'. If no value is specified, default is 'auto'
--find-references-to=[class|method|property]
Searches the codebase for references to the given fully-qualified class or method,
@@ -425,7 +427,11 @@ function ($arg) {
/** @var false|'always'|'auto' $find_unused_code */
$find_unused_code = false;
if (isset($options['find-dead-code'])) {
if ($options['find-dead-code'] === 'always') {
$options['find-unused-code'] = $options['find-dead-code'];
}
if (isset($options['find-unused-code'])) {
if ($options['find-unused-code'] === 'always') {
$find_unused_code = 'always';
} else {
$find_unused_code = 'auto';

0 comments on commit 2fe5a72

Please sign in to comment.
You can’t perform that action at this time.