{"id":15008344,"url":"https://github.com/123inkt/phpunit-file-coverage-inspection","last_synced_at":"2025-06-24T08:35:34.192Z","repository":{"id":38060207,"uuid":"291923398","full_name":"123inkt/phpunit-file-coverage-inspection","owner":"123inkt","description":"Configurable phpunit coverage inspection tool. Allow per file coverage inspections.","archived":false,"fork":false,"pushed_at":"2025-02-21T19:50:21.000Z","size":258,"stargazers_count":5,"open_issues_count":3,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T16:04:46.685Z","etag":null,"topics":["automation","coding-standards","coverage","php","phpunit","test","testing-tools"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/123inkt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-01T07:07:25.000Z","updated_at":"2025-02-21T19:50:03.000Z","dependencies_parsed_at":"2024-05-20T20:32:50.305Z","dependency_job_id":"312913b2-269c-4861-a435-2be3bc384930","html_url":"https://github.com/123inkt/phpunit-file-coverage-inspection","commit_stats":{"total_commits":111,"total_committers":6,"mean_commits":18.5,"dds":"0.33333333333333337","last_synced_commit":"43be471f823dde25c524aec4bb4d19c69a1e6905"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/123inkt%2Fphpunit-file-coverage-inspection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/123inkt%2Fphpunit-file-coverage-inspection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/123inkt%2Fphpunit-file-coverage-inspection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/123inkt%2Fphpunit-file-coverage-inspection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/123inkt","download_url":"https://codeload.github.com/123inkt/phpunit-file-coverage-inspection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065289,"owners_count":21041871,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","coding-standards","coverage","php","phpunit","test","testing-tools"],"created_at":"2024-09-24T19:17:43.393Z","updated_at":"2025-04-09T16:04:57.665Z","avatar_url":"https://github.com/123inkt.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.1-8892BF)](https://php.net/)\n![Run tests](https://github.com/123inkt/phpunit-file-coverage-inspection/actions/workflows/test.yml/badge.svg)\n\n# PHPUnit coverage inspection\nA tool to allow code coverage rules be defined per file. Set a minimum coverage threshold for every file and configure\ncustom minimum coverage for existing files if the current test coverage is not up to standards yet. \nInspection failure will be output in checkstyle format, allowing it to be imported in ci/cd tools.\n\n## Use case\nStandard coverage calculation is calculated over the whole codebase. If for example the threshold is 80% and one file drops\nbelow 80% you never notice this because the overall coverage went from 87.6% to 87.4%.\nThis package makes sure that that doesn't happen anymore and coverage is calculated on a per-file basis. \n\n## Supported formats\n* Input: clover coverage.xml\n* Output: checkstyle or gitlab\n\n## Installation\nInclude the library as dependency in your own project via: \n```\ncomposer require \"digitalrevolution/phpunit-file-coverage-inspection\" --dev\n```\n\n## Configuration\n\nFile: `phpfci.xml`\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cphpfci xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n        xsi:noNamespaceSchemaLocation=\"vendor/digitalrevolution/phpunit-file-coverage-inspection/resources/phpfci.xsd\"\n        min-coverage=\"100\"\n        allow-uncovered-methods=\"false\"\n\u003e\n    \u003ccustom-coverage\u003e\n        \u003c!-- directory based coverage rule --\u003e\n        \u003cdirectory path=\"src/Lib/\" min=\"90\"/\u003e\n        \u003c!-- subdirectories will superceed a parent directory rule --\u003e\n        \u003cdirectory path=\"src/Lib/Config/\" min=\"100\"/\u003e\n        \u003c!-- file rule will always superceed a directory rule --\u003e\n        \u003cfile path=\"src/Lib/Config/File.php\" min=\"80\"/\u003e\n    \u003c/custom-coverage\u003e\n    \n    \u003c!-- when 'allow-uncovered-methods' is set to false, override this behaviour for specific files: --\u003e\n    \u003cignore-uncovered-methods\u003e\n        \u003cfile path=\"src/Command/ExampleCommand.php\"/\u003e\n    \u003c/ignore-uncovered-methods\u003e\n\u003c/phpfci\u003e\n```\n\n| Option                  | Required | Default  | Description                                   |\n|-------------------------|----------|----------|-----------------------------------------------|\n| min-coverage            | yes      | -        | The minimum global coverage                   |\n| allow-uncovered-methods | no       | false    | All methods should have atleast some coverage | \n\n\nor generate a config file based on existing coverage results\n\n```shell script\nphp vendor/bin/phpfci baseline coverage.xml --config ./phpfci.xml --baseDir /home/ci/workspace\nphp vendor/bin/phpfci baseline coverage1.xml coverage2.xml --config ./phpfci.xml --baseDir /home/ci/workspace\n```\n\nThe base directory will be subtracted from the filepaths in coverage.xml\n\n## Usage\n\nCheckstyle format:\n```shell script\nphp vendor/bin/phpfci inspect coverage.xml --reportCheckstyle=reports/checkstyle.xml\n```\n\nGitlab format:\n```shell script\nphp vendor/bin/phpfci inspect coverage.xml --reportGitlab=reports/gitlab.errors.json\n```\n\nGitlab format to file and text output to stdout:\n```shell script\nphp vendor/bin/phpfci inspect coverage.xml --reportGitlab=reports/gitlab.errors.json --reportText\n```\n\nText format to stdout:\n```shell script\nphp vendor/bin/phpfci inspect coverage.xml\nphp vendor/bin/phpfci inspect coverage1.xml coverage2.xml\n```\n```shell script\nphp vendor/bin/phpfci inspect coverage.xml --reportText\n```\n\n## Command line arguments\n\n| Option                         | Values                                   | Description                                                             |\n|--------------------------------|------------------------------------------|-------------------------------------------------------------------------| \n| `argument 1`                   | `inspect`, `baseline`                    | the command to execute.                                                 |\n| `argument 2` [`argument 3`]... | `coverage.xml` [`coverage2.xml`]         | the phpunit clover coverage input file(s).                              |\n| `--reportGitlab=[\u003cfile\u003e]`      | filepath or if absent stdout             | the file (or stdout) to write the gitlab format to.                     |\n| `--reportCheckstyle=[\u003cfile\u003e]`  | filepath or if absent stdout             | the file (or stdout) to write the checkstyle format to.                 |\n| `--reportText=[\u003cfile\u003e]`        | filepath or if absent stdout             | the file (or stdout) to write the checkstyle format to.                 |\n| `--config=\u003cpath-to-file\u003e`      | `phpfci.xml`                             | the path to the config file.                                            |\n| `--baseDir=\u003cpath\u003e`             | defaults to directory of the output file | The root directory of the project, will be used to make paths relative. |\n| `--exit-code-on-failure`       | -                                        | Set exit code to `1` when there are failures.                           |\n\nNote: if no `--reportGitlab`, `--reportCheckstyle` or `--reportText` is set, it will default to `--reportText=php://stdout`\n\n## Migrating from 1 to 2\nThe third required argument and `--report` has been removed, and should be replaced by:\n`--reportGitlab=\u003cfile\u003e`, `--reportCheckstyle=\u003cfile\u003e` or `--reportText=\u003cfile\u003e` \n\n# Migrating from 2 to 3\nThe baseline now also supports multiple coverage files, as the inspect command.\nAn error is also raised if the baseline custom entry doesn't match the coverage.\n\n## About us\n\nAt 123inkt (Part of Digital Revolution B.V.), every day more than 50 development professionals are working on improving our internal ERP \nand our several shops. Do you want to join us? [We are looking for developers](https://www.werkenbij123inkt.nl/zoek-op-afdeling/it).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F123inkt%2Fphpunit-file-coverage-inspection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F123inkt%2Fphpunit-file-coverage-inspection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F123inkt%2Fphpunit-file-coverage-inspection/lists"}