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:
commit
437fea965f
@ -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;
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user