Skip to content

Commit

Permalink
Returned breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hidanio committed Mar 22, 2024
1 parent 5d8e078 commit a8fb57d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/linter/block_linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -782,11 +782,11 @@ func checkNode(node ir.Node, b *blockLinter) {
switch n := node.(type) {
case *ir.ConstFetchExpr:
if strings.EqualFold(n.Constant.Value, "true") || strings.EqualFold(n.Constant.Value, "false") {
b.report(node, LevelWarning, "DangerousCondition", "Potential dangerous bool value: you have constant bool value in condition")
b.report(node, LevelWarning, "dangerousCondition", "Potential dangerous bool value: you have constant bool value in condition")
}
case *ir.Lnumber:
if n.Value == "0" || n.Value == "1" {
b.report(node, LevelWarning, "DangerousCondition", "Potential dangerous value: you have constant int value that interpreted as bool")
b.report(node, LevelWarning, "dangerousCondition", "Potential dangerous value: you have constant int value that interpreted as bool")
}
case *ir.BooleanOrExpr:
checkNode(n.Left, b)
Expand Down
2 changes: 1 addition & 1 deletion src/linter/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ function main(): void {
},

{
Name: "DangerousCondition",
Name: "dangerousCondition",
Default: true,
Quickfix: false,
Comment: "Report a dangerous condition",
Expand Down
29 changes: 27 additions & 2 deletions src/tests/golden/golden_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,33 @@ func TestGolden(t *testing.T) {
Deps: []string{
`stubs/phpstorm-stubs/mbstring/mbstring.php`,
},
Disable: []string{
"DangerousCondition",
},

{
Name: "parsedown",
Disable: []string{"missingPhpdoc", "arraySyntax"},
Deps: []string{
`stubs/phpstorm-stubs/pcre/pcre.php`,
`stubs/phpstorm-stubs/mbstring/mbstring.php`,
},
},

{
Name: "underscore",
Disable: []string{"missingPhpdoc"},
Deps: []string{
`stubs/phpstorm-stubs/pcre/pcre.php`,
},
},

{
Name: "phprocksyd",
Disable: []string{"missingPhpdoc", "dangerousCondition"},
Deps: []string{
`stubs/phpstorm-stubs/standard/basic.php`,
`stubs/phpstorm-stubs/pcntl/pcntl.php`,
`stubs/phpstorm-stubs/json/json.php`,
`stubs/phpstorm-stubs/posix/posix.php`,
},
},

Expand Down

0 comments on commit a8fb57d

Please sign in to comment.