Skip to content

Add phpcs code standard checks. #17

@serundeputy

Description

@serundeputy

@docwilmot in backdrop/backdrop-issues#659 (comment) you mentioned getting code standards checks on contrib.

I use phpcs in backdrop/coder for drush and headless modules. Here is how:

Add a .travis.yml file similar to this:

language: php
dist: xenial
php:
  - 7.2
cache:
  directories:
    - $HOME/.composer/cache/files
    - $HOME/.composer/cache/repo
services:
  - mysql
addons:
  - mariadb: '10.0'
before_install:
  - composer install

script:
  # Check code standards
  - vendor/bin/phpcs -n --standard=vendor/backdrop/coder/coder_sniffer/Backdrop --ignore="vendor/*,README.md" --extensions=install,module,php,inc,theme .

  # Unit tests

You can either include a composer.json file in the root of your repo (this has the added benefit of having your module available on packagist.org for users to discover and manage backdrop modules) or you can add the composer require --dev backdrop/coder into the .travis.yml file.

Then allow travisCI access to the repo. I'd encourage you to add this code checking to all the modules you maintain and perhaps we (you, I, @klonos anyone who is interested) could lead a campaign making PRs against contrib projects giving them the infra to have code checking on there module(s).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions