Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
[core] Non-XML output breaks XML-based CLI integrations #1036
Affects PMD Version:
When the CLI is run for structured output, nothing but the structured output should be emitted to stdout/stderr. Otherwise parsing of the contents of the streams will fail unless some form of scrubbing/pre-processing is performed by every integrating client.
Running PMD through:
While found through the integration with Illuminated Cloud, this is easily reproducible via the CLI.
@SCWells72 thanks for your report and your concern. However, I do not agree with your position.
Messages such as the one you cite are written to stderr (as many other messages may), the output of the analysis is written to stdout unless redirected to a file. These are two separate and distinct streams any integration should be able to differentiate easily regardless of the operating system. As long as we don't mix both I believe our usage is correct and we should never silence a warning just because no output file has been chosen.
Why is it impossible to differentiate streams in your case?
If you believe we are mixing streams please let me know. That would be a huge bug.
Unrelated, but also of note, an IDE integration is a prime use-case for the analysis cache, you should consider supporting it.
@SCWells72 When running PMD from command line, there is also the
I agree, that nothing else than the report should go to stdout. If there is such output, then it's a bug. But stderr is still useful to report errors/warnings and can easily separated via redirections (e.g.
Related to this issue: #897
I am separating stdout from stderr already. The issue is that the message is included in both streams.
Regarding stdout vs. stderr and expectations, if the programmatic contract with the CLI is expressed via both stdout and stderr, then both should provide structured responses. If the contract is always communicated via stdout, only it should provide a structured response and stderr can be free-form.
I integrate other CLIs with the IDE, notably the Salesforce DX CLI, and when you run it with a
If PMD is only intended to write a structured XML response to stdout when run with the
Here you go. I just ran this:
and here's the first few lines of
That's the real issue.
Non the less, an IDE is a prime use-case for the cache, as you analyze, edit only a few files, analyze again, and so on. I'd rather recommend making use of the feature.