mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Make diff map more verbose so it can serve as a list of safe zones
Outside them all issues must be removed
This commit is contained in:
parent
a2ee2f12a4
commit
370874d9b6
@ -411,7 +411,6 @@ class Analyzer
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->shiftFileOffsets($diff_map);
|
||||
|
||||
foreach ($this->files_to_analyze as $file_path) {
|
||||
@ -443,6 +442,7 @@ class Analyzer
|
||||
|
||||
foreach ($file_issues as $i => &$issue_data) {
|
||||
if ($issue_data['to'] < $first_diff_offset || $issue_data['from'] > $last_diff_offset) {
|
||||
unset($file_issues[$i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -454,6 +454,8 @@ class Analyzer
|
||||
$issue_data['snippet_to'] += $file_offset;
|
||||
$issue_data['line_from'] += $line_offset;
|
||||
$issue_data['line_to'] += $line_offset;
|
||||
} else {
|
||||
unset($file_issues[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,9 +86,7 @@ class ClassStatementsDiffer extends AstDiffer
|
||||
$start_diff = $b_start - $a_start;
|
||||
$line_diff = $b->getLine() - $a->getLine();
|
||||
|
||||
if ($start_diff !== 0 || $line_diff !== 0) {
|
||||
$diff_map[] = [$a_start, $a_end, $start_diff, $line_diff];
|
||||
}
|
||||
$diff_map[] = [$a_start, $a_end, $start_diff, $line_diff];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ class FileDiffTest extends TestCase
|
||||
['foo\a::$aB', 'foo\a::F', 'foo\a::foo', 'foo\a::bar'],
|
||||
[],
|
||||
[],
|
||||
[]
|
||||
[[0, 0], [0, 0], [0, 0], [0, 0]]
|
||||
],
|
||||
'sameFileWithDoubleDocblocks' => [
|
||||
'<?php
|
||||
@ -285,7 +285,7 @@ class FileDiffTest extends TestCase
|
||||
['foo\a::$aB', 'foo\a::F', 'foo\a::foo', 'foo\a::bar'],
|
||||
[],
|
||||
[],
|
||||
[]
|
||||
[[0, 0], [0, 0], [0, 0], [0, 0]]
|
||||
],
|
||||
'lineChanges' => [
|
||||
'<?php
|
||||
@ -411,7 +411,7 @@ class FileDiffTest extends TestCase
|
||||
['foo\a::foo'],
|
||||
[],
|
||||
['foo\a::bar', 'foo\a::bar'],
|
||||
[]
|
||||
[[0, 0]]
|
||||
],
|
||||
'propertyChange' => [
|
||||
'<?php
|
||||
@ -587,7 +587,7 @@ class FileDiffTest extends TestCase
|
||||
['foo\a::foo'],
|
||||
[],
|
||||
['foo\a::bar', 'foo\a::bar'],
|
||||
[]
|
||||
[[0, 0]]
|
||||
],
|
||||
'removeDocblock' => [
|
||||
'<?php
|
||||
@ -618,7 +618,7 @@ class FileDiffTest extends TestCase
|
||||
['foo\a::foo'],
|
||||
[],
|
||||
['foo\a::bar', 'foo\a::bar'],
|
||||
[]
|
||||
[[0, 0]]
|
||||
],
|
||||
'changeDocblock' => [
|
||||
'<?php
|
||||
@ -652,7 +652,7 @@ class FileDiffTest extends TestCase
|
||||
['foo\a::foo'],
|
||||
[],
|
||||
['foo\a::bar', 'foo\a::bar'],
|
||||
[]
|
||||
[[0, 0]]
|
||||
],
|
||||
'changeMethodVisibility' => [
|
||||
'<?php
|
||||
@ -680,7 +680,7 @@ class FileDiffTest extends TestCase
|
||||
['foo\a::foo'],
|
||||
[],
|
||||
['foo\a::bar', 'foo\a::bar'],
|
||||
[]
|
||||
[[0, 0]]
|
||||
],
|
||||
'removeFunctionAtEnd' => [
|
||||
'<?php
|
||||
@ -729,7 +729,7 @@ class FileDiffTest extends TestCase
|
||||
['foo\a::foo', 'foo\a::bar'],
|
||||
[],
|
||||
['foo\a::bat'],
|
||||
[]
|
||||
[[0, 0], [0, 0]]
|
||||
],
|
||||
'addSpaceInFunction' => [
|
||||
'<?php
|
||||
@ -803,7 +803,7 @@ class FileDiffTest extends TestCase
|
||||
['foo\a::foo', 'foo\a::bat'],
|
||||
['foo\a::bar'],
|
||||
[],
|
||||
[[4, 4]]
|
||||
[[0, 0], [4, 4]]
|
||||
],
|
||||
'removeSpaceInFunction' => [
|
||||
'<?php
|
||||
@ -877,7 +877,7 @@ class FileDiffTest extends TestCase
|
||||
['foo\a::foo', 'foo\a::bat'],
|
||||
['foo\a::bar'],
|
||||
[],
|
||||
[[-4, -4]]
|
||||
[[0, 0], [-4, -4]]
|
||||
],
|
||||
'removeFunctionAtBeginning' => [
|
||||
'<?php
|
||||
@ -939,7 +939,7 @@ class FileDiffTest extends TestCase
|
||||
['foo\a::foo', 'foo\a::bat'],
|
||||
[],
|
||||
['foo\a::bar'],
|
||||
[[-98, -3]],
|
||||
[[0, 0], [-98, -3]],
|
||||
],
|
||||
'changeNamespace' => [
|
||||
'<?php
|
||||
@ -1036,7 +1036,7 @@ class FileDiffTest extends TestCase
|
||||
['foo\a::foo', 'foo\a::bar'],
|
||||
[],
|
||||
['foo\a::bat'],
|
||||
[]
|
||||
[[0, 0], [0, 0]]
|
||||
],
|
||||
'newFunctionAtBeginning' => [
|
||||
'<?php
|
||||
@ -1134,7 +1134,7 @@ class FileDiffTest extends TestCase
|
||||
['foo\a::foo', 'foo\a::bar'],
|
||||
[],
|
||||
['foo\a::bat'],
|
||||
[[183, 7]]
|
||||
[[0, 0], [183, 7]]
|
||||
],
|
||||
'removeAdditionalComments' => [
|
||||
'<?php
|
||||
@ -1247,7 +1247,7 @@ class FileDiffTest extends TestCase
|
||||
['foo\a::__construct', 'foo\a::bar', 'foo\b::bat'],
|
||||
[],
|
||||
['foo\b::__construct', 'foo\b::bar'],
|
||||
[[120, 2]]
|
||||
[[0, 0], [0, 0], [120, 2]]
|
||||
],
|
||||
'sameTrait' => [
|
||||
'<?php
|
||||
@ -1283,7 +1283,7 @@ class FileDiffTest extends TestCase
|
||||
['foo\t::$aB', 'foo\t::F', 'foo\t::foo', 'foo\t::bar'],
|
||||
[],
|
||||
[],
|
||||
[]
|
||||
[[0, 0], [0, 0], [0, 0], [0, 0]]
|
||||
],
|
||||
'traitPropertyChange' => [
|
||||
'<?php
|
||||
@ -1416,7 +1416,7 @@ class FileDiffTest extends TestCase
|
||||
['bar\foo::a', 'bar\foo::c'],
|
||||
[],
|
||||
['bar\foo::b'],
|
||||
[[229, 8]]
|
||||
[[0, 0], [229, 8]]
|
||||
],
|
||||
'removeStatementsAbove' => [
|
||||
'<?php
|
||||
|
@ -975,6 +975,64 @@ class TemporaryUpdateTest extends \Psalm\Tests\TestCase
|
||||
],
|
||||
'error_positions' => [[], [238], [], [238], []],
|
||||
],
|
||||
'duplicateMethodThenRemove' => [
|
||||
[
|
||||
[
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
||||
class A {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public static function foo() {}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public static function bar(
|
||||
string $function_id
|
||||
) {}
|
||||
}',
|
||||
],
|
||||
[
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
||||
class A {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public static function foo() {}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public static function foo() {}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public static function bar(
|
||||
string $function_id
|
||||
) {}
|
||||
}',
|
||||
],
|
||||
[
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
||||
class A {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public static function foo() {}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public static function bar(
|
||||
string $function_id
|
||||
) {}
|
||||
}',
|
||||
],
|
||||
],
|
||||
'error_positions' => [[], [381], []],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user