Search code examples
github-pagesphpcodesniffer

Code Consistency badge for packages using PHP_CodeSniffer


The PHP_CodeSniffer Github page has a very nice Code Consistency badge.

image link

Clicking the badge takes you to a breakdown of the analysis for the ranking reported by the badge. You can also see the analysis of many packages.

I would like to include a Code Consistency badge in my own projects.

I can not find any details for how this is achieved. Perhaps it's not something that is available to any packages?


Solution

  • I add projects manually to that analysis site, but you can suggest a PHP project to add by opening an issue on the PHP_CodeSniffer Github project. It must be hosted on Github though, and be public.

    The information I need is pretty basic. You can view the list of current projects, and their settings, here: https://github.com/squizlabs/PHP_CodeSniffer/blob/gh-pages/analysis/_assets/repos.json

    The settings are:

    • Name: The friendly name of your project
    • URL: The Github path to your project
    • Path: The path inside your project to check (most use either the root, or src if your root has a bunch of files and dirs that should not be checked)
    • Ignore: Any files or directories to ignore, using one of more regexs (if your git clone is going to have code from other projects in it)
    • Extensions: In case you use non-standard extensions, which ones should be checked.

    If you have no idea what the settings should be, you can point me to a Github repo and I can figure it out, as I've done for the vast majority of projects in the report.