Skip to content

Commit

Permalink
Config reportInfo to speed up analysis for big projects (#4095)
Browse files Browse the repository at this point in the history
  • Loading branch information
orklah authored and muglug committed Sep 1, 2020
1 parent 66bbfea commit 2160396
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions config.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<xs:attribute name="usePhpStormMetaPath" type="xs:boolean" default="true" />
<xs:attribute name="allowInternalNamedArgumentCalls" type="xs:boolean" default="true" />
<xs:attribute name="allowNamedArgumentCalls" type="xs:boolean" default="true" />
<xs:attribute name="reportInfo" type="xs:boolean" default="true" />
</xs:complexType>

<xs:complexType name="ProjectFilesType">
Expand Down
10 changes: 10 additions & 0 deletions docs/running_psalm/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,16 @@ When `true`, Psalm will treat all classes as if they had sealed methods, meaning

When `true`, Psalm will run [Taint Analysis](../security_analysis/index.md) on your codebase. This config is the same as if you were running Psalm with `--taint-analysis`.

#### reportInfo

```xml
<psalm
reportInfo="[bool]"
>
```

When `false`, Psalm will not consider issue at lower level than `errorLevel` as `info` (they will be suppressed instead). This can be a big improvement in analysis time for big projects. However, this config will prevent Psalm to count or suggest fixes for suppressed issue

### Running Psalm

#### autoloader
Expand Down
8 changes: 7 additions & 1 deletion src/Psalm/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,11 @@ class Config
*/
public $debug_emitted_issues = false;

/**
* @var bool
*/
private $report_info = true;

protected function __construct()
{
self::$instance = $this;
Expand Down Expand Up @@ -844,6 +849,7 @@ private static function fromXmlAndPaths(string $base_dir, string $file_contents,
'allowInternalNamedArgumentsCalls' => 'allow_internal_named_arg_calls',
'allowNamedArgumentCalls' => 'allow_named_arg_calls',
'findUnusedPsalmSuppress' => 'find_unused_psalm_suppress',
'reportInfo' => 'report_info',
];

foreach ($booleanAttributes as $xmlName => $internalName) {
Expand Down Expand Up @@ -1604,7 +1610,7 @@ public function getReportingLevelForFile($issue_type, $file_path)
$issue_level = $issue_class::ERROR_LEVEL;

if ($issue_level > 0 && $issue_level < $this->level) {
return self::REPORT_INFO;
return $this->report_info ? self::REPORT_INFO : self::REPORT_SUPPRESS;
}

return self::REPORT_ERROR;
Expand Down

0 comments on commit 2160396

Please sign in to comment.