php 代码质量检查_代码规范工具 phpcs 质量检查工具 phpmd
// 安装后 将 ~/.composer/vendor/bin/ 添加到 PATH 环境变量中,否则会报命令找不到。
composer global require"squizlabs/php_codesniffer=*"
$ phpcs--help
Usage:phpcs[-nwlsaepqvi][-d key[=value]][--colors][--no-colors]
[--cache[=]][--no-cache][--tab-width=]
[--report=][--report-file=][--report-=
e>]
[--report-width=][--basepath=][--bootstrap=
>]
[--severity=][--error-severity=][--warning-severity=
erity>]
[--runtime-setkey value][--config-setkey value][--config-deletekey][--co
nfig-show]
[--standard=][--sniffs=][--exclude=]
[--encoding=][--parallel=][--generator=]
[--extensions=][--ignore=][--ignore-annotations]
[--stdin-path=][--file-list=]-...
-CheckSTDIN instead of local files and directories
-nDonot print warnings(shortcutfor--warning-severity=0)
-wPrintboth warnings and errors(thisis thedefault)
-lLocaldirectory only,no recursion
-sShowsniff codes in all reports
-aRuninteractively
-eExplaina standard by showing the sniffs it includes
-pShowprogress of the run
-qQuietmode;disables progress and verbose output
-mStoperror messages from being recorded
(saves a lot of memory,but stops many reports from being used)
-vPrintprocessed files
-vvPrintruleset and token output
-vvvPrintsniff processing information
-iShowa list of installed coding standards
-dSetthe[key]php.ini value to[value]or[true]ifvalue is omitted
--helpPrintthishelp message
--versionPrintversion information
--colorsUsecolors in output
--no-colorsDonot use colors in output(thisis thedefault)
--cacheCacheresults between runs
--no-cacheDonot cache results between runs(thisis thedefault)
--ignore-annotationsIgnoreall@codingStandardannotations in code comments
Usea specific fileforcaching(uses a temporary file by defaul
t)
A path to strip from the front of file paths inside reports
A comma separated list of files to run before processing begins
Oneor more files and/or directories to check
A file containing a list of files and/or directories to check(o
ne per line)
Theencoding of the files being checked(defaultis utf-8)
A comma separated list of file extensions to check
(extension filtering only valid when checking a directory)
Thetype of the file can be specified using:ext/type
e.g.,module/php,es/js
Useseither the"HTML","Markdown"or"Text"generator
(forces documentation generation instead of checking)
A comma separated list of patterns to ignore files and directori
es
Howmany files should be checked simultaneously(defaultis1)
Printeither the"full","xml","checkstyle","csv"
"json","junit","emacs","source","summary","diff"
"svnblame","gitblame","hgblame"or"notifysend"report
(the"full"report is printed bydefault)
Writethe report to the specified file path
Howmany columns wide screen reports should be printed
orsetto"auto"to use current screen width,where supported
Theminimum severity required to display an error or warning
A comma separated list of sniff codes to include or exclude from
checking
(all sniffs must be part of the specified standard)
Thename or path of the coding standard to use
Ifprocessing STDIN,the file path that STDIN will be processed
as
Thenumber of spaces each tab represents
$ phpcs-i
Theinstalled coding standards areMySource,PEAR,PSR1,PSR2,SquizandZend
$ phpcs--report=summary downloadexcel.php
PHP CODE SNIFFER REPORT SUMMARY
--------------------------------------------------------------------------------
FILE ERRORS WARNINGS
--------------------------------------------------------------------------------
downloadexcel.php515
--------------------------------------------------------------------------------
A TOTAL OF51ERROR(S)AND5WARNING(S)WERE FOUND IN1FILE(S)
--------------------------------------------------------------------------------
Time:1second,Memory:2.50Mb
$ phpcs downloadexcel.php
FILE:downloadexcel.php
--------------------------------------------------------------------------------
FOUND51ERROR(S)AND5WARNING(S)AFFECTING40LINE(S)
--------------------------------------------------------------------------------
1|ERROR|Endof line character is invalid;expected"\n"but found
||"\r\n"
1|ERROR|Missingfile doc comment
3|WARNING|Lineexceeds85characters;contains153characters
178|WARNING|Lineexceeds85characters;contains115characters
179|ERROR|Doccommentforvar[UNKNOWN]does not match actual variable
||name&$data at position1
179|ERROR|Missingparameter name at position1
179|ERROR|Missingcommentforparam"[ UNKNOWN ]"at position1
179|ERROR|Theremust be exactly one blank line before the tags in
||functioncomment
180|ERROR|Lastparameter comment requires a blank newline after it
180|ERROR|Thevariable namesforparameters UNKNOWN(1)and[UNKNOWN]
||(2)donot align
180|ERROR|Doccommentforvar[UNKNOWN]does not match actual variable
||name $fields at position2
180|ERROR|Missingparameter name at position2
180|ERROR|Missingcommentforparam"[ UNKNOWN ]"at position2
183|ERROR|Openingbrace should be on anewline
186|WARNING|Lineexceeds85characters;contains142characters
187|ERROR|Openingparenthesis of a multi-linefunctioncall must be the
||last content on the line
190|ERROR|Expected"if (...) {\n";found"if(...){\n"
190|ERROR|Theremust be a single space between the closing parenthesis
||and the opening brace of a multi-line IF statement;found0
||spaces
192|ERROR|Expected"} else {\n";found"}else{\n"
207|ERROR|Closingparenthesis of a multi-linefunctioncall must be on a
||line by itself
210|ERROR|Spacesmust be used to indent lines;tabs are not allowed
210|ERROR|Doccommentfor"$filename"missing
212|ERROR|Missing@returntag infunctioncomment
213|ERROR|Functionname"export_csv"is prefixedwitha package name but
||does not beginwitha capital letter
213|ERROR|Lineindented incorrectly;expected0spaces,found4
225|ERROR|Spacesmust be used to indent lines;tabs are not allowed
226|ERROR|Spacesmust be used to indent lines;tabs are not allowed
226|ERROR|Lineindented incorrectly;expected0spaces,found2
227|ERROR|Spacesmust be used to indent lines;tabs are not allowed
228|ERROR|Closingbrace indented incorrectly;expected2spaces,found8
229|ERROR|Lineindented incorrectly;expected0spaces,found8
232|ERROR|Lineindented incorrectly;expected4spaces,found12
233|ERROR|Lineindented incorrectly;expected8spaces,found16
234|WARNING|Lineexceeds85characters;contains148characters
237|ERROR|Lineindented incorrectly;expected4spaces,found12
243|ERROR|Lineindented incorrectly;expected0spaces,found8
247|ERROR|Lineindented incorrectly;expected0spaces,found8
248|ERROR|Lineindented incorrectly;expected4spaces,found12
250|ERROR|Lineindented incorrectly;expected8spaces,found16
252|ERROR|Lineindented incorrectly;expected8spaces,found16
258|ERROR|Lineindented incorrectly;expected0spaces,found8
265|ERROR|Lineindented incorrectly;expected0spaces,found8
266|ERROR|Expected"if (...) {\n";found"if(...){\n"
266|ERROR|Lineindented incorrectly;expected4spaces,found12
266|ERROR|Theremust be a single space between the closing parenthesis
||and the opening brace of a multi-line IF statement;found0
||spaces
269|WARNING|Lineexceeds85characters;contains94characters
270|ERROR|Lineindented incorrectly;expected4spaces,found12
271|ERROR|Lineindented incorrectly;expected8spaces,found16
272|ERROR|Lineindented incorrectly;expected12spaces,found20
274|ERROR|Expected"} elseif (...) {\n";found"} elseif(...) {\n"
274|ERROR|Lineindented incorrectly;expected12spaces,found20
277|ERROR|Lineindented incorrectly;expected8spaces,found16
279|ERROR|Nospace found after comma infunctioncall
281|ERROR|Lineindented incorrectly;expected8spaces,found16
285|ERROR|Nospace found after comma infunctioncall
285|ERROR|Nospace found after comma infunctioncall
--------------------------------------------------------------------------------
Time:1second,Memory:2.50Mb
// phpcbf downloadexcel.php 直接覆盖原文件,可以使用 --suffix 指定修复后的代码后缀,生成文件 downloadexcel.php.fixed
$ phpcbf downloadexcel.php--suffix=.fixed
PHPCBF RESULT SUMMARY
----------------------------------------------------------------------
FILE FIXED REMAINING
----------------------------------------------------------------------
downloadexcel.php5716
----------------------------------------------------------------------
A TOTAL OF57ERRORS WERE FIXED IN1FILE
----------------------------------------------------------------------
Time:5.36secs;Memory:5Mbhttps://github.com/overtrue/phpmd-rulesets
phpcs/path/to/code--suffix=.fixed
php 代码质量检查_代码规范工具 phpcs 质量检查工具 phpmd相关推荐
- python 代码分块_[代码全屏查看]-python多进程分块读取文件
[1].[代码] [Python]代码 # -*- coding: GBK -*- import urlparse import datetime import os from multiproces ...
- python优雅代码大全_代码这样写更优雅(Python版)
Python 这门语言最大的优点之一就是语法简洁,好的代码就像伪代码一样,干净.整洁.一目了然.但有时候我们写代码,特别是 Python 初学者,往往还是按照其它语言的思维习惯来写,那样的写法不仅运行 ...
- java代码雨_代码雨 - java代码库 - 云代码
[java]代码库import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; ...
- java 代码结构_代码结构说明
代码结构说明 === ## 一.JEECG目录结构 ### 1.配置文件目录结构 JEECG中的配置文件目录结构如图3-1所示. ![输入图片说明](https://static.oschina.ne ...
- java lock代码写法_[代码全屏查看]-java lock的使用
[1].[代码] [Java]代码 package boom; import java.util.concurrent.TimeUnit; import java.util.concurrent.lo ...
- python游戏代码示例_代码实例1:python 小人打架游戏
中断了几年的python学习最近被重新拾起来了,实在是因为工作上需要用到的地方太多.不立flag了,记录学习成果,慢慢更新吧. 小人打架程序代码如下: ------------------------ ...
- 游戏脚本代码大全_代码与程序的关系是这样的
很多人都明白代码的意思,但真正的含义还不是太理解,那么专业的代码解释是什么呢?其实它就是服务器所解析的语言,也就是说服务器将代码翻译成源代码. 代码也可以看成是程序的片段,代码可能只有一行,也有可能有 ...
- c++ doxygen 注释规范_[代码规范]Go语言编码规范指导
本规范旨在为日常Go项目开发提供一个代码的规范指导,方便团队形成一个统一的代码风格,提高代码的可读性,规范性和统一性.本规范将从命名规范,注释规范,代码风格和 Go 语言提供的常用的工具这几个方面做一 ...
- idea,配置checkstyle 【提高代码质量,检查代码规范的工具 】Checkstyle,FindBugs,PMD,Jtest
idea,配置checkstyle [提高代码质量,检查代码规范的工具 ]Checkstyle,FindBugs,PMD,Jtest 2016年12月15日 14:19:02 common_util ...
最新文章
- 【248】◀▶IEW-Unit13
- theano 安装杂记
- 演化:这五年里,我们对架构师职责的思考与定位
- 如何让智能客服成为企业的生产力工具?
- linux下source命令使用详解
- xcode开发php,xcode怎么编写c语言
- 《赢在中国》第二赛季108将进京
- java读取properties文件详解
- rethat安装MySQL多例_SSM 使用 mybatis 分页插件 pagehepler 实现分页
- O_NONBLOCK与O_NDELAY有何不同?
- 前端页面怎么办啊一条长的信息换行展示_前端入门!不容错过!HTML基本标签知识大盘点...
- 蒲公英联机平台的服务器虚拟IP,蒲公英客户端如何使用固定虚拟IP管理虚拟局域网的步骤是什么?...
- Latex符号与公式集合
- mysql 数据入库去重_MySQL中去重 distinct 的用法 ,数据库去重distinct
- 金蝶K3供应链单据套打设置(以采购订单为例)
- 阿里云ACE认证学习知识点梳理
- 使用国内镜像安装pyqt5
- 【榜单公布】10·24征文活动结果出炉!
- 大象知道“故事怎么讲”
- Sedona NetFusion 在OIF/ONF T-API 互通测试中扮演关键角色