Skip to content
Permalink
Browse files

Fix #701 - indicate issues fixable with Psalter

  • Loading branch information
muglug committed Dec 2, 2019
1 parent a7565bc commit 821f3528d2933567e83521999feaa0fe5955f374
@@ -299,7 +299,8 @@ public static function verifyReturnType(
'Closure does not have a return type, expecting ' . $inferred_return_type,
new CodeLocation($function_like_analyzer, $function, null, true)
),
$suppressed_issues
$suppressed_issues,
!$inferred_return_type->hasMixed() && !$inferred_return_type->isNull()
)) {
// fall through
}
@@ -338,7 +339,8 @@ public static function verifyReturnType(
(!$inferred_return_type->hasMixed() ? ', expecting ' . $inferred_return_type : ''),
new CodeLocation($function_like_analyzer, $function->name, null, true)
),
$suppressed_issues
$suppressed_issues,
!$inferred_return_type->hasMixed() && !$inferred_return_type->isNull()
)) {
// fall through
}
@@ -401,7 +403,8 @@ public static function verifyReturnType(
' but return type \'' . $declared_return_type . '\' was expected',
$return_type_location
),
$suppressed_issues
$suppressed_issues,
true
)) {
return false;
}
@@ -495,7 +498,8 @@ public static function verifyReturnType(
' is incorrect, got \'' . $inferred_return_type . '\'',
$return_type_location
),
$suppressed_issues
$suppressed_issues,
true
)) {
return false;
}
@@ -553,7 +557,8 @@ public static function verifyReturnType(
' is more specific than the declared return type \'' . $declared_return_type . '\'',
$return_type_location
),
$suppressed_issues
$suppressed_issues,
!($function_like_storage instanceof MethodStorage && $function_like_storage->inheritdoc)
)) {
return false;
}
@@ -591,7 +596,8 @@ public static function verifyReturnType(
' is not nullable, but \'' . $inferred_return_type . '\' contains null',
$return_type_location
),
$suppressed_issues
$suppressed_issues,
!$inferred_return_type->isNull()
)) {
return false;
}
@@ -627,7 +633,8 @@ public static function verifyReturnType(
' does not allow false, but \'' . $inferred_return_type . '\' contains false',
$return_type_location
),
$suppressed_issues
$suppressed_issues,
true
)) {
return false;
}
@@ -794,7 +801,8 @@ public static function checkReturnType(
'\', should be \'' . $storage->signature_return_type->getId() . '\'',
$storage->return_type_location
),
$storage->suppressed_issues
$storage->suppressed_issues,
true
)) {
return false;
}
@@ -1002,7 +1002,8 @@ private function processParams(
'\', should be \'' . $signature_type . '\'',
$function_param->type_location
),
$storage->suppressed_issues
$storage->suppressed_issues,
true
)) {
// do nothing
}
@@ -490,6 +490,8 @@ public function check($base_dir, $is_diff = false)
$this->config->initializePlugins($this);
$this->codebase->scanFiles($this->threads);
$this->codebase->infer_types_from_usage = true;
} else {
$this->progress->debug(count($diff_files) . ' changed files: ' . "\n");
$this->progress->debug(' ' . implode("\n ", $diff_files) . "\n");
@@ -540,15 +542,12 @@ public function check($base_dir, $is_diff = false)
/**
* @return void
*/
public function checkClassReferences()
public function consolidateAnalyzedData()
{
if (!$this->codebase->collect_references) {
throw new \UnexpectedValueException('Should not be checking references');
}
$this->codebase->classlikes->checkClassReferences(
$this->codebase->classlikes->consolidateAnalyzedData(
$this->codebase->methods,
$this->progress
$this->progress,
$this->codebase->collect_references
);
}
@@ -167,7 +167,9 @@ public static function analyze(
'The @var ' . $comment_type . ' annotation for '
. $var_comment->var_id . ' is unnecessary',
$type_location
)
),
[],
true
)) {
// fall through
}
@@ -190,7 +190,9 @@ public static function analyze(
'The @var ' . $var_comment_type . ' annotation for '
. $var_comment->var_id . ' is unnecessary',
$type_location
)
),
[],
true
)) {
// fall through
}
@@ -225,7 +225,8 @@ public static function analyze(
$first_appearance->getLineNumber(),
new CodeLocation($statements_analyzer->getSource(), $stmt)
),
$statements_analyzer->getSuppressedIssues()
$statements_analyzer->getSuppressedIssues(),
(bool) $statements_analyzer->getBranchPoint($var_name)
)) {
return false;
}
@@ -250,7 +251,8 @@ public static function analyze(
$first_appearance->getLineNumber(),
new CodeLocation($statements_analyzer->getSource(), $stmt)
),
$statements_analyzer->getSuppressedIssues()
$statements_analyzer->getSuppressedIssues(),
(bool) $statements_analyzer->getBranchPoint($var_name)
)) {
return false;
}
@@ -1629,7 +1629,9 @@ protected static function analyzeYield(
new UnnecessaryVarAnnotation(
'The @var annotation for ' . $var_comment->var_id . ' is unnecessary',
$type_location
)
),
[],
true
)) {
// fall through
}
@@ -1277,7 +1277,8 @@ public function checkUnreferencedVars(array $stmts)
if (IssueBuffer::accepts(
$issue,
$this->getSuppressedIssues()
$this->getSuppressedIssues(),
true
)) {
// fall through
}
@@ -46,6 +46,7 @@
*
* @psalm-type WorkerData = array{
* issues: array<int, IssueData>,
* fixable_issue_counts: array<string, int>,
* file_references_to_classes: array<string, array<string,bool>>,
* file_references_to_class_members: array<string, array<string,bool>>,
* file_references_to_missing_class_members: array<string, array<string,bool>>,
@@ -278,10 +279,8 @@ function (string $file_path) : bool {
$this->progress->finish();
if ($codebase->find_unused_code
&& ($project_analyzer->full_run || $codebase->find_unused_code === 'always')
) {
$project_analyzer->checkClassReferences();
if ($project_analyzer->full_run || $codebase->find_unused_code === 'always') {
$project_analyzer->consolidateAnalyzedData();
}
if ($codebase->track_unused_suppressions) {
@@ -427,6 +426,7 @@ function () use ($rerun) {
// @codingStandardsIgnoreStart
return [
'issues' => IssueBuffer::getIssuesData(),
'fixable_issue_counts' => IssueBuffer::getFixableIssues(),
'file_references_to_classes' => $rerun ? [] : $file_reference_provider->getAllFileReferencesToClasses(),
'file_references_to_class_members' => $rerun ? [] : $file_reference_provider->getAllFileReferencesToClassMembers(),
'method_references_to_class_members' => $rerun ? [] : $file_reference_provider->getAllMethodReferencesToClassMembers(),
@@ -463,6 +463,7 @@ function () use ($rerun) {
foreach ($forked_pool_data as $pool_data) {
IssueBuffer::addIssues($pool_data['issues']);
IssueBuffer::addFixableIssues($pool_data['fixable_issue_counts']);
if ($codebase->track_unused_suppressions) {
IssueBuffer::addUnusedSuppressions($pool_data['unused_suppressions']);

0 comments on commit 821f352

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