The Wayback Machine - https://web.archive.org/web/20201117220417/https://github.com/phpmd/phpmd/issues/841
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling of filepath Windows/Linux in exclude-pattern #841

Open
04cfb1ed opened this issue Oct 30, 2020 · 1 comment
Open

Handling of filepath Windows/Linux in exclude-pattern #841

04cfb1ed opened this issue Oct 30, 2020 · 1 comment

Comments

@04cfb1ed
Copy link

@04cfb1ed 04cfb1ed commented Oct 30, 2020

  • PHPMD version: 2.9.1
  • PHP Version: 7.4.10
  • Installation type: composer
  • Operating System / Distribution & Version: Windows 10 / Linux

Current Behavior

I'm trying to use exclude-pattern in a ruleset, but the same path doesn't work in windows/linux at the same time.

Usually I use a path like
<exclude-pattern>application/folder</exclude-pattern>

But, this only works for linux, for windows I have to write
<exclude-pattern>application\folder</exclude-pattern>

My workaround is use 2 exclude patterns, but I don't know if this is correct or there are other alternatives.

<exclude-pattern>application/folder</exclude-pattern>
<exclude-pattern>application\folder</exclude-pattern>

Expected Behavior

I expect use just one path for windows/linux.

Thank you

@kylekatarnls
Copy link
Collaborator

@kylekatarnls kylekatarnls commented Oct 30, 2020

The correct way to fix it in my opinion would be to handle it in PDepend:
https://github.com/pdepend/pdepend/blob/master/src/main/php/PDepend/Input/ExcludePathFilter.php#L91

The ExcludePathFilter::accept() method determines if a given file matches a given pattern. So this filter could replace / and \ with [/\\\\] which as a RegExp pattern would allow both / and .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.