From 6ea68e9f7f021f73e291dd4b34a04ac235c32f55 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Sun, 18 Aug 2019 16:59:56 -0400 Subject: [PATCH] Clean up more unused @psalm-suppress annotations --- src/Psalm/Config/FileFilter.php | 11 +---------- src/Psalm/Internal/Codebase/Analyzer.php | 4 ---- .../Internal/Diff/NamespaceStatementsDiffer.php | 1 - src/Psalm/Internal/Fork/PsalmRestarter.php | 4 ---- .../Internal/LanguageServer/EmitterTrait.php | 1 - .../PluginManager/Command/ShowCommand.php | 2 -- .../Internal/Visitor/SimpleNameResolver.php | 1 - tests/PsalmPluginTest.php | 1 - tests/TestCase.php | 4 +--- tests/UnusedCodeTest.php | 17 ++++++++++++++++- 10 files changed, 18 insertions(+), 28 deletions(-) diff --git a/src/Psalm/Config/FileFilter.php b/src/Psalm/Config/FileFilter.php index 10b1ca07f..2580f98ee 100644 --- a/src/Psalm/Config/FileFilter.php +++ b/src/Psalm/Config/FileFilter.php @@ -75,17 +75,8 @@ class FileFilter */ protected $declare_strict_types = []; - /** - * @param bool $inclusive - * - * @psalm-suppress DocblockTypeContradiction - */ - public function __construct($inclusive) + public function __construct(bool $inclusive) { - if (!is_bool($inclusive)) { - throw new \InvalidArgumentException('Filter arg must be bool'); - } - $this->inclusive = $inclusive; } diff --git a/src/Psalm/Internal/Codebase/Analyzer.php b/src/Psalm/Internal/Codebase/Analyzer.php index 30b7493d1..32dd91519 100644 --- a/src/Psalm/Internal/Codebase/Analyzer.php +++ b/src/Psalm/Internal/Codebase/Analyzer.php @@ -539,10 +539,6 @@ class Analyzer $codebase->file_reference_provider->addIssue($issue_data['file_path'], $issue_data); } } - - if ($codebase->track_unused_suppressions) { - IssueBuffer::processUnusedSuppressions($codebase->file_provider); - } } /** diff --git a/src/Psalm/Internal/Diff/NamespaceStatementsDiffer.php b/src/Psalm/Internal/Diff/NamespaceStatementsDiffer.php index 0133e4d13..ae0e2b469 100644 --- a/src/Psalm/Internal/Diff/NamespaceStatementsDiffer.php +++ b/src/Psalm/Internal/Diff/NamespaceStatementsDiffer.php @@ -34,7 +34,6 @@ class NamespaceStatementsDiffer extends AstDiffer /** * @param string $a_code * @param string $b_code - * @psalm-suppress UnusedParam * * @return bool */ diff --git a/src/Psalm/Internal/Fork/PsalmRestarter.php b/src/Psalm/Internal/Fork/PsalmRestarter.php index a337f3202..a1d669f1f 100644 --- a/src/Psalm/Internal/Fork/PsalmRestarter.php +++ b/src/Psalm/Internal/Fork/PsalmRestarter.php @@ -34,8 +34,6 @@ class PsalmRestarter extends \Composer\XdebugHandler\XdebugHandler } /** - * @psalm-suppress UnusedMethod - * * @param mixed $loaded */ protected function requiresRestart($loaded) @@ -56,8 +54,6 @@ class PsalmRestarter extends \Composer\XdebugHandler\XdebugHandler } /** - * @psalm-suppress UnusedMethod - * * @param mixed $command * * @return void diff --git a/src/Psalm/Internal/LanguageServer/EmitterTrait.php b/src/Psalm/Internal/LanguageServer/EmitterTrait.php index 541aec403..d586ac4d5 100644 --- a/src/Psalm/Internal/LanguageServer/EmitterTrait.php +++ b/src/Psalm/Internal/LanguageServer/EmitterTrait.php @@ -122,7 +122,6 @@ trait EmitterTrait // The list is not sorted if (!$this->listeners[$eventName][0]) { // Sorting - /** @psalm-suppress MixedArgument */ \array_multisort($this->listeners[$eventName][1], SORT_NUMERIC, $this->listeners[$eventName][2]); // Marking the listeners as sorted diff --git a/src/Psalm/Internal/PluginManager/Command/ShowCommand.php b/src/Psalm/Internal/PluginManager/Command/ShowCommand.php index f0399d3eb..bf967cf6e 100644 --- a/src/Psalm/Internal/PluginManager/Command/ShowCommand.php +++ b/src/Psalm/Internal/PluginManager/Command/ShowCommand.php @@ -30,7 +30,6 @@ class ShowCommand extends Command /** * @return void - * @psalm-suppress UnusedMethod */ protected function configure() { @@ -42,7 +41,6 @@ class ShowCommand extends Command /** * @return null|int - * @psalm-suppress UnusedMethod */ protected function execute(InputInterface $i, OutputInterface $o) { diff --git a/src/Psalm/Internal/Visitor/SimpleNameResolver.php b/src/Psalm/Internal/Visitor/SimpleNameResolver.php index 0c3ce253a..ad117022a 100644 --- a/src/Psalm/Internal/Visitor/SimpleNameResolver.php +++ b/src/Psalm/Internal/Visitor/SimpleNameResolver.php @@ -175,7 +175,6 @@ class SimpleNameResolver extends NodeVisitorAbstract * @param PhpParser\Node|string|null $node * * @return null|PhpParser\Node\Identifier|PhpParser\Node\Name|PhpParser\Node\NullableType - * @psalm-suppress MoreSpecificReturnType * @psalm-suppress InvalidReturnType * @psalm-suppress InvalidReturnStatement */ diff --git a/tests/PsalmPluginTest.php b/tests/PsalmPluginTest.php index 644e5d80d..25cc779d8 100644 --- a/tests/PsalmPluginTest.php +++ b/tests/PsalmPluginTest.php @@ -142,7 +142,6 @@ class PsalmPluginTest extends TestCase * @return void * @dataProvider commands * @test - * @psalm-suppress RedundantConditionGivenDocblockType */ public function showsHelpForCommand(string $command) { diff --git a/tests/TestCase.php b/tests/TestCase.php index ecb92c1c4..cae8d44db 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -105,9 +105,7 @@ class TestCase extends BaseTestCase $this->project_analyzer->interpretRefactors(); } - if ($track_unused_suppressions) { - $this->project_analyzer->trackUnusedSuppressions(); - } + $this->project_analyzer->trackUnusedSuppressions(); $file_analyzer = new FileAnalyzer( $this->project_analyzer, diff --git a/tests/UnusedCodeTest.php b/tests/UnusedCodeTest.php index 0b7531aed..779f426ed 100644 --- a/tests/UnusedCodeTest.php +++ b/tests/UnusedCodeTest.php @@ -64,6 +64,8 @@ class UnusedCodeTest extends TestCase $this->analyzeFile($file_path, $context, false); $this->project_analyzer->checkClassReferences(); + + \Psalm\IssueBuffer::processUnusedSuppressions($this->project_analyzer->getCodebase()->file_provider); } /** @@ -98,9 +100,11 @@ class UnusedCodeTest extends TestCase $context = new Context(); $context->collect_references = true; - $this->analyzeFile($file_path, $context); + $this->analyzeFile($file_path, $context, false); $this->project_analyzer->checkClassReferences(); + + \Psalm\IssueBuffer::processUnusedSuppressions($this->project_analyzer->getCodebase()->file_provider); } /** @@ -499,6 +503,17 @@ class UnusedCodeTest extends TestCase return $foo; }', ], + 'suppressUnusedMethod' => [ + '