Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Code Climate Engine for PHP Code Sniffer

License

NotificationsYou must be signed in to change notification settings

codeclimate/codeclimate-phpcodesniffer

 
 

Repository files navigation

Code Climate

codeclimate-phpcodesniffer is a Code Climate engine that wraps thePHP_Code Sniffer static analysis tool. You can run it on your command line using the Code Climate CLI, or on our hosted analysis platform.

PHP_CodeSniffer helps you detect violations of a defined coding standard.

Installation

  1. If you haven't already,install the Code Climate CLI.
  2. Runcodeclimate engines:enable phpcodesniffer. This command both installs the engine and enables it in your.codeclimate.yml file.
  3. You're ready to analyze! Browse into your project's folder and runcodeclimate analyze.

Config Options

Format the values for these config options per thePHP_CodeSniffer documentation.

  • file_extensions - This is where you can configure the file extensions for the files that you want PHP_CodeSniffer to analyze.
  • standard - This is the comma delimited list of standards that you wantPHP_CodeSniffer to use while analyzing your files. You may optionally includea relative path to a custom phpcs ruleset.xml file.
  • ignore_warnings - You can hide warnings, and only report errors with this option.
  • encoding - By default, PHPCS uses ISO-8859-1. Use this to change it to your encoding, e.g. UTF-8.

Sample Config

exclude_paths: - "/examples/**/*"engines:  phpcodesniffer:    enabled: true    config:      file_extensions: "php,inc,lib"      standard: "PSR1,PSR2,my_custom_php_ruleset.xml"      ignore_warnings: true      encoding: utf-8ratings:  paths:  - "**.php"

Supported Coding Standards

In addition to standards provided bydefault with PHP_CodeSniffer, theDrupal,WordPress,Yii2, andMagento Extension coding standards are supported. Here is the full list:

  • Drupal
  • DrupalPractice
  • MEQP1
  • MEQP2
  • MySource
  • PEAR
  • PHPCS
  • PSR1
  • PSR2
  • Squiz
  • WordPress
  • WordPress-Core
  • WordPress-Docs
  • WordPress-Extra
  • WordPress-VIP
  • Yii2
  • Zend

  • To use the PSR12 standard, you'll need to specify thebeta channel in your .codeclimate.yml:
plugins:   phpcodesniffer:    enabled: true    channel: beta    config:        standard: "PSR12"

Need help?

For help with PHP_CodeSniffer,check out their documentation.

If you're running into a Code Climate issue, first look over this project'sGitHub Issues, as your question may have already been covered. If not,go ahead and open a support ticket with us.


[8]ページ先頭

©2009-2025 Movatter.jp