bmitch / churn-php
发现需要重构的文件。
1.7.2
2024-08-04 10:06 UTC
Requires
- php: >=7.1.3
- composer-runtime-api: ^2
- ext-json: *
- ext-tokenizer: *
- symfony/console: ^3.4 || ^4.0 || ^5.0 || ^6.0 || ^7.0
- symfony/filesystem: ^3.4 || ^4.0 || ^5.0 || ^6.0 || ^7.0
- symfony/process: ^3.4 || ^4.0 || ^5.0 || ^6.0 || ^7.0
- symfony/yaml: ^3.4 || ^4.0 || ^5.0 || ^6.0 || ^7.0
- webmozart/assert: ^1.2
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.5
- mockery/mockery: ^1.3.0
- phar-io/manifest: ^1.0 || ^2.0
- symfony/phpunit-bridge: ^5.1 || ^6.0 || ^7.0
This package is auto-updated.
Last update: 2024-09-03 22:54:52 UTC
README
帮助发现重构的良好候选者。
目录
这是什么?
churn-php
是一个包,可以帮助您识别项目中可能适合重构的 PHP 文件。它将检查提供的路径中的每个 PHP 文件
- 检查其提交数。
- 计算复杂度。
- 根据这两个值创建一个评分。
结果以表格形式显示
经常更改且复杂性高的文件可能比不经常更改且复杂性低的文件更适合重构。
churn-php
仅协助开发者识别重构文件。最好结合自己的判断来决定可能想要重构的文件。
兼容性
- PHP 7.1+
- Composer 2.0+
如何安装?
下载 最新版本 的 churn.phar
或使用 Phive 安装
phive install churn
您还可以通过 Composer 安装 churn-php
composer require bmitch/churn-php --dev
如何使用?
churn run <one or more paths to source code> ... churn run src churn run src tests # the command name can be skipped if directoriesToScan is set in churn.yml churn
如何配置?
您可以添加一个可选的 churn.yml
文件,该文件可用于配置 churn-php。此文件的路径可以使用 --configuration
选项进行自定义
# Default: "churn.yml" or "churn.yml.dist" churn run --configuration=config-dir/ <path> churn run --configuration=my-config.yml <path>
一个示例 churn.yml
文件如下
# The maximum number of files to display in the results table. # Default: 10 filesToShow: 10 # The minimum score a file need to display in the results table. # Disabled if null. # Default: 0.1 minScoreToShow: 0 # The command returns an 1 exit code if the highest score is greater than the threshold. # Disabled if null. # Default: null maxScoreThreshold: 0.9 # The number of parallel jobs to use when processing files. # Default: 10 parallelJobs: 10 # How far back in the VCS history to count the number of commits to a file # Can be a human readable date like 'One week ago' or a date like '2017-07-12' # Default: '10 Years ago' commitsSince: One year ago # Files to ignore when processing. The full path to the file relative to the root of your project is required. # Also supports regular expressions. # Default: All PHP files in the path provided to churn-php are processed. filesToIgnore: - src/Commands/ChurnCommand.php - src/Results/ResultsParser.php - src/Foo/Ba* # File extensions to use when processing. # Default: php fileExtensions: - php - inc # This list is used only if there is no argument when running churn. # Default: <empty> directoriesToScan: - src - tests/ # List of user-defined hooks. # They can be referenced by their full qualified class name if churn has access to the autoloader. # Otherwise the file path can be used as well. # See below the section about hooks for more details. # Default: <empty> hooks: - Namespace\MyHook - path/to/my-hook.php # The version control system used for your project. # Accepted values: fossil, git, mercurial, subversion, none # Default: git vcs: git # The path of the cache file. It doesn't need to exist before running churn. # Disabled if null. # Default: null cachePath: .churn.cache
如果省略了 churn.yml
文件或省略了单个设置,则将使用上述默认值。
输出格式
您可以将 churn
配置为以不同的格式输出结果。可用格式有
csv
json
markdown
text
(默认)
要使用不同的格式,请使用 --format
选项。例如,对于 json
的命令示例
churn run --format json
钩子
“钩子”配置允许您自定义 churn
。
用户定义的钩子必须实现至少一个钩子接口
类似包
联系
有问题、评论、反馈? @bmitch2112
贡献
- 请在 PHP 7.1 上运行
composer test
并确保通过。 - 如果您无法访问 PHP 7.1,请在提交拉取请求时确保 CI 构建通过。如果您无法在拉取请求中使其通过,请向我发送 ping,我可以帮助您。
- 请参阅 CONTRIBUTING.md
许可
MIT 许可证(MIT)。有关更多信息,请参阅 许可文件