Coder Social home page Coder Social logo

jbzoo / ci-report-converter Goto Github PK

View Code? Open in Web Editor NEW
27.0 3.0 2.0 2.36 MB

The tool converts different error reporting standards for deep compatibility with popular CI systems (TeamCity, IntelliJ IDEA, GitHub Actions, etc).

Home Page: https://github.com/JBZoo

License: MIT License

PHP 99.03% Makefile 0.56% Dockerfile 0.41%
checkstyle codestyle phpstorm teamcity github actions junit phpstan psalm phan

ci-report-converter's Introduction

JBZoo / CI-Report-Converter

CI Coverage Status Psalm Coverage Psalm Level CodeFactor
Stable Version Total Downloads Docker Pulls Dependents GitHub License

Why?

I believe you are familiar with the huge zoo of various utilities for testing, checking code standards, linters etc. It's really often the output of utilities is not supported in popular CI systems (TeamCity, GitHub, etc...). I guess you are lucky if the utility saves the error report in the junit.xml format, because it works pretty fine with almost all modern dev software.

But... My experience tells me it's the exception rather than the rule. For example, I really like the good old phpmd utility (perhaps you have another right opinion about the benefits. At least, it's just an example). It doesn't integrate well with TeamCity/PhpStorm/GitHub. Everytime I spend a lot of time looking for results in the logs. Though I really want to see instant and well-printed error report.

Therefore, I developed a converter that changes the report format for deep integration with CI systems and JetBrain IDEs.

Well... It may seem to you it's a useless thing, and your favorite super tool works fine in TeamCity/PhpStorm. Just take a look at the examples below.

Installing

composer require jbzoo/ci-report-converter
php ./vendor/bin/ci-report-converter --help

# OR use phar file
wget https://github.com/JBZoo/CI-Report-Converter/releases/latest/download/ci-report-converter.phar
chmod +x ./ci-report-converter.phar
./ci-report-converter.phar --help

# OR just pull the Docker Image
docker run --rm jbzoo/ci-report-converter --help

Using as GitHub Action

Action allows you to convert error reports to the GitHub Annotations format

- uses: jbzoo/ci-report-converter@master # or see the specific version on releases page
  with:
    # File path with the original report format. If not set or empty, then the STDIN is used.
    # Required: true
    input-file: ./build/checkstyle.xml

    # Source format. Available options: checkstyle, junit, phpmd-json, phpmnd, pmd-cpd, psalm-json
    # Default value: checkstyle
    # Required: true
    input-format: checkstyle

    # Will exit with the code=1, if any violations are found.
    # Default value: no
    non-zero-code: yes

    # File path with the result report format. If not set or empty, then the STDOUT is used.
    output-file: ./build/junit.xml

    # Target format. Available options: gitlab-json, github-cli, junit, plain, tc-inspections, tc-tests
    # Default value: github-cli
    # Required: true
    output-format: junit

    # If option is set, all absolute file paths will be converted to relative once.
    # Default value: .
    root-path: ./custom/project/path

    # Set custom name of root group/suite (if it's possible).
    # Required: true
    suite-name: My Tests

Example GitHub Action workflow

name: Linters

on:
  pull_request:
    branches:
      - "*"

jobs:
  linters:
    name: PHPcs
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Code
        uses: actions/checkout@v2

      - name: PHP Code Sniffer
        run: ./vendor/bin/phpcs --report=checkstyle --standard=PSR12 -q ./src > ./build/phpcs-checkstyle.xml

      - name: Converting checkstyle.xml to Github Annotations
        uses: jbzoo/ci-report-converter@master
        with:
          input-file: build/phpcs-checkstyle.xml

Available Directions

graph LR;
    checkstyle_src("CheckStyle.xml");
    ci-report-converter(("CI-Report<br>Converter"));
    github-cli_target("GitHub Actions - CLI");
    gitlab-json_target("GitLab - JSON");
    junit_src("JUnit.xml");
    junit_target("JUnit.xml");
    phpmd-json_src("PHPmd.json");
    phpmnd_src("PHPmnd.xml");
    plain_target("Plain Text");
    pmd-cpd_src("PmdCpd.xml");
    psalm-json_src("Psalm.json");
    tc-inspections_target("TeamCity - Inspections");
    tc-tests_target("TeamCity - Tests");

    checkstyle_src ==> ci-report-converter;
    ci-report-converter ==> github-cli_target;
    ci-report-converter ==> gitlab-json_target;
    ci-report-converter ==> junit_target;
    ci-report-converter ==> plain_target;
    ci-report-converter ==> tc-inspections_target;
    ci-report-converter ==> tc-tests_target;
    junit_src ==> ci-report-converter;
    phpmd-json_src ==> ci-report-converter;
    phpmnd_src ==> ci-report-converter;
    pmd-cpd_src ==> ci-report-converter;
    psalm-json_src ==> ci-report-converter;

linkStyle default interpolate basis;
Loading

At the moment, converting of reports works with

Also, you can follow metrics around your code in TeamCity via teamcity:stats

Help description in terminal

Converting

$ php ./vendor/bin/ci-report-converter convert --help
Description:
  Convert one report format to another one

Usage:
  convert [options]

Options:
  -S, --input-format=INPUT-FORMAT      Source format. Available options: checkstyle, junit, phpmd-json, phpmnd, pmd-cpd, psalm-json [default: "checkstyle"]
  -I, --input-file[=INPUT-FILE]        File path with the original report format. If not set or empty, then the STDIN is used.
  -T, --output-format=OUTPUT-FORMAT    Target format. Available options: gitlab-json, github-cli, junit, plain, tc-inspections, tc-tests [default: "tc-tests"]
  -O, --output-file[=OUTPUT-FILE]      File path with the result report format. If not set or empty, then the STDOUT is used.
  -R, --root-path[=ROOT-PATH]          If option is set, all absolute file paths will be converted to relative once. [default: "."]
  -N, --suite-name=SUITE-NAME          Set custom name of root group/suite (if it's possible).
  -F, --tc-flow-id[=TC-FLOW-ID]        Custom flowId in TeamCity output. Default value is PID of the tool.
  -Q, --non-zero-code[=NON-ZERO-CODE]  Will exit with the code=1, if any violations are found. [default: "no"]
      --no-progress                    Disable progress bar animation for logs. It will be used only for text output format.
      --mute-errors                    Mute any sort of errors. So exit code will be always "0" (if it's possible).
                                       It has major priority then --non-zero-on-error. It's on your own risk!
      --stdout-only                    For any errors messages application will use StdOut instead of StdErr. It's on your own risk!
      --non-zero-on-error              None-zero exit code on any StdErr message.
      --timestamp                      Show timestamp at the beginning of each message.It will be used only for text output format.
      --profile                        Display timing and memory usage information.
      --output-mode=OUTPUT-MODE        Output format. Available options:
                                       text - Default text output format, userfriendly and easy to read.
                                       cron - Shortcut for crontab. It's basically focused on human-readable logs output.
                                       It's combination of --timestamp --profile --stdout-only --no-progress -vv.
                                       logstash - Logstash output format, for integration with ELK stack.
                                        [default: "text"]
      --cron                           Alias for --output-mode=cron. Deprecated!
  -h, --help                           Display help for the given command. When no command is given display help for the list command
  -q, --quiet                          Do not output any message
  -V, --version                        Display this application version
      --ansi|--no-ansi                 Force (or disable --no-ansi) ANSI output
  -n, --no-interaction                 Do not ask any interactive question
  -v|vv|vvv, --verbose                 Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Custom Metrics in TeamCity

To clarify the use of the method, take a look at the examples and screenshots below, please.

$ php ./vendor/bin/ci-report-converter teamcity:stats --help
Description:
  Push code metrics to TeamCity Stats

Usage:
  teamcity:stats [options]

Options:
  -S, --input-format=INPUT-FORMAT  Source format. Available options: junit-xml, pdepend-xml, phploc-json, phpmetrics-xml, phpunit-clover-xml
  -I, --input-file[=INPUT-FILE]    File path with the original report format. If not set or empty, then the STDIN is used.
  -O, --output-file[=OUTPUT-FILE]  File path with the result report format. If not set or empty, then the STDOUT is used.
  -R, --root-path[=ROOT-PATH]      If option is set, all absolute file paths will be converted to relative once. [default: "."]
  -F, --tc-flow-id[=TC-FLOW-ID]    Custom flowId in TeamCity output. Default value is PID of the tool.
      --no-progress                Disable progress bar animation for logs. It will be used only for text output format.
      --mute-errors                Mute any sort of errors. So exit code will be always "0" (if it's possible).
                                   It has major priority then --non-zero-on-error. It's on your own risk!
      --stdout-only                For any errors messages application will use StdOut instead of StdErr. It's on your own risk!
      --non-zero-on-error          None-zero exit code on any StdErr message.
      --timestamp                  Show timestamp at the beginning of each message.It will be used only for text output format.
      --profile                    Display timing and memory usage information.
      --output-mode=OUTPUT-MODE    Output format. Available options:
                                   text - Default text output format, userfriendly and easy to read.
                                   cron - Shortcut for crontab. It's basically focused on human-readable logs output.
                                   It's combination of --timestamp --profile --stdout-only --no-progress -vv.
                                   logstash - Logstash output format, for integration with ELK stack.
                                    [default: "text"]
      --cron                       Alias for --output-mode=cron. Deprecated!
  -h, --help                       Display help for the given command. When no command is given display help for the list command
  -q, --quiet                      Do not output any message
  -V, --version                    Display this application version
      --ansi|--no-ansi             Force (or disable --no-ansi) ANSI output
  -n, --no-interaction             Do not ask any interactive question
  -v|vv|vvv, --verbose             Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Examples

JetBrains IDE (IntelliJ IDEA, PhpStorm, WebStorm, etc)

One of the unique features of the tool is converting reports to a unit test format compatible with JetBrains IDE and TeamCity. The following examples show how to use JetBrains IDE UI to display any kind of style issues. Yeah, I know that the integration is not the cleanest, and it's not super beautiful. However, this code/screenshots demonstrate the usability of the approach.

PHPcs in JetBrains PhpStorm

NOTE: I believe that coding style issues have the same level of severity as any other sort of errors. Therefore, I prefer to use the same workflow to check the quality of the code as I do with regular PHPUnit tests. It's like "just one click!" Also, you will have the awesome bonus - navigating the project and gives the most detailed information about errors.

The general idea is pretty simple:

  • We take almost any utility for testing.
  • It saves report in the file or outputs error to StdOut as xml/json.
  • CI-Report-Converter changes the report format. It saves result somewhere or just outputs it in StdOut.
  • ???
  • Profit.

In the next example we will see how to integrate JetBrains IDE UI with Code Sniffer deeply. I use PHPcs just as example. This is the most popular linter in PHP. However, the approach is independent of the programming language or unit testing framework.

<?php declare(strict_types=1);

use PHPUnit\Framework\Assert;
use PHPUnit\Framework\TestCase;

/**
 * Here's an example based on PHPUnit and PhpStorm, but you are not limited to PHP language.
 * This is just an example to show the idea.
 * So you can use any sort language to integrate style tests with JetBrains IDE.
 */
class CheckStyleExamplesTest extends TestCase
{
    /**
     * The short example which uses pipe as way to pass error report.
     */
    public function testPipelineWay(): void
    {
        echo shell_exec(                       # Execute command via shell and return the complete output as a string.
            'php ./vendor/bin/phpcs' .         # Path to bin of third-party tool (PHP Code Sniffer is just example).
            ' --report=checkstyle' .           # Output format of PHPcs. ci-report-converter expects it by default as `--input-format` option.
            ' --standard=PSR12 -q ./src' .     # The custom tool options. For phpcs `-q` is important!
            ' | ' .                            # The pipe operator, it passes the output of one command as input to another. See https://en.wikipedia.org/wiki/Pipeline_(Unix)
            ' ./ci-report-converter.phar'      # The converter does all the magic. Look at help description ( --help) to lean more about options and default values.
        );

        # Usually PHPUnit expects at least one assert in a test.
        # Otherwise, it may show useless warning messages. It depends on PHPUnit version and your configurations.
        # So, just in case, we make a fake assertion.
        Assert::assertTrue(true);
    }

    /**
     * The super detailed example which uses files as way to pass error report.
     */
    public function testXmlFileWay(): void
    {
        shell_exec(                                     # Execute command via shell and return the complete output as a string.
            'php ./vendor/bin/phpcs' .                  # Path to bin of third-party tool (PHP Code Sniffer is just example).
            ' --report=checkstyle' .                    # Output format of PHPcs. CI-Report-Converter expects it by default as `--input-format` option.
            ' --report-file=./build/phpcs-report.xml' . # Save result of phpcs work in XML file in "checkstyle" format.
            ' --standard=PSR12 -q ./src' .              # The custom tool options. For phpcs `-q` is important!
            ' || true > /dev/null'                      # We don't expect any output of phpcs and ignore error exit codes.
                                                        # Lol, we are very self-confident. Actually, we need only XML file, that's it.
        );

        // I've shown all the options explicitly just to add transparency.
        // In fact, this example does the same thing as the code above in `testPipelineWay()`.
        echo shell_exec(
            './ci-report-converter.phar' .              # The path to bin file of CI-Report-Converter. It depends of your installation way. See above.
            ' --input-format=checkstyle' .              # Source reporting format. Default value is "checkstyle".
            ' --input-file=./build/phpcs-report.xml' .  # Using prepared file on previous step as source.
            ' --output-format=tc-tests' .               # Target reporting format. Default value is "tc-tests".
            ' --suite-name=PHPcs' .                     # Define the name of group. See screenshot below.
            ' --root-path=`pwd`'                        # Specify the project path for pretty printing paths in UI. Default value is `.` (current dir).
        );

        # The same reason like in `testPipelineWay()`.
        Assert::assertTrue(true);
    }
}

What happens under the hood. Also, see source file as ready-to-use examples.

cd  ~/your/project/root/directory
php ./vendor/bin/phpunit ./tests/examples/CheckStyleExamples.php --teamcity

# or
php ./vendor/bin/phpcs --report=checkstyle --standard=PSR12 -q ./src | ./ci-report-converter.phar

Mess Detector (phpmd-json)

Screenshot

PHPmd in JetBrains PhpStorm

php ./vendor/bin/phpmd ./src json cleancode | ./ci-report-converter.phar -Sphpmd-json

Magic Number Detector (phpmnd)

Screenshot

PHPmd in JetBrains PhpStorm

php ./vendor/bin/phpmnd ./src --hint --quiet --xml-output=./build/phpmnd-report.xml
./ci-report-converter.phar --root-path=./src --input-file=./build/phpmnd-report.xml --input-format=phpmnd

Copy/Paste Detector (pmd-cpd)

Screenshot

PHPcpd in JetBrains PhpStorm

php ./vendor/bin/phpcpd ./src --log-pmd=./build/phpcpd-report.xml
./ci-report-converter.phar --input-file=./build/phpcpd-report.xml --input-format=pmd-cpd

PHPStan (checkstyle)

Screenshot

PHPstan in JetBrains PhpStorm

php ./vendor/bin/phpstan analyse --error-format=checkstyle --no-progress ./src | ./ci-report-converter.phar

Psalm (psalm-json)

Screenshot

PHP Psalm in JetBrains PhpStorm

php ./vendor/bin/psalm --output-format=json | ./ci-report-converter.phar --input-format="psalm-json"

Phan (checkstyle)

Screenshot

PHP Psalm in JetBrains PhpStorm

php ./vendor/bin/phan.phar --directory=./src --output-mode=checkstyle |  ./ci-report-converter.phar

TeamCity - Style Issue As Failed Unit test

Use the option --output-format=tc-tests to convert any style report to unit test format in TeamCity

Style issues as failed tests in TeamCity

TeamCity - Style Issue As Code Inspections

Use the option --output-format=tc-inspections to convert any style report to unit test format in TeamCity

Style Issue As Code Inspections in TeamCity

TeamCity - Reported Statistic Values

PHPDepend.xml => Example in TeamCity

./vendor/bin/pdepend.phar --summary-xml="./build/pdepend-summary.xml" --quiet ./src
./ci-report-converter.phar teamcity:stats --input-format="pdepend-xml" --input-file="./build/pdepend-summary.xml"

PHPloc.json => Example in TeamCity

./vendor/bin/phploc ./src --log-json="./build/phploc.json" --quiet
./ci-report-converter.phar teamcity:stats --input-format="phploc-json" --input-file="./build/phploc.json"

PHPUnitClover.xml => Example in TeamCity

./vendor/bin/phpunit --coverage-clover ./build/phpunit-report.xml
./ci-report-converter.phar teamcity:stats --input-format="phpunit-clover-xml" --input-file="./build/phpunit-report.xml"

JUnit.xml => Example in TeamCity

./vendor/bin/phpunit --coverage-xml ./build/phpunit-junit.xml
./ci-report-converter.phar teamcity:stats --input-format="junit-xml" --input-file="./build/phpunit-junit.xml"

PHPMetrics.xml => Example in TeamCity

./vendor/bin/phpmetrics  ./src --report-violations="./build/phpmetrics-report.xml"
./ci-report-converter.phar teamcity:stats --input-format="phpmetrics-xml" --input-file="./build/phpmetrics-report.xml"

Style issues as failed tests in TeamCity

GitHub Actions

You can find a lot of life examples here and see real examples in YML file

GitHub Actions 1

GitHub Actions 1

GitLab CI

Use the option --output-format=gitlab-json to convert the report to Gitlab JSON format.

Als, see how to implemente GitLab Custom Report

GitLab Code Quality Report

Use tool as SDK to generate reports

Also, you can use source of tool as SDK for reports in your tools/project.

PS: More examples are coming soon.

JUnit.xml (API)

use JBZoo\CIReportConverter\Converters\JUnitConverter;
use JBZoo\CIReportConverter\Formats\Source\SourceCaseOutput;
use JBZoo\CIReportConverter\Formats\Source\SourceSuite;

$class = \JBZoo\PHPUnit\ExampleTest::class;
$className = str_replace('\\', '.', $class);
$filename = './tests/ExampleTest.php';
$line = 28;

$suite = new SourceSuite('Suite');
$case = $suite->addTestCase('Test Name');
$case->time = 0.001824;
$case->file = $filename;
$case->line = $line;
$case->class = $class;
$case->classname = $className;
$case->assertions = 5;
$case->stdOut = 'Some std output';
$case->errOut = 'Some err output';
$case->failure = new SourceCaseOutput('Failure', 'Failure Message', 'Failure Details');
$case->error = new SourceCaseOutput('Error', 'Error Message', 'Error Details');
$case->warning = new SourceCaseOutput('Warning', 'Warning Message', 'Warning Details');
$case->skipped = new SourceCaseOutput('Skipped', 'Skipped Message', 'Skipped Details');

echo (new JUnitConverter())->fromInternal($suite);
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite name="Suite" tests="1" assertions="5" errors="1" warnings="1" failures="1" skipped="1" time="0.001824">
    <testcase name="Test Name" class="JBZoo\PHPUnit\ExampleTest" classname="JBZoo.PHPUnit.ExampleTest" file="./tests/ExampleTest.php" line="28" assertions="5" time="0.001824">
      <failure type="Failure" message="Failure Message">Failure Details</failure>
      <warning type="Warning" message="Warning Message">Warning Details</warning>
      <error type="Error" message="Error Message">Error Details</error>
      <system-out>Some std output
Some err output</system-out>
      <skipped/>
    </testcase>
  </testsuite>
</testsuites>

GitHub Actions (API)

use JBZoo\CIReportConverter\Formats\GithubActions\GithubActions;

$ghActions = new GithubActions();
$case0 = $ghActions->addCase('src/Root.php');
$case0->line = 789;
$case0->column = null;
$case0->message = 'Something went wrong #0';

$suite1 = $ghActions->addSuite('src/File.php');
$case1 = $suite1->addCase('src/Class.php');
$case1->line = 123;
$case1->column = 4;
$case1->message = 'Something went wrong #1';

echo $ghActions->__toString();
::error file=src/Root.php,line=789::Something went wrong #0

::group::src/File.php
::error file=src/Class.php,line=123,col=4::Something went wrong #1
::endgroup::

Contributing

# Fork the repo and build project
make build

# Make your local changes

# Run all tests and check code style
make test
make codestyle

# Create your pull request and check all tests in CI

License

MIT

See Also

  • Composer-Diff - See what packages have changed after composer update.
  • Composer-Graph - Dependency graph visualization of composer.json based on mermaid-js.
  • Mermaid-PHP - Generate diagrams and flowcharts with the help of the mermaid script language.
  • Utils - Collection of useful PHP functions, mini-classes, and snippets for every day.
  • Image - Package provides object-oriented way to manipulate with images as simple as possible.
  • Data - Extended implementation of ArrayObject. Use files as config/array.
  • Retry - Tiny PHP library providing retry/backoff functionality with multiple backoff strategies and jitter support.
  • SimpleTypes - Converting any values and measures - money, weight, exchange rates, length, ...

ci-report-converter's People

Contributors

kimpepper avatar smetdenis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ci-report-converter's Issues

Output format "plain" doesn't work

Using on Github actions as:

      - uses: jbzoo/[email protected]
        with:
          input-file: ./build/mypy-report.xml
          input-format: junit
          output-format: plain

it fails:

 In Convert.php line 105:
  [JBZoo\CiReportConverter\Commands\Exception]                                 
  Format "plain" not found. See the option "--output-format".                  
  Available options: checkstyle,gitlab-json,github-cli,junit,phpmd-json,phpmn  
  d,pmd-cpd,psalm-json,tc-inspections,tc-tests                                 
Exception trace:
  at /app/src/Commands/Convert.php:105
 JBZoo\CiReportConverter\Commands\Convert->getFormat() at /app/src/Commands/Convert.php:82
 JBZoo\CiReportConverter\Commands\Convert->executeAction() at /app/src/Commands/AbstractCommand.php:50
 JBZoo\CiReportConverter\Commands\AbstractCommand->execute() at /app/vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /app/vendor/symfony/console/Application.php:1009
 Symfony\Component\Console\Application->doRunCommand() at /app/vendor/symfony/console/Application.php:273
 Symfony\Component\Console\Application->doRun() at /app/vendor/symfony/console/Application.php:149
 Symfony\Component\Console\Application->run() at /app/ci-report-converter.php:45
 require_once() at /app/ci-report-converter:19
convert [-S|--input-format INPUT-FORMAT] [-I|--input-file [INPUT-FILE]] [-T|--output-format OUTPUT-FORMAT] [-O|--output-file [OUTPUT-FILE]] [-R|--root-path [ROOT-PATH]] [-N|--suite-name SUITE-NAME] [-F|--tc-flow-id [TC-FLOW-ID]] [-Q|--non-zero-code [NON-ZERO-CODE]]

STDIN usage hangs when no inputs provided

Hello

I've discovered and tested your package quickly, and was surprised that it took a long time to reply to me !
So I've investigate, and see that if you forget to specify the --input-file option, then STDIN is used by default.

But when we run ci-report-converter convert command without any input on STDIN, it hangs. why?
Because it's patiently waiting for input that never comes.

To solve this, I recommend to fix your jbzoo/cli package (take caution of other impacts with your other projects)

Replace current JBZoo\Cli\CliCommand ::getStdIn() implementation

By this one :

<?php 

    protected static function getStdIn(): ?string
    {
        static $result; // It can be read only once, so we save result as internal variable

        if ($result === null) {
            $result = '';

            $read = [STDIN];
            $write = [];
            $except = [];
            $seconds = 1; // 1 second (is enough) on timeout since this is just for testing stream change
            $streamCount = @\stream_select($read, $write, $except, $seconds);

            if ($streamCount > 0) {
                while ($line = \fgets(\STDIN, 1024)) {
                    $result .= $line;
                }
            }
        }

        return $result;
    }

And if you give it a try (with ./ci-report-converter convert -S phpmd-json -T plain --profile -vv), we will have expected error !

STDIN

Real pipeline condition with inputs still gave results as expected too :

/shared/backups/forks/phpmd/src/bin/phpmd vendor/povils/phpmnd/src/ json unusedcode | ./ci-report-converter convert -S phpmd-json -T plain --profile -vv
[+1.165s/   1.16 MB] ## Test Case: vendor/povils/phpmnd/src/Command/RunCommand.php
[+0.000s/       0 B] +-------------+----------+---- vendor/povils/phpmnd/src/Command/RunCommand.php -----------------------------+
[+0.000s/       0 B] | Line:Column | Severity | Message                                                                          |
[+0.000s/       0 B] +-------------+----------+----------------------------------------------------------------------------------+
[+0.000s/       0 B] | 254         | Error    | Avoid unused private methods such as 'castToNumber'.                             |
[+0.000s/       0 B] |             |          | Rule     : Unused Code Rules / UnusedPrivateMethod / Priority: 3                 |
[+0.000s/       0 B] |             |          | PHP Mute : @SuppressWarnings(PHPMD.UnusedPrivateMethod)                          |
[+0.000s/       0 B] |             |          | Func     : Povils\PHPMND\Command\RunCommand->castToNumber()                      |
[+0.001s/       0 B] |             |          | File Path: vendor/povils/phpmnd/src/Command/RunCommand.php:254                   |
[+0.000s/       0 B] |             |          | Docs     : https://phpmd.org/rules/unusedcode.html#unusedprivatemethod           |
[+0.000s/       0 B] +-------------+----------+---- vendor/povils/phpmnd/src/Command/RunCommand.php -----------------------------+
[+0.000s/       0 B]
[+0.000s/       0 B] ## Test Case: vendor/povils/phpmnd/src/Container.php
[+0.000s/       0 B] +-------------+----------+-------- vendor/povils/phpmnd/src/Container.php ----------------------------------+
[+0.000s/       0 B] | Line:Column | Severity | Message                                                                          |
[+0.000s/       0 B] +-------------+----------+----------------------------------------------------------------------------------+
[+0.000s/       0 B] | 57          | Error    | Avoid unused private methods such as 'getParser'.                                |
[+0.000s/       0 B] |             |          | Rule     : Unused Code Rules / UnusedPrivateMethod / Priority: 3                 |
[+0.000s/       0 B] |             |          | PHP Mute : @SuppressWarnings(PHPMD.UnusedPrivateMethod)                          |
[+0.000s/       0 B] |             |          | Func     : Povils\PHPMND\Container->getParser()                                  |
[+0.001s/       0 B] |             |          | File Path: vendor/povils/phpmnd/src/Container.php:57                             |
[+0.000s/       0 B] |             |          | Docs     : https://phpmd.org/rules/unusedcode.html#unusedprivatemethod           |
[+0.000s/       0 B] +-------------+----------+----------------------------------------------------------------------------------+
[+0.000s/       0 B] | 62          | Error    | Avoid unused private methods such as 'getLexer'.                                 |
[+0.000s/       0 B] |             |          | Rule     : Unused Code Rules / UnusedPrivateMethod / Priority: 3                 |
[+0.000s/       0 B] |             |          | PHP Mute : @SuppressWarnings(PHPMD.UnusedPrivateMethod)                          |
[+0.000s/       0 B] |             |          | Func     : Povils\PHPMND\Container->getLexer()                                   |
[+0.000s/       0 B] |             |          | File Path: vendor/povils/phpmnd/src/Container.php:62                             |
[+0.000s/       0 B] |             |          | Docs     : https://phpmd.org/rules/unusedcode.html#unusedprivatemethod           |
[+0.000s/       0 B] +-------------+----------+-------- vendor/povils/phpmnd/src/Container.php ----------------------------------+
[+0.000s/       0 B]
[+0.000s/       0 B] ## Test Case: vendor/povils/phpmnd/src/PhpParser/Visitor/DetectionVisitor.php
[+0.000s/       0 B] +-------------+------- vendor/povils/phpmnd/src/PhpParser/Visitor/DetectionVisitor.php ---------------------+
[+0.000s/       0 B] | Line:Column | Severity | Message                                                                          |
[+0.001s/       0 B] +-------------+----------+----------------------------------------------------------------------------------+
[+0.000s/       0 B] | 26          | Error    | Avoid unused parameters such as '$nodes'.                                        |
[+0.000s/       0 B] |             |          | Rule     : Unused Code Rules / UnusedFormalParameter / Priority: 3               |
[+0.000s/       0 B] |             |          | PHP Mute : @SuppressWarnings(PHPMD.UnusedFormalParameter)                        |
[+0.000s/       0 B] |             |          | File Path: vendor/povils/phpmnd/src/PhpParser/Visitor/DetectionVisitor.php:26    |
[+0.000s/       0 B] |             |          | Docs     : https://phpmd.org/rules/unusedcode.html#unusedformalparameter         |
[+0.000s/       0 B] +-------------+------- vendor/povils/phpmnd/src/PhpParser/Visitor/DetectionVisitor.php ---------------------+
[+0.001s/       0 B]
[+0.001s/       0 B] ## Test Case: vendor/povils/phpmnd/src/PhpParser/Visitor/ParentConnectorVisitor.php
[+0.000s/       0 B] +-------------+---- vendor/povils/phpmnd/src/PhpParser/Visitor/ParentConnectorVisitor.php ------------------+
[+0.000s/       0 B] | Line:Column | Severity | Message                                                                          |
[+0.000s/       0 B] +-------------+----------+----------------------------------------------------------------------------------+
[+0.000s/       0 B] | 17          | Error    | Avoid unused parameters such as '$nodes'.                                        |
[+0.000s/       0 B] |             |          | Rule     : Unused Code Rules / UnusedFormalParameter / Priority: 3               |
[+0.000s/       0 B] |             |          | PHP Mute : @SuppressWarnings(PHPMD.UnusedFormalParameter)                        |
[+0.001s/       0 B] |             |          | File Path:                                                                       |
[+0.000s/       0 B] |             |          | vendor/povils/phpmnd/src/PhpParser/Visitor/ParentConnectorVisitor.php:17         |
[+0.000s/       0 B] |             |          | Docs     : https://phpmd.org/rules/unusedcode.html#unusedformalparameter         |
[+0.000s/       0 B] +-------------+----------+----------------------------------------------------------------------------------+
[+0.001s/       0 B] | 31          | Error    | Avoid unused parameters such as '$node'.                                         |
[+0.000s/       0 B] |             |          | Rule     : Unused Code Rules / UnusedFormalParameter / Priority: 3               |
[+0.000s/       0 B] |             |          | PHP Mute : @SuppressWarnings(PHPMD.UnusedFormalParameter)                        |
[+0.000s/       0 B] |             |          | File Path:                                                                       |
[+0.000s/       0 B] |             |          | vendor/povils/phpmnd/src/PhpParser/Visitor/ParentConnectorVisitor.php:31         |
[+0.000s/       0 B] |             |          | Docs     : https://phpmd.org/rules/unusedcode.html#unusedformalparameter         |
[+0.001s/       0 B] +-------------+---- vendor/povils/phpmnd/src/PhpParser/Visitor/ParentConnectorVisitor.php ------------------+
[+0.001s/       0 B]
[+0.002s/       0 B] Memory Usage/Peak: 7.72 MB/10.00 MB; Execution Time: 1.189 sec
[+0.001s/       0 B] Exit Code is "0"

`make test` command failed if we cannot build locally a PHAR version

Related to issue #41, when we invoke make test command, we got following output

[email protected] in /shared/backups/forks/CI-Report-Converter $ make test
make[1]: Entering directory '/shared/backups/forks/CI-Report-Converter'
File ./vendor/bin/composer-diff.phar not found. Downloading.
File ./vendor/bin/composer-graph.phar not found. Downloading.
File ./vendor/bin/ci-report-converter.phar not found. Downloading.
make[1]: Leaving directory '/shared/backups/forks/CI-Report-Converter'
make[1]: Entering directory '/shared/backups/forks/CI-Report-Converter'

>>>> >>>> >>>> >>>> >>>> >>>>  PHPUnit - Run all tests
make[2]: Entering directory '/shared/backups/forks/CI-Report-Converter'
PHPUnit 9.6.13 by Sebastian Bergmann and contributors.

EEESEEEEESEEE..................................................  63 / 135 ( 46%)
......SSSSSSSSSSSSSS................S.......SSS.SSS.....SSSSSSS 126 / 135 ( 93%)
S........                                                       135 / 135 (100%)

Time: 00:03.119, Memory: 36.00 MB

There were 11 errors:

1) JBZoo\PHPUnit\CliCommandsPharTest::testConvertCommandReadMe
Symfony\Component\Process\Exception\ProcessFailedException: The command "'/usr/local/bin/php' /shared/backups/forks/CI-Report-Converter/build/ci-report-converter.phar convert 2>&1 --help -v --no-ansi" failed.

Exit Code: 1(General error)

Working directory: /shared/backups/forks/CI-Report-Converter

Output:
================
Could not open input file: /shared/backups/forks/CI-Report-Converter/build/ci-report-converter.phar


Error Output:
================


/shared/backups/forks/CI-Report-Converter/vendor/jbzoo/utils/src/Cli.php:119
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsPharTest.php:36
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsTest.php:42

2) JBZoo\PHPUnit\CliCommandsPharTest::testTcStatsCommandReadMe
Symfony\Component\Process\Exception\ProcessFailedException: The command "'/usr/local/bin/php' /shared/backups/forks/CI-Report-Converter/build/ci-report-converter.phar teamcity:stats 2>&1 --help -v --no-ansi" failed.

Exit Code: 1(General error)

Working directory: /shared/backups/forks/CI-Report-Converter

Output:
================
Could not open input file: /shared/backups/forks/CI-Report-Converter/build/ci-report-converter.phar


Error Output:
================


/shared/backups/forks/CI-Report-Converter/vendor/jbzoo/utils/src/Cli.php:119
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsPharTest.php:36
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsTest.php:57

3) JBZoo\PHPUnit\CliCommandsPharTest::testGitHubActionsYml
Symfony\Component\Process\Exception\ProcessFailedException: The command "'/usr/local/bin/php' /shared/backups/forks/CI-Report-Converter/build/ci-report-converter.phar convert 2>&1 --help --format="json" -v --no-ansi" failed.

Exit Code: 1(General error)

Working directory: /shared/backups/forks/CI-Report-Converter

Output:
================
Could not open input file: /shared/backups/forks/CI-Report-Converter/build/ci-report-converter.phar


Error Output:
================


/shared/backups/forks/CI-Report-Converter/vendor/jbzoo/utils/src/Cli.php:119
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsPharTest.php:36
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsTest.php:72

4) JBZoo\PHPUnit\CliCommandsPharTest::testConvertCommandMapReadMe
Symfony\Component\Process\Exception\ProcessFailedException: The command "'/usr/local/bin/php' /shared/backups/forks/CI-Report-Converter/build/ci-report-converter.phar convert:map 2>&1 -v --no-ansi" failed.

Exit Code: 1(General error)

Working directory: /shared/backups/forks/CI-Report-Converter

Output:
================
Could not open input file: /shared/backups/forks/CI-Report-Converter/build/ci-report-converter.phar


Error Output:
================


/shared/backups/forks/CI-Report-Converter/vendor/jbzoo/utils/src/Cli.php:119
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsPharTest.php:36
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsPharTest.php:26
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsTest.php:184

5) JBZoo\PHPUnit\CliCommandsPharTest::testConvertStatsUndefinedFile
Symfony\Component\Process\Exception\ProcessFailedException: The command "'/usr/local/bin/php' /shared/backups/forks/CI-Report-Converter/build/ci-report-converter.phar teamcity:stats 2>&1 --input-file="/undefined/file.xml" --input-format="pdepend-xml" -v --no-ansi" failed.

Exit Code: 1(General error)

Working directory: /shared/backups/forks/CI-Report-Converter

Output:
================
Could not open input file: /shared/backups/forks/CI-Report-Converter/build/ci-report-converter.phar


Error Output:
================


/shared/backups/forks/CI-Report-Converter/vendor/jbzoo/utils/src/Cli.php:119
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsPharTest.php:36
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsPharTest.php:26
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsTest.php:190

6) JBZoo\PHPUnit\CliCommandsPharTest::testConvertStatsCustomFlowId
Symfony\Component\Process\Exception\ProcessFailedException: The command "'/usr/local/bin/php' /shared/backups/forks/CI-Report-Converter/build/ci-report-converter.phar teamcity:stats 2>&1 --input-file="/shared/backups/forks/CI-Report-Converter/tests/fixtures/origin/phploc/json.json" --input-format="phploc-json" --tc-flow-id="10000" -v --no-ansi" failed.

Exit Code: 1(General error)

Working directory: /shared/backups/forks/CI-Report-Converter

Output:
================
Could not open input file: /shared/backups/forks/CI-Report-Converter/build/ci-report-converter.phar


Error Output:
================


/shared/backups/forks/CI-Report-Converter/vendor/jbzoo/utils/src/Cli.php:119
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsPharTest.php:36
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsPharTest.php:26
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsTest.php:200

7) JBZoo\PHPUnit\CliCommandsPharTest::testConvertCustomFlowId
Symfony\Component\Process\Exception\ProcessFailedException: The command "'/usr/local/bin/php' /shared/backups/forks/CI-Report-Converter/build/ci-report-converter.phar convert 2>&1 --input-format="checkstyle" --output-format="tc-tests" --input-file="/shared/backups/forks/CI-Report-Converter/tests/fixtures/origin/psalm/checkstyle.xml" --suite-name="Test Suite" --root-path="src" --tc-flow-id="10101" -v --no-ansi" failed.

Exit Code: 1(General error)

Working directory: /shared/backups/forks/CI-Report-Converter

Output:
================
Could not open input file: /shared/backups/forks/CI-Report-Converter/build/ci-report-converter.phar


Error Output:
================


/shared/backups/forks/CI-Report-Converter/vendor/jbzoo/utils/src/Cli.php:119
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsPharTest.php:36
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsPharTest.php:26
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsTest.php:211

8) JBZoo\PHPUnit\CliCommandsPharTest::testConvertToTcInspections
Symfony\Component\Process\Exception\ProcessFailedException: The command "'/usr/local/bin/php' /shared/backups/forks/CI-Report-Converter/build/ci-report-converter.phar convert 2>&1 --input-format="phpmd-json" --output-format="tc-inspections" --input-file="/shared/backups/forks/CI-Report-Converter/tests/fixtures/origin/phpmd/json.json" -v --no-ansi" failed.

Exit Code: 1(General error)

Working directory: /shared/backups/forks/CI-Report-Converter

Output:
================
Could not open input file: /shared/backups/forks/CI-Report-Converter/build/ci-report-converter.phar


Error Output:
================


/shared/backups/forks/CI-Report-Converter/vendor/jbzoo/utils/src/Cli.php:119
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsPharTest.php:36
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsPharTest.php:26
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsTest.php:225

9) JBZoo\PHPUnit\CliCommandsPharTest::testConvertUndefinedFile
Symfony\Component\Process\Exception\ProcessFailedException: The command "'/usr/local/bin/php' /shared/backups/forks/CI-Report-Converter/build/ci-report-converter.phar convert 2>&1 --input-format="checkstyle" --output-format="junit" --input-file="/undefined/file.xml" --suite-name="Test Suite" --root-path="src" --non-zero-code="yes" -v --no-ansi" failed.

Exit Code: 1(General error)

Working directory: /shared/backups/forks/CI-Report-Converter

Output:
================
Could not open input file: /shared/backups/forks/CI-Report-Converter/build/ci-report-converter.phar


Error Output:
================


/shared/backups/forks/CI-Report-Converter/vendor/jbzoo/utils/src/Cli.php:119
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsPharTest.php:36
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsPharTest.php:26
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsTest.php:282

10) JBZoo\PHPUnit\CliCommandsPharTest::testConvertCommand
Symfony\Component\Process\Exception\ProcessFailedException: The command "'/usr/local/bin/php' /shared/backups/forks/CI-Report-Converter/build/ci-report-converter.phar convert 2>&1 --input-format="checkstyle" --output-format="junit" --input-file="/shared/backups/forks/CI-Report-Converter/tests/fixtures/origin/psalm/checkstyle.xml" --suite-name="Test Suite" --root-path="src" -v --no-ansi" failed.

Exit Code: 1(General error)

Working directory: /shared/backups/forks/CI-Report-Converter

Output:
================
Could not open input file: /shared/backups/forks/CI-Report-Converter/build/ci-report-converter.phar


Error Output:
================


/shared/backups/forks/CI-Report-Converter/vendor/jbzoo/utils/src/Cli.php:119
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsPharTest.php:36
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsPharTest.php:26
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsTest.php:296

11) JBZoo\PHPUnit\CliCommandsPharTest::testConvertCommandSaveToFile
Symfony\Component\Process\Exception\ProcessFailedException: The command "'/usr/local/bin/php' /shared/backups/forks/CI-Report-Converter/build/ci-report-converter.phar convert 2>&1 --input-format="checkstyle" --output-format="junit" --input-file="/shared/backups/forks/CI-Report-Converter/tests/fixtures/origin/psalm/checkstyle.xml" --output-file="/shared/backups/forks/CI-Report-Converter/build/testConvertCommandSaveToFile.xml" --suite-name="Test Suite" --root-path="src" -v --no-ansi" failed.

Exit Code: 1(General error)

Working directory: /shared/backups/forks/CI-Report-Converter

Output:
================
Could not open input file: /shared/backups/forks/CI-Report-Converter/build/ci-report-converter.phar


Error Output:
================


/shared/backups/forks/CI-Report-Converter/vendor/jbzoo/utils/src/Cli.php:119
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsPharTest.php:36
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsPharTest.php:26
/shared/backups/forks/CI-Report-Converter/tests/CliCommandsTest.php:356

ERRORS!
Tests: 135, Assertions: 648, Errors: 11, Skipped: 31.

Generating code coverage report in PHP format ... done [00:00.003]

Generating code coverage report in Clover XML format ... done [00:00.068]


Code Coverage Report:
  2024-01-25 06:05:33

 Summary:
  Classes: 41.18% (21/51)
  Methods: 74.47% (140/188)
  Lines:   94.13% (1426/1515)

JBZoo\CIReportConverter\Commands\AbstractCommand
  Methods:  50.00% ( 1/ 2)   Lines:  76.47% ( 13/ 17)
JBZoo\CIReportConverter\Commands\Convert
  Methods:  33.33% ( 1/ 3)   Lines:  93.81% ( 91/ 97)
JBZoo\CIReportConverter\Commands\ConvertMap
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 17/ 17)
JBZoo\CIReportConverter\Commands\Exception
  Methods:  ( 0/ 0)   Lines:  (  0/  0)
JBZoo\CIReportConverter\Commands\TeamCityStats
  Methods:  75.00% ( 3/ 4)   Lines:  93.44% ( 57/ 61)
JBZoo\CIReportConverter\Converters\AbstractConverter
  Methods:  50.00% ( 4/ 8)   Lines:  83.33% ( 30/ 36)
JBZoo\CIReportConverter\Converters\AbstractStatsTcConverter
  Methods:  50.00% ( 2/ 4)   Lines:  90.00% ( 18/ 20)
JBZoo\CIReportConverter\Converters\CheckStyleConverter
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 32/ 32)
JBZoo\CIReportConverter\Converters\Exception
  Methods:  ( 0/ 0)   Lines:  (  0/  0)
JBZoo\CIReportConverter\Converters\GitLabJsonConverter
  Methods:  66.67% ( 2/ 3)   Lines:  96.30% ( 26/ 27)
JBZoo\CIReportConverter\Converters\GithubCliConverter
  Methods:  66.67% ( 2/ 3)   Lines:  96.55% ( 28/ 29)
JBZoo\CIReportConverter\Converters\JUnitConverter
  Methods:  75.00% ( 3/ 4)   Lines:  98.63% ( 72/ 73)
JBZoo\CIReportConverter\Converters\JUnitStatsTcConverter
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% ( 11/ 11)
JBZoo\CIReportConverter\Converters\Map
  Methods:  66.67% ( 4/ 6)   Lines:  86.49% ( 32/ 37)
JBZoo\CIReportConverter\Converters\PhpDependStatsTcConverter
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  7/  7)
JBZoo\CIReportConverter\Converters\PhpLocStatsTcConverter
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  2/  2)
JBZoo\CIReportConverter\Converters\PhpMdJsonConverter
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 45/ 45)
JBZoo\CIReportConverter\Converters\PhpMetricsStatsTcConverter
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  7/  7)
JBZoo\CIReportConverter\Converters\PhpMndConverter
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 47/ 47)
JBZoo\CIReportConverter\Converters\PhpUnitCloverStatsTcConverter
  Methods:   0.00% ( 0/ 2)   Lines:  93.62% ( 44/ 47)
JBZoo\CIReportConverter\Converters\PlainTextConverter
  Methods:  66.67% ( 2/ 3)   Lines:  96.55% ( 28/ 29)
JBZoo\CIReportConverter\Converters\PmdCpdConverter
  Methods:  88.89% ( 8/ 9)   Lines:  98.44% ( 63/ 64)
JBZoo\CIReportConverter\Converters\PsalmJsonConverter
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 35/ 35)
JBZoo\CIReportConverter\Converters\TeamCityInspectionsConverter
  Methods:  50.00% ( 2/ 4)   Lines:  96.36% ( 53/ 55)
JBZoo\CIReportConverter\Converters\TeamCityTestsConverter
  Methods:  50.00% ( 2/ 4)   Lines:  95.92% ( 47/ 49)
JBZoo\CIReportConverter\Exception
  Methods:  ( 0/ 0)   Lines:  (  0/  0)
JBZoo\CIReportConverter\Formats\AbstractNode
  Methods:  66.67% ( 2/ 3)   Lines:  95.45% ( 21/ 22)
JBZoo\CIReportConverter\Formats\Exception
  Methods:  ( 0/ 0)   Lines:  (  0/  0)
JBZoo\CIReportConverter\Formats\GitLabJson\GitLabJson
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% (  7/  7)
JBZoo\CIReportConverter\Formats\GitLabJson\GitLabJsonCase
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 15/ 15)
JBZoo\CIReportConverter\Formats\GithubActions\GithubActions
  Methods:  75.00% ( 3/ 4)   Lines:  95.45% ( 21/ 22)
JBZoo\CIReportConverter\Formats\GithubActions\GithubCase
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 14/ 14)
JBZoo\CIReportConverter\Formats\GithubActions\GithubSuite
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% (  7/  7)
JBZoo\CIReportConverter\Formats\JUnit\CaseOutput\AbstractOutput
  Methods:  75.00% ( 3/ 4)   Lines:  86.67% ( 13/ 15)
JBZoo\CIReportConverter\Formats\JUnit\CaseOutput\Error
  Methods:  ( 0/ 0)   Lines:  (  0/  0)
JBZoo\CIReportConverter\Formats\JUnit\CaseOutput\Failure
  Methods:  ( 0/ 0)   Lines:  (  0/  0)
JBZoo\CIReportConverter\Formats\JUnit\CaseOutput\Skipped
  Methods:  ( 0/ 0)   Lines:  (  0/  0)
JBZoo\CIReportConverter\Formats\JUnit\CaseOutput\SystemOut
  Methods:  ( 0/ 0)   Lines:  (  0/  0)
JBZoo\CIReportConverter\Formats\JUnit\CaseOutput\Warning
  Methods:  ( 0/ 0)   Lines:  (  0/  0)
JBZoo\CIReportConverter\Formats\JUnit\Exception
  Methods:  ( 0/ 0)   Lines:  (  0/  0)
JBZoo\CIReportConverter\Formats\JUnit\JUnit
  Methods: 100.00% ( 3/ 3)   Lines: 100.00% ( 10/ 10)
JBZoo\CIReportConverter\Formats\JUnit\JUnitCase
  Methods:  91.67% (11/12)   Lines:  97.14% ( 34/ 35)
JBZoo\CIReportConverter\Formats\JUnit\JUnitSuite
  Methods: 100.00% (10/10)   Lines: 100.00% ( 94/ 94)
JBZoo\CIReportConverter\Formats\MetricMaps\AbstractMetricMap
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% (  2/  2)
JBZoo\CIReportConverter\Formats\MetricMaps\JUnit
  Methods:  ( 0/ 0)   Lines:  (  0/  0)
JBZoo\CIReportConverter\Formats\MetricMaps\PhpDepend
  Methods:  ( 0/ 0)   Lines:  (  0/  0)
JBZoo\CIReportConverter\Formats\MetricMaps\PhpLoc
  Methods:  ( 0/ 0)   Lines:  (  0/  0)
JBZoo\CIReportConverter\Formats\MetricMaps\PhpMetrics
  Methods:  ( 0/ 0)   Lines:  (  0/  0)
JBZoo\CIReportConverter\Formats\MetricMaps\PhpUnitClover
  Methods:  ( 0/ 0)   Lines:  (  0/  0)
JBZoo\CIReportConverter\Formats\Metric\Metric
  Methods:  ( 0/ 0)   Lines:  (  0/  0)
JBZoo\CIReportConverter\Formats\Metric\Metrics
  Methods:  25.00% ( 1/ 4)   Lines:  75.76% ( 25/ 33)
JBZoo\CIReportConverter\Formats\PlainText\PlainTable
  Methods:  75.00% ( 3/ 4)   Lines:  95.45% ( 21/ 22)
JBZoo\CIReportConverter\Formats\PlainText\PlainText
  Methods: 100.00% ( 3/ 3)   Lines: 100.00% ( 24/ 24)
JBZoo\CIReportConverter\Formats\PlainText\PlainTextCase
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  5/  5)
JBZoo\CIReportConverter\Formats\PlainText\PlainTextSuite
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 19/ 19)
JBZoo\CIReportConverter\Formats\Source\Exception
  Methods:  ( 0/ 0)   Lines:  (  0/  0)
JBZoo\CIReportConverter\Formats\Source\FileRef
  Methods:   0.00% ( 0/ 2)   Lines:   0.00% (  0/  8)
JBZoo\CIReportConverter\Formats\Source\SourceCase
  Methods:  75.00% ( 6/ 8)   Lines:  83.33% ( 30/ 36)
JBZoo\CIReportConverter\Formats\Source\SourceCaseOutput
  Methods: 100.00% ( 3/ 3)   Lines: 100.00% ( 41/ 41)
JBZoo\CIReportConverter\Formats\Source\SourceSuite
  Methods:  92.86% (13/14)   Lines:  98.65% ( 73/ 74)
JBZoo\CIReportConverter\Formats\TeamCity\Exception
  Methods:  ( 0/ 0)   Lines:  (  0/  0)
JBZoo\CIReportConverter\Formats\TeamCity\Helper
  Methods:  25.00% ( 1/ 4)   Lines:  83.33% ( 30/ 36)
JBZoo\CIReportConverter\Formats\TeamCity\TeamCity
  Methods:  84.62% (11/13)   Lines:  96.88% ( 62/ 64)
JBZoo\CIReportConverter\Formats\TeamCity\Writers\Buffer
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% (  2/  2)
JBZoo\CIReportConverter\Formats\TeamCity\Writers\CustomCallback
  Methods:   0.00% ( 0/ 2)   Lines:   0.00% (  0/  4)
JBZoo\CIReportConverter\Formats\TeamCity\Writers\Exception
  Methods:  ( 0/ 0)   Lines:  (  0/  0)
JBZoo\CIReportConverter\Formats\TeamCity\Writers\Stdout
  Methods:   0.00% ( 0/ 1)   Lines:   0.00% (  0/  2)
JBZoo\CIReportConverter\Formats\TeamCity\Writers\SymfonyConsole
  Methods:   0.00% ( 0/ 2)   Lines:   0.00% (  0/  5)
JBZoo\CIReportConverter\Formats\Xml
  Methods:  66.67% ( 2/ 3)   Lines:  97.96% ( 48/ 49)
JBZoo\CIReportConverter\Helper
  Methods:   0.00% ( 0/ 1)   Lines:  75.00% (  3/  4)
make[2]: *** [/shared/backups/forks/CI-Report-Converter/vendor/jbzoo/codestyle/src/Makefiles/03_tests.Makefile:43: test-phpunit-local] Error 2
make[2]: Leaving directory '/shared/backups/forks/CI-Report-Converter'
make[1]: *** [/shared/backups/forks/CI-Report-Converter/vendor/jbzoo/codestyle/src/Makefiles/03_tests.Makefile:21: test-phpunit] Error 2
make[1]: Leaving directory '/shared/backups/forks/CI-Report-Converter'
make: *** [/shared/backups/forks/CI-Report-Converter/vendor/jbzoo/codestyle/src/Makefiles/03_tests.Makefile:17: test] Error 2

Exception messages renders (cosmetic fix)

Hello,

While trying to implement a new converter, I've noticed that Exceptions render an unecessary slash (in my opinion).

Before patch :

Exception_1

After patch :

Exception_2

Patch :

diff --git a/src/Converters/AbstractConverter.php b/src/Converters/AbstractConverter.php
index 5b536da..d2a69aa 100644
--- a/src/Converters/AbstractConverter.php
+++ b/src/Converters/AbstractConverter.php
@@ -36,7 +36,7 @@ abstract class AbstractConverter
      */
     public function toInternal(string $source): SourceSuite
     {
-        throw new Exception('Method \"' . __METHOD__ . '\" is not available');
+        throw new Exception('Method "' . __METHOD__ . '" is not available');
     }

     /**
@@ -45,7 +45,7 @@ abstract class AbstractConverter
      */
     public function fromInternal(SourceSuite $sourceSuite): string
     {
-        throw new Exception('Method \"' . __METHOD__ . '\" is not available');
+        throw new Exception('Method "' . __METHOD__ . '" is not available');
     }

     public function setRootPath(string $rootPath): self

Question about new Converter (Format)

Hello @SmetDenis

As I've already said, I'm working on a new SARIF Converter for your project.

Even if the POC is already available, I've a little question about your project.

Did you think to open your API to add external converter without to embed it in your kernel code ?

BTW, I've noticed that PHPMD converter lose information details about violation that is not easy to retrieve/reuse by other converter later.

On my POC, I've modified the SourceCase class to store extra info (violation data structure)

diff --git a/src/Formats/Source/SourceCase.php b/src/Formats/Source/SourceCase.php
index 641a52f..b702e3c 100644
--- a/src/Formats/Source/SourceCase.php
+++ b/src/Formats/Source/SourceCase.php
@@ -17,6 +17,7 @@ declare(strict_types=1);
 namespace JBZoo\CIReportConverter\Formats\Source;

 use JBZoo\CIReportConverter\Formats\AbstractNode;
+use JBZoo\Data\Data;

 final class SourceCase extends AbstractNode
 {
@@ -27,6 +28,8 @@ final class SourceCase extends AbstractNode
     public ?int    $line      = null;
     public ?int    $column    = null;

+    public Data    $violation;
+
     // Output
     public ?string $stdOut = null;
     public ?string $errOut = null;

Could you explain why you split / re-implement for each format a *Case.php and *Suite.php.
I've not follow it and my SARIF converter is only 130 lines of code (of course with help of my project https://github.com/llaville/sarif-php-sdk)

Oh, FYI, here is a preview of what my POC is able to do on PHPMD

Command invoked

phpmd vendor/povils/phpmnd/src/ json unusedcode | ./ci-report-converter convert -S phpmd-json -T sarif --profile -vv

Gave somethink like this

PHPMD report converted to SARIF
{
    "$schema": "https://json.schemastore.org/sarif-2.1.0.json",
    "version": "2.1.0",
    "runs": [
        {
            "tool": {
                "driver": {
                    "name": "PHPmd",
                    "rules": [
                        {
                            "id": "UnusedPrivateMethod",
                            "defaultConfiguration": {
                                "enabled": true,
                                "level": "error"
                            },
                            "properties": {
                                "ruleSet": "Unused Code Rules"
                            }
                        },
                        {
                            "id": "UnusedFormalParameter",
                            "defaultConfiguration": {
                                "enabled": true,
                                "level": "error"
                            },
                            "properties": {
                                "ruleSet": "Unused Code Rules"
                            }
                        }
                    ]
                }
            },
            "originalUriBaseIds": {
                "SRCROOT": {
                    "uriBaseId": "/shared/backups/forks/CI-Report-Converter"
                }
            },
            "logicalLocations": [
                {
                    "name": "castToNumber",
                    "fullyQualifiedName": "Povils\\PHPMND\\Command\\RunCommand->castToNumber()",
                    "kind": "function"
                },
                {
                    "name": "Povils\\PHPMND\\Command",
                    "kind": "namespace"
                },
                {
                    "name": "getParser",
                    "fullyQualifiedName": "Povils\\PHPMND\\Container->getParser()",
                    "kind": "function"
                },
                {
                    "name": "Povils\\PHPMND",
                    "kind": "namespace"
                },
                {
                    "name": "getLexer",
                    "fullyQualifiedName": "Povils\\PHPMND\\Container->getLexer()",
                    "kind": "function"
                },
                {
                    "name": "Povils\\PHPMND",
                    "kind": "namespace"
                }
            ],
            "results": [
                {
                    "message": {
                        "text": "Avoid unused private methods such as 'castToNumber'."
                    },
                    "ruleId": "UnusedPrivateMethod",
                    "locations": [
                        {
                            "physicalLocation": {
                                "artifactLocation": {
                                    "uri": "vendor/povils/phpmnd/src/Command/RunCommand.php",
                                    "uriBaseId": "SRCROOT"
                                },
                                "region": {
                                    "startLine": 254
                                }
                            }
                        }
                    ]
                },
                {
                    "message": {
                        "text": "Avoid unused private methods such as 'getParser'."
                    },
                    "ruleId": "UnusedPrivateMethod",
                    "locations": [
                        {
                            "physicalLocation": {
                                "artifactLocation": {
                                    "uri": "vendor/povils/phpmnd/src/Container.php",
                                    "uriBaseId": "SRCROOT"
                                },
                                "region": {
                                    "startLine": 57
                                }
                            }
                        }
                    ]
                },
                {
                    "message": {
                        "text": "Avoid unused private methods such as 'getLexer'."
                    },
                    "ruleId": "UnusedPrivateMethod",
                    "locations": [
                        {
                            "physicalLocation": {
                                "artifactLocation": {
                                    "uri": "vendor/povils/phpmnd/src/Container.php",
                                    "uriBaseId": "SRCROOT"
                                },
                                "region": {
                                    "startLine": 62
                                }
                            }
                        }
                    ]
                },
                {
                    "message": {
                        "text": "Avoid unused parameters such as '$nodes'."
                    },
                    "ruleId": "UnusedFormalParameter",
                    "locations": [
                        {
                            "physicalLocation": {
                                "artifactLocation": {
                                    "uri": "vendor/povils/phpmnd/src/PhpParser/Visitor/DetectionVisitor.php",
                                    "uriBaseId": "SRCROOT"
                                },
                                "region": {
                                    "startLine": 26
                                }
                            }
                        }
                    ]
                },
                {
                    "message": {
                        "text": "Avoid unused parameters such as '$nodes'."
                    },
                    "ruleId": "UnusedFormalParameter",
                    "locations": [
                        {
                            "physicalLocation": {
                                "artifactLocation": {
                                    "uri": "vendor/povils/phpmnd/src/PhpParser/Visitor/ParentConnectorVisitor.php",
                                    "uriBaseId": "SRCROOT"
                                },
                                "region": {
                                    "startLine": 17
                                }
                            }
                        }
                    ]
                },
                {
                    "message": {
                        "text": "Avoid unused parameters such as '$node'."
                    },
                    "ruleId": "UnusedFormalParameter",
                    "locations": [
                        {
                            "physicalLocation": {
                                "artifactLocation": {
                                    "uri": "vendor/povils/phpmnd/src/PhpParser/Visitor/ParentConnectorVisitor.php",
                                    "uriBaseId": "SRCROOT"
                                },
                                "region": {
                                    "startLine": 31
                                }
                            }
                        }
                    ]
                }
            ]
        }
    ]
}

Deprecated error when using `make build`

Hello

When running make build command, I got a deprecated error when using BOX v3 to build the PHAR version on a PHP 8.2 platform.

Please consider to upgrade to BOX v4 !

>>>> >>>> >>>> >>>> >>>> >>>>  Install/Update all 3rd party dependencies
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Generating optimized autoload files
64 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
make[1]: Entering directory '/shared/backups/forks/CI-Report-Converter'
File ./vendor/bin/box.phar not found. Downloading.
Box version 3.16.0@adb282a 2022-02-13 23:54:13 UTC

Box Requirements Checker
========================

> Using PHP 8.2.15
> PHP is using the following php.ini file:
  WARNING: No configuration file (php.ini) used by PHP!

> Checking Box requirements:
  ✔ The application requires the version "^7.4 || ^8.0" or greater.
  ✔ The application requires the extension "zlib".
  ✔ The application requires the extension "phar".
  ✔ The package "nikic/php-parser" requires the extension "tokenizer".
  ✔ The package "phpdocumentor/reflection-docblock" requires the extension "filter".


 [OK] Your system is ready to run the application.



In DumpCompletionCommand.php line 48:

  [ErrorException]
  Using ${var} in strings is deprecated, use {$var} instead


Exception trace:
  at phar:///shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar/vendor/symfony/console/Command/DumpCompletionCommand.php:48
 KevinGH\Box\{closure}() at phar:///shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar/.box/vendor/composer/ClassLoader.php:571
 include() at phar:///shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar/.box/vendor/composer/ClassLoader.php:571
 Composer\Autoload\includeFile() at phar:///shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar/.box/vendor/composer/ClassLoader.php:428
 Composer\Autoload\ClassLoader->loadClass() at phar:///shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar/vendor/symfony/console/Application.php:1092
 Symfony\Component\Console\Application->getDefaultCommands() at phar:///shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar/src/Console/Application.php:83
 KevinGH\Box\Console\Application->getDefaultCommands() at phar:///shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar/vendor/symfony/console/Application.php:1272
 Symfony\Component\Console\Application->init() at phar:///shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar/vendor/symfony/console/Application.php:662
 Symfony\Component\Console\Application->find() at phar:///shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar/vendor/symfony/console/Application.php:259
 Symfony\Component\Console\Application->doRun() at phar:///shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at phar:///shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar/bin/box:52
 require() at /shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar:18


Box Requirements Checker
========================

> Using PHP 8.2.15
> PHP is using the following php.ini file:
  WARNING: No configuration file (php.ini) used by PHP!

> Checking Box requirements:
  .....


 [OK] Your system is ready to run the application.



In DumpCompletionCommand.php line 48:

  [ErrorException]
  Using ${var} in strings is deprecated, use {$var} instead


Exception trace:
  at phar:///shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar/vendor/symfony/console/Command/DumpCompletionCommand.php:48
 KevinGH\Box\{closure}() at phar:///shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar/.box/vendor/composer/ClassLoader.php:571
 include() at phar:///shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar/.box/vendor/composer/ClassLoader.php:571
 Composer\Autoload\includeFile() at phar:///shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar/.box/vendor/composer/ClassLoader.php:428
 Composer\Autoload\ClassLoader->loadClass() at phar:///shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar/vendor/symfony/console/Application.php:1092
 Symfony\Component\Console\Application->getDefaultCommands() at phar:///shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar/src/Console/Application.php:83
 KevinGH\Box\Console\Application->getDefaultCommands() at phar:///shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar/vendor/symfony/console/Application.php:1272
 Symfony\Component\Console\Application->init() at phar:///shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar/vendor/symfony/console/Application.php:662
 Symfony\Component\Console\Application->find() at phar:///shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar/vendor/symfony/console/Application.php:259
 Symfony\Component\Console\Application->doRun() at phar:///shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at phar:///shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar/bin/box:52
 require() at /shared/backups/forks/CI-Report-Converter/vendor/bin/box.phar:18

make[1]: *** [/shared/backups/forks/CI-Report-Converter/vendor/jbzoo/codestyle/src/Makefiles/02_project.Makefile:38: build-phar] Error 1
make[1]: Leaving directory '/shared/backups/forks/CI-Report-Converter'
make: *** [Makefile:22: build] Error 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.