-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[cli] Filenames printed as absolute paths in the report despite parameter --short-names
#4026
Comments
--short-names
Thanks for the report. I remember commenting somewhere about this, the paths are only shortened if you input a relative path in the first place. If your file list contains absolute paths they will remain absolute. I couldn't find in which PR this was merged, and I don't think it was for PMD 6.47... That's maybe something #4000 uncovered. I'll take a harder look later. Edit: found it, it's only for PMD 7 #3893 (comment) That change still makes sense to me so I don't know if it's really a bug, though the behavior is surprising in this case... |
Hello @oowekyala, thanks for your response, but my file list contains relative paths |
So I could observe an inconsistent behavior, namely that the @hassanalamibmx could you check again whether this is a regression in PMD 6.47, and if so, provide a reproducible MWE? Here's what I observed with PMD 6.43, 6.44 and 6.47:
Ideally Maybe a solution would be to replace the |
I can see, that this feature appears to be working with 6.46.0 - but that is only accidentally: With fixing #3999 the behavior of 6.45.0 was restored. It only appears to be working in 6.46.0, because we used accidentally the current working directory for Maybe the following would be a way to make this magically work without configuring an explicit base path (which gives more flexibility, because you can control it): If we get the file-list, we try to find the longest common path prefix of all files and use this for shortening the paths. I guess, if the filelist only contains relative paths, then we would need to use the current working directory as the base path. If it contains mixed paths, then we would report only absolute paths. This could be a way to make it work for 90% of the use cases and without adding additional CLI parameters. The short-names-option belongs to reporting options like |
I think the problem with this strategy is that eg if we use a filelist with the files in Alternatively, we could say that we always relativize relative to the current working dir. It's less flexible and is not compatible with the current behavior of
I don't really like that... It's not English... Maybe |
Proposed fix for next version:
|
Affects PMD Version:
PMD 6.47.0
Description:
The PMD CLI option
--short-names
is expected to print shortned filenames, however the filenames are printed in absolute format.This feature was working fine 6.46.0
Exception Stacktrace:
Code Sample demonstrating the issue:
Steps to reproduce:
Please provide detailed steps for how we can reproduce the bug.
pmd --rulesets ruleset.xml --file-list diff.txt --format xml --report-file pmd-report.xml --short-names
Running PMD through: [CLI]
The text was updated successfully, but these errors were encountered: