-
Notifications
You must be signed in to change notification settings - Fork 3
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
Remove working directory substring from filename of pmd violation #25
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm.... maybe I misunderstood what you wanted to do. I understood, that you want to remove the local working path information from the pmd report....
You're right and good catch for seeing this problem: If someone would run the tool from a different path than from which the baseline was created, the diff wouldn't work.
I've created now the baseline locally and the full local working path is still contained in the pmd_report.xml files. Is this, what you wanted?
Post-filtering the report might have the advantage, that the files become a bit smaller. But I think, this should really be an option of PMD itself (e.g. output relative filenames....would be a option for the renderer...).
By looking at the code, it should work, since we remove the code on-the-fly when reading the reports.
Note: I think, it won't work with PmdError, since the filename there is still with the local part (and used with the eql method).
@@ -28,11 +29,11 @@ def start_element(name, attrs = []) | |||
case name | |||
when 'file' | |||
@current_violations = [] | |||
@current_filename = attrs['name'] | |||
@current_filename = attrs['name'].sub(/^#{@working_dir}/, '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the hash key, that is used to collect the violations...
when 'violation' | ||
@current_violation = PmdViolation.new(attrs, @branch_name) | ||
when 'error' | ||
@current_filename = attrs['filename'] | ||
@current_filename = attrs['filename'].sub(/^#{@working_dir}/, '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's again only the hash key. attrs['filename']
is not changed, so the full filename is later on still available in PmdError.
@@ -25,6 +27,7 @@ def load(report_info_path) | |||
hash = JSON.parse(File.read(report_info_path)) | |||
@execution_time = hash['execution_time'] | |||
@timestamp = hash['timestamp'] | |||
@working_dir = hash['working_dir'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would expose the working directory again.... which I though, you wanted to remove...
The baseline is used for sharing, so we should remove this part of the information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used to record the working directory when generating the pmd report. When we reading pmd report, we can remove the working dir from pmd report according to value of this 'working dir'.
Yes, I agree with you that post-filtering the report should be a option of PMD itself.
Good catch! I'll fix it. |
When we generate the baseline which will be uploaded to somewhere, the file attribute of the violation element in the pmd report contains the local working path information. The baseline is used for sharing, so we should remove this part of the information.