eldy / phpcsfixer-action

A github action to run PHPCS and PHPCBF

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP Code Sniffer GitHub action

Run and fix errors

release GitHub release (latest SemVer)

  • Works on every PHP code base, including WordPress(all rules are bundled).
  • Supports configuration files (phpcs.xml, phpcs.xml.dist, ...).
  • Fixes all fixable errors.

This action runs PHPCS and fix errors using PHPCBF. If the errors are not fixable the job will fail, if they are phpcbf will fix them. The WordPress rulesets are bundled and made available to phpcs. The action supports using PHPCS configuration files if there is a phpcs.xml or other supported file names.

Input

inputs:
  github_token:
    description: 'GITHUB_TOKEN'
    default: '${{ github.token }}'
  workdir:
    description: 'Working directory relative to the root directory.'
    default: '.'
  ### Flags for phpcs-wordpress ###
  phpcs_args:
    description: 'Additional PHPCS flags'
    default: '.'
  phpcbf_args:
    description: 'Additional PHPCBF flags'
    default: '.'
  phpcs_standard:
    description: 'Coding standard for PHPCS to use when checking files'
    default: 'WordPress'
  use_default_configuration_file:
    description: 'Whether to use default configuration file(phpcs.xml) or not'
    default: 'true'

Usage

name: WPCS checker
on: push
jobs:
  linter_name:
    name: runner / phpcs
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: shalior/wordpress-phpcs-action@master
        with:
          github_token: ${{ secrets.github_token }}
          use_default_configuration_file: true
          phpcs_args: '-n' # ignore warnings
      - uses: stefanzweifel/git-auto-commit-action@v4 # auto commit the fixes action for GitHub
        with:
          commit_message: Fix PHPCS errors

PHPCS Coding Standards

The following sniffs are currently available. You can configure the standard(s) used by using the phpcs_standard input setting. By default, WordPress is used.

  • MySource
  • PEAR
  • PHPCompatibility
  • PHPCompatibilityWP
  • PSR1
  • PSR12
  • PSR2
  • Squiz
  • WordPress
  • WordPress-Core
  • Wordpress-Docs
  • WordPress-Extra
  • WordPress-VIP-Go
  • WordPressVIPMinimum
  • Zend
  • (Soon) WooCommerce

This action is based on action-phpcs-wordpress.

About

A github action to run PHPCS and PHPCBF

License:MIT License


Languages

Language:Shell 66.7%Language:Dockerfile 33.3%