2017 © Pedro Peláez
 

library coverage

Sends PHP test coverage information to Codacy.

image

codacy/coverage

Sends PHP test coverage information to Codacy.

  • Monday, April 30, 2018
  • by haffla
  • Repository
  • 17 Watchers
  • 22 Stars
  • 532,135 Installations
  • PHP
  • 379 Dependents
  • 0 Suggesters
  • 17 Forks
  • 0 Open issues
  • 15 Versions
  • 10 % Grown

The README.md

Deprecated

This repository is no longer maintained. As an alternative, check codacy-coverage-reporter to send your test coverage results to your Codacy dashboard., (*1)

Codacy Badge Codacy Badge Circle CI Latest Stable Version, (*2)

Codacy PHP Coverage Reporter

Codacy coverage support for PHP. Get coverage reporting and code analysis for PHP from Codacy., (*3)

Prerequisites

  • PHP 5.3 or later
  • One of the following coverage report formats
    • Clover XML (e.g. --coverage-clover in PHPUnit)
    • [Only for PHPUnit <4] PHPUnit XML (e.g. --coverage-xml in PHPUnit)

Installation

Setup codacy-coverage with Composer, just add the following to your composer.json:, (*4)

// composer.json
{
    "require-dev": {
        "codacy/coverage": "dev-master"
    }
}

Download the dependencies by running Composer in the directory of your composer.json:, (*5)

# install
$ php composer.phar install --dev
# update
$ php composer.phar update codacy/coverage --dev

codacy-coverage library is available on Packagist., (*6)

Add the autoloader to your php script:, (*7)

require_once 'vendor/autoload.php';

Note: We have php5-curl dependency, if you have issues related to curl_init() please install it with:, (*8)

sudo apt-get install php5-curl

Alternative Installation (using phar)

Setup codacy-coverage as phar, you can simply download a pre-compiled and ready-to-use version as a phar to any directory. Simply download the latest codacy-coverage.phar file from our releases page:, (*9)

Latest release, (*10)

That's it already., (*11)

Updating Codacy

To update Codacy, you will need your project API token. You can find the token in Project -> Settings -> Integrations -> Project API., (*12)

Then set it in your terminal, replacing %Project_Token% with your own token:, (*13)

export CODACY_PROJECT_TOKEN=%Project_Token%

Note: You should keep your API token well protected, as it grants owner permissions to your projects., (*14)

To send coverage in the enterprise version you should:, (*15)

export CODACY_API_BASE_URL=<Codacy_instance_URL>:16006

Usage

Run vendor/bin/codacycoverage to see a list of commands., (*16)

Basic usage for Clover format:

vendor/bin/codacycoverage clover, (*17)

Basic usage for PHPUnit XML format:

php vendor/bin/codacycoverage phpunit, (*18)

By default we assume that - your Clover coverage report is saved in build/logs/clover.xml - your PHPUnit XML report is saved in the directory build/coverage-xml, (*19)

Optional parameters:

You can specify the path to your report with the second parameter:, (*20)

  • Clover XML
    • php vendor/bin/codacycoverage clover path/to/a-clover.xml
  • PHPUnit XML
    • php vendor/bin/codacycoverage phpunit directory/path/to/phpunitreport

Even more control:, (*21)

  • --base-url=<OTHER_URL> defaults to http://codacy.com
  • --git-commit=<COMMIT_HASH> defaults to the last commit hash

Circle CI

This project sends its own coverage during the build in circleCI. Feel free to check our circle.yml, and send your coverage as a step of your build process., (*22)

Travis CI

Add codacycoverage to your .travis.yml:, (*23)

# .travis.yml
language: php

# Do not forget to provide your CODACY_PROJECT_TOKEN as described in https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings

php:
  - 5.3
  - 5.4
  - 5.5
  - 5.6
  - hhvm

# In case of timeouts and build failures you may want to prepend 'travis_retry' to the following commands:
before_script:
  - curl -s http://getcomposer.org/installer | php
  - php composer.phar install -n

script:
  - php vendor/bin/phpunit --coverage-clover build/coverage/xml

after_script:
  - php vendor/bin/codacycoverage clover build/coverage/xml

Troubleshooting

If you have a fatal error regarding curl_init():, (*24)

PHP Fatal error:  Uncaught Error: Call to undefined function Codacy\Coverage\Util\curl_init() in /src/Codacy/Coverage/Util/CodacyApiClient.php:30

Run: sudo apt-get install php5-curl, (*25)

What is Codacy?

Codacy is an Automated Code Review Tool that monitors your technical debt, helps you improve your code quality, teaches best practices to your developers, and helps you save time in Code Reviews., (*26)

Among Codacy’s features:

  • Identify new Static Analysis issues
  • Commit and Pull Request Analysis with GitHub, BitBucket/Stash, GitLab (and also direct git repositories)
  • Auto-comments on Commits and Pull Requests
  • Integrations with Slack, HipChat, Jira, YouTrack
  • Track issues in Code Style, Security, Error Proneness, Performance, Unused Code and other categories

Codacy also helps keep track of Code Coverage, Code Duplication, and Code Complexity., (*27)

Codacy supports PHP, Python, Ruby, Java, JavaScript, and Scala, among others., (*28)

Free for Open Source

Codacy is free for Open Source projects., (*29)

License

MIT, (*30)

The Versions

30/04 2018

dev-master

9999999-dev https://github.com/codacy/php-codacy-coverage

Sends PHP test coverage information to Codacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jakob Pupke

22/03 2018

1.4.2

1.4.2.0 https://github.com/codacy/php-codacy-coverage

Sends PHP test coverage information to Codacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jakob Pupke

20/12 2017

1.4.1

1.4.1.0 https://github.com/codacy/php-codacy-coverage

Sends PHP test coverage information to Codacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jakob Pupke

28/09 2017

1.4.0

1.4.0.0 https://github.com/codacy/php-codacy-coverage

Sends PHP test coverage information to Codacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jakob Pupke

07/09 2017

1.3.0

1.3.0.0 https://github.com/codacy/php-codacy-coverage

Sends PHP test coverage information to Codacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jakob Pupke

09/08 2017

1.2.0

1.2.0.0 https://github.com/codacy/php-codacy-coverage

Sends PHP test coverage information to Codacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jakob Pupke

09/08 2017

dev-bump-php-version

dev-bump-php-version https://github.com/codacy/php-codacy-coverage

Sends PHP test coverage information to Codacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jakob Pupke

04/04 2017

1.1.0

1.1.0.0 https://github.com/codacy/php-codacy-coverage

Sends PHP test coverage information to Codacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jakob Pupke

07/07 2016

1.0.5

1.0.5.0 https://github.com/codacy/php-codacy-coverage

Sends PHP test coverage information to Codacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jakob Pupke

17/05 2016

dev-update-readme

dev-update-readme https://github.com/codacy/php-codacy-coverage

Sends PHP test coverage information to Codacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jakob Pupke

10/05 2016

1.0.4

1.0.4.0 https://github.com/codacy/php-codacy-coverage

Sends PHP test coverage information to Codacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jakob Pupke

07/01 2016

1.0.3

1.0.3.0 https://github.com/codacy/php-codacy-coverage

Sends PHP test coverage information to Codacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jakob Pupke

17/10 2015

1.0.2

1.0.2.0 https://github.com/codacy/php-codacy-coverage

Sends PHP test coverage information to Codacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jakob Pupke

25/08 2015

1.0.1

1.0.1.0 https://github.com/codacy/php-codacy-coverage

Sends PHP test coverage information to Codacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jakob Pupke

25/08 2015

1.0.0

1.0.0.0 https://github.com/codacy/php-codacy-coverage

Sends PHP test coverage information to Codacy.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jakob Pupke