shipmonk-rnd / composer-dependency-analyser

🚀 Fast detection of composer dependency issues (unused dependencies, shadow dependencies, misplaced dependencies)
MIT License
332 stars 8 forks source link

only print message if console format is used #128

Closed reinfi closed 2 months ago

reinfi commented 3 months ago

Bugfix patch for my junit formatter.

Finally found time to test it with CI/CD and found one issue:

Using config /Users/xxx/composer-dependency-analyser.php
<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="shadow dependencies" failures="1"><testcase name="laminas/laminas-uri"><failure>e.g. Laminas\Uri\Uri in src/Infrastructure/ExternalService/Url/UrlService.php:45 (+ 10 more)</failure></testcase></testsuite></testsuites>

The first line breaks the valid xml and I would have to remove it by script.

janedbal commented 3 months ago

Does junit support any kind of metadata? I'd rather keep those in the xml if possible. There are also other places with similar output.

reinfi commented 3 months ago

Does junit support any kind of metadata? I'd rather keep those in the xml if possible. There are also other places with similar output.

Will check if JUnit does support that, but would require a complete rework as there would be no single point of writing the xml.

I'm quite unsure about all the other lines. If they are just informal output I would need to suppress them all. May be I should add a different printMethod and change the other one that they does not output anything with format 'junit'. That would keep the code much cleaner.

reinfi commented 3 months ago

https://github.com/testmoapp/junitxml

There are some sort of properties that can be defined but that would need to be defined at any testsuite. Also the information from the output would need to be transfered to the JUnit-Formatter.

And the known JUnit-Parser does not display them properly. So if it fine for you I would skip that part for displaying these informal content.

Another, but different idea, would be that we add an output-file as option where the xml would be stored. Then the normal output could also happen but the xml would only be in that file.

janedbal commented 3 months ago

I'll think about it, but if we decide not to print things in Initializer for junit, I'd rather make Printer an interface and just pass VoidPrinter to Initializer in that case.

janedbal commented 2 months ago

PHPStan deals with the same issue by using STDERR for informatory message and STDOUT for the regular "formatter output". This seems like a best solution to me.

janedbal commented 2 months ago

Fixed in 1.5.3