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

The cli option --exclude doesn't work with absolute paths #888

Open
Wtyd opened this issue May 8, 2021 · 2 comments
Open

The cli option --exclude doesn't work with absolute paths #888

Wtyd opened this issue May 8, 2021 · 2 comments

Comments

@Wtyd
Copy link

Wtyd commented May 8, 2021

  • PHPMD version: 2.10.0
  • PHP Version: 7.4.16
  • Installation type: composer
  • Operating System / Distribution & Version: Debian 10

Current Behavior

I use --exclude option and the execution ignore it. The path to source and the path to exclude are absolute. If the exclude path is relative the behavior is right.

Expected Behavior

The file in the exclude path must be ignored.

Steps To Reproduce:

  1. Create a file with any violation.
  2. Execute phpmd with the violated rule against the file (or the path of the file) with the option --exclude in absolute path.
  3. Enjoy!
# Doesn't Work
vendor/bin/phpmd /var/www/html2/tests/../testsDir/src/File.php ansi unusedcode --exclude "/var/www/html2/tests/../testsDir/src/File.php"

FILE: /var/www/html2/testsDir/src/File.php
------------------------------------------
 21 | VIOLATION | Avoid unused local variables such as '$myVariable'.

Found 1 violation and 0 errors in 109ms

# Works
vendor/bin/phpmd /var/www/html2/tests/../testsDir/src/File.php ansi unusedcode --exclude "testsDir/src/File.php"                                                                    

Found 0 violations and 0 errors in 53ms

No mess detected

Checks before submitting

  • [X ] Be sure that there isn't already an issue about this. See: Issues list
  • [X ] Be sure that there isn't already a pull request about this. See: Pull requests
  • [ X] I have added every step to reproduce the bug.
  • [X ] If possible I added relevant code examples.
  • [ X] This issue is about 1 bug and nothing more.
  • [ X] The issue has a descriptive title. For example: "JSON rendering failed on Windows for filenames with space".
@tvbeek tvbeek added the Feature label Apr 12, 2022
@tvbeek
Copy link
Member

tvbeek commented Apr 12, 2022

@Wtyd thanks for the report, this is a nice situation that I personally didn't think about.

I think it is a nice feature to support absolute paths, do you have the option to create a PR?

@Wtyd
Copy link
Author

Wtyd commented Apr 30, 2022

I've downloaded the project, taken a look at it, and really don't know where to start. Sorry I can not be of more help.

@ravage84 ravage84 added this to the 2.x (unspecific) milestone May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants