1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Merge pull request #9626 from ADmad/report-mixed-issues

Allow enabling mixed issues reporting for error levels > 2.
This commit is contained in:
orklah 2023-04-08 10:44:32 +02:00 committed by GitHub
commit 437fea965f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 73 additions and 1 deletions

View File

@ -1735,7 +1735,8 @@ class Config
public function reportIssueInFile(string $issue_type, string $file_path): bool
{
if (($this->show_mixed_issues === false || $this->level > 2)
if ((($this->level < 3 && $this->show_mixed_issues === false)
|| ($this->level > 2 && $this->show_mixed_issues !== true))
&& in_array($issue_type, self::MIXED_ISSUES, true)
) {
return false;

View File

@ -353,6 +353,77 @@ class ConfigTest extends TestCase
$this->assertFalse($config->reportIssueInFile('MissingReturnType', realpath('src/Psalm/Type.php')));
}
public function testReportMixedIssues(): void
{
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
Config::loadFromXML(
dirname(__DIR__, 2),
'<?xml version="1.0"?>
<psalm>
<projectFiles>
<directory name="src" />
<directory name="tests" />
</projectFiles>
</psalm>',
),
);
$config = $this->project_analyzer->getConfig();
$this->assertNull($config->show_mixed_issues);
$this->assertTrue($config->reportIssueInFile('MixedArgument', realpath(__FILE__)));
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
Config::loadFromXML(
dirname(__DIR__, 2),
'<?xml version="1.0"?>
<psalm reportMixedIssues="false">
<projectFiles>
<directory name="src" />
<directory name="tests" />
</projectFiles>
</psalm>',
),
);
$config = $this->project_analyzer->getConfig();
$this->assertFalse($config->show_mixed_issues);
$this->assertFalse($config->reportIssueInFile('MixedArgument', realpath(__FILE__)));
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
Config::loadFromXML(
dirname(__DIR__, 2),
'<?xml version="1.0"?>
<psalm errorLevel="5">
<projectFiles>
<directory name="src" />
<directory name="tests" />
</projectFiles>
</psalm>',
),
);
$config = $this->project_analyzer->getConfig();
$this->assertNull($config->show_mixed_issues);
$this->assertFalse($config->reportIssueInFile('MixedArgument', realpath(__FILE__)));
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
Config::loadFromXML(
dirname(__DIR__, 2),
'<?xml version="1.0"?>
<psalm errorLevel="5" reportMixedIssues="true">
<projectFiles>
<directory name="src" />
<directory name="tests" />
</projectFiles>
</psalm>',
),
);
$config = $this->project_analyzer->getConfig();
$this->assertTrue($config->show_mixed_issues);
$this->assertTrue($config->reportIssueInFile('MixedArgument', realpath(__FILE__)));
}
public function testGlobalUndefinedFunctionSuppression(): void
{
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(