Skip to content

Commit

Permalink
Enable back Infection, fix new mutants
Browse files Browse the repository at this point in the history
  • Loading branch information
maks-rafalko committed Mar 24, 2024
1 parent f3832cd commit 0f708d3
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 12 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ jobs:
shell: bash
run: make tests

# - name: Run Infection for touched lines
# shell: bash
# if: github.event_name == 'pull_request'
# run: |
# git fetch origin $GITHUB_BASE_REF
# vendor/bin/infection --threads=max --only-covered --show-mutations --min-covered-msi=100 --git-diff-lines --git-diff-base=origin/$GITHUB_BASE_REF --ignore-msi-with-no-mutations
- name: Run Infection for touched lines
shell: bash
if: github.event_name == 'pull_request'
run: |
git fetch origin $GITHUB_BASE_REF
vendor/bin/infection --threads=max --only-covered --show-mutations --min-covered-msi=100 --git-diff-lines --git-diff-base=origin/$GITHUB_BASE_REF --ignore-msi-with-no-mutations
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.4",
"infection/infection": "^0.28.0",
"phpunit/phpunit": "^10.1"
},
"autoload": {
Expand Down
6 changes: 6 additions & 0 deletions infection.json5
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
"ignore": [
"Sid\\PHPStan\\Rules\\MagicNumber\\AbstractMagicNumberRule::isNumericString"
]
},
"FalseValue": {
"ignore": [
// because in current tests Rule is always created with $ignoreNumericStrings=false
"Sid\\PHPStan\\Rules\\MagicNumber\\AbstractMagicNumberRule::__construct"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ final class NoMagicNumberInArithmeticOperatorRule extends AbstractMagicNumberRul

public function getNodeType(): string
{
return Node\Expr\BinaryOp::class;
return BinaryOp::class;
}

/**
* @param Node\Expr\BinaryOp $node
* @param BinaryOp $node
*/
public function processNode(Node $node, Scope $scope): array
{
Expand Down
6 changes: 5 additions & 1 deletion tests/Rules/MagicNumber/NoMagicNumberInMatchCaseRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ public function test_rule(): void
],
[
NoMagicNumberInMatchRule::MATCH_ARM_COND_MESSAGE,
8,
9,
],
[
NoMagicNumberInMatchRule::MATCH_ARM_COND_MESSAGE,
9,
],
]
);
Expand Down
7 changes: 5 additions & 2 deletions tests/Rules/MagicNumber/NoMagicNumberInSwitchCaseRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ public function test_rule(): void
],
[
NoMagicNumberInSwitchCaseRule::ERROR_MESSAGE,
6,
8,
], [
NoMagicNumberInSwitchCaseRule::ERROR_MESSAGE,
10,
],
[
NoMagicNumberInSwitchCaseRule::ERROR_CONDITION_MESSAGE,
11,
15,
],
]
);
Expand Down
3 changes: 2 additions & 1 deletion tests/Rules/MagicNumber/data/match-case.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
match (3) {
1 => 'Hi',
2, 4 => 'There',
'1', 5 => 'magic number after string',
'string in the middle', '5' => 'There',
'1', 6 => 'magic number after string',
default => throw new LogicException(),
0 => 'Hello',
};
4 changes: 4 additions & 0 deletions tests/Rules/MagicNumber/data/switch-case.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
switch (100) {
case 5:
break;
case 'string in the middle':
break;
case 6:
break;
case '10':
break;
}
Expand Down

0 comments on commit 0f708d3

Please sign in to comment.