Skip to content

Commit

Permalink
removed path casting logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Hidanio committed Dec 5, 2024
1 parent ed85e6b commit 0e43314
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
21 changes: 0 additions & 21 deletions src/linter/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -1627,27 +1627,6 @@ func (d *rootWalker) ReportLocation(loc ir.Location, level int, checkName, msg s

filePath := d.file.Name()

if d.config.ProjectPath != "" {
// Convert absolute path to relative to the project root

relativePath, err := filepath.Rel(d.config.ProjectPath, filePath)
if err != nil {
d.reports = append(d.reports, &Report{
CheckName: checkName,
Context: string(contextLine),
StartChar: loc.StartChar,
EndChar: loc.EndChar,
Line: loc.StartLine + 1,
Level: level,
Filename: strings.ReplaceAll(d.ctx.st.CurrentFile, "\\", "/"), // To make output stable between platforms, see #572
Message: fmt.Sprintf(msg, args...),
Hash: hash,
})
return
}
filePath = relativePath
}

rootNode := d.config.PathRules

if !IsRuleEnabledForPath(rootNode, filePath, checkName) {
Expand Down
4 changes: 2 additions & 2 deletions src/tests/infra/pathRulesSet_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestDisablePath(t *testing.T) {
code := `<?php
require_once 'foo.php';;
`
test.AddNamedFile("dev/disable-emptyStmt/foo.php", code)
test.AddNamedFile("disable-emptyStmt/foo.php", code)

test.RunAndMatch()
}
Expand Down Expand Up @@ -82,7 +82,7 @@ function f($cond) {
}
`

test.AddNamedFile("dev/mixed/foo.php", mergedCode)
test.AddNamedFile("mixed/foo.php", mergedCode)

test.Expect = []string{
"Semicolon (;) is not needed here, it can be safely removed at",
Expand Down

0 comments on commit 0e43314

Please sign in to comment.