eonx-com/standards

用于对代码库强制执行EoneoPay编码标准的库

v0.3.2 2020-01-14 02:53 UTC

README

此库提供了检查代码库是否符合EoneoPay编码标准的工具。

安装

此库通过composer安装

composer require --dev eonx-com/standards dev-master

要求

此库至少需要PHP 5.6。

兼容工具

如果系统上找到以下包,此库将自动运行。它们可以通过composer安装或全局可用,例如通过brew安装。

推荐扩展

建议您还安装以下PHP扩展。

检查您的代码库

您可以直接从vendor目录运行es来检查您的代码库,任何已安装的包都将自动运行。

bash vendor/bin/es

默认情况下,将检查您应用程序或库的app/src/tests/目录中的任何php文件。如果使用变更检测,将尽可能执行部分扫描。

强制进行全面扫描

您可能希望在执行变更检测的同时运行全面扫描。您可以通过传递-f标志来强制进行全面扫描。

bash vendor/bin/es -f

运行详细扫描

您可能希望运行一个显示所有操作及其结果的扫描。您可以通过传递-v标志来强制进行详细扫描。

bash vendor/bin/es -v

配置

您可以通过向应用程序或库的根目录添加standards.cfg文件并调整以下变量来微调配置。

# Comma separated paths to files to check, absolute or relative to working directory
PATHS=app,src,tests

########## CHANGE DETECTION CONFIGURATION ##########
# The primary branch for your repository which feature branches are merged into
CD_PRIMARY_BRANCH=development
# Branches which a full scan of the paths above should be performed
CD_FULL_SCAN_BRANCHES=master,${CD_PRIMARY_BRANCH}

########## PHP COPY/PASTE DETECTOR CONFIGURATION ##########
# Whether or not to run php copy/paste detector, will run if phpcpd binary is found
PHPCPD_ENABLED=true
# A comma seperated list of regexes to exclude from copy/paste detection
PHPCPD_EXCLUDE_REGEX=
# The minimum number of lines which need to be duplicated to count as copy/paste
PHPCPD_MIN_LINES=5
# The minimum number of duplicated tokens within a line to count as copy/paste
PHPCPD_MIN_TOKENS=70

########## PHP CODE SNIFFER CONFIGURATION ##########
# Whether or not to run php code sniffer, will run if phpcs binary is found
PHPCS_ENABLED=true
# The standards to compare code against, will be ignored if phpcs.xml exists
PHPCS_STANDARDS=vendor/eoneopay/standards/php-code-sniffer/EoneoPay
# Whether to show the code sniffs name on report output
PHPCS_SHOW_SNIFF_NAME=true

########## PHP CS FIXER CONFIGURATION ##########
# Whether or not to run php code sniffer, will run if phpcs binary is found
PHPCS_FIXER_ENABLED=true
# Default rules to be used when no .php_cs file exists in the project
PHPCS_FIXER_RULES='@PSR2,trailing_comma_in_multiline_array'

########## PHP MESS DETECTOR CONFIGURATION ##########
# Whether or not to run php mess destector, will run if phpmd binary is found
PHPMD_ENABLED=true
# The rulesets to use to determine issues, will be ignored if phpmd.xml exists
PHPMD_RULESETS=cleancode,codesize,controversial,design,naming,unusedcode

########## PHPSTAN CONFIGURATION ##########
# Whether or not to run phpstan, will run if phpstan binary is found
PHPSTAN_ENABLED=true
# The reporting level, 1 = loose, 7 = strict
PHPSTAN_REPORTING_LEVEL=7

########## PHPUNIT CONFIGURATION ##########
# Whether or not to run phpunit, will run if paratest or phpunit binary is found
PHPUNIT_ENABLED=true
# Whether or not to enable code coverage checks
PHPUNIT_ENABLE_CODE_COVERAGE=true
# The minimum percentage of coverage to have, will be ignored if coverage check is disabled
PHPUNIT_COVERAGE_MINIMUM_LEVEL=90
# The testsuites to run with coverage
PHPUNIT_COVERAGE_TEST_SUITES=
# The path to output junit parseable log file, can be relative, will be ignored if left blank
PHPUNIT_JUNIT_LOG_PATH=
# The directory containing tests, will be ignored it phpunit.xml exists in working directory
PHPUNIT_TEST_DIRECTORY=tests
# The test suites to run, will run all tests if not specified
PHPUNIT_TEST_SUITES=

########## SECURITY CHECKER CONFIGURATION ##########
# Whether or not to run security-checker, will run if security-checker binary is found
SECURITY_CHECKER_ENABLED=true

工具配置

您还可以通过向应用程序或库的根目录添加配置文件来配置单个工具。