bmitch/churn-php
Composer 安装命令:
composer require --dev bmitch/churn-php
包简介
Discover files in need of refactoring.
README 文档
README
Helps discover good candidates for refactoring.
Table of Contents
- What Is it?
- Compatibility
- How to Install?
- How to Use?
- How to Configure?
- Similar Packages
- Contact
- Contributing
- License
What is it?
churn-php is a package that helps you identify php files in your project that could be good candidates for refactoring.
It examines each PHP file in the path it is provided and:
- Checks how many commits it has.
- Calculates the cyclomatic complexity.
- Creates a score based on these two values.
The results are displayed in a table:
A file that changes a lot and has a high complexity might be a better candidate for refactoring than a file that doesn't change a lot and has a low complexity.
churn-php only assists the developer to identify files for refactoring.
It's best to use the results in addition to your own judgment to decide which files you may want to refactor.
Compatibility
- PHP 7.1+
- Composer 2.0+
How to Install?
Download the last release of churn.phar
or install it with Phive:
phive install churn
You can also install churn-php via Composer:
composer require bmitch/churn-php --dev
How to Use?
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
How to Configure?
You may add an optional churn.yml file which can be used to configure churn-php.
The location of this file can be customized using the --configuration option:
# Default: "churn.yml" or "churn.yml.dist" churn run --configuration=config-dir/ <path> churn run --configuration=my-config.yml <path>
A sample churn.yml file looks like:
# 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
If a churn.yml file is omitted or an individual setting is omitted the default values above will be used.
Output formats
You can configure churn to output the result in different formats. The available formats are:
csvjsonmarkdowntext(default)
To use a different format use --format option. Example command for json:
churn run --format json
Hooks
The hooks configuration allows you to customize churn.
A user-defined hook must implement at least one Hook interface:
| Hook interface | Corresponding event interface |
|---|---|
| AfterAnalysisHook | AfterAnalysis |
| AfterFileAnalysisHook | AfterFileAnalysis |
| BeforeAnalysisHook | BeforeAnalysis |
Similar Packages
Contact
Questions, comments, feedback? @bmitch2112
Contributing
- Please run
composer teston PHP 7.1 and ensure it passes. - If you don't have access to PHP 7.1 please make sure that CI build passes when you make pull request. If you are unable to get it to pass in the pull request please ping me and I can help.
- Please see CONTRIBUTING.md
License
The MIT License (MIT). Please see License File for more information.
bmitch/churn-php 适用场景与选型建议
bmitch/churn-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.52M 次下载、GitHub Stars 达 1.38k, 最近一次更新时间为 2017 年 06 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「static analysis」 「refactoring」 「complexity」 「churn」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bmitch/churn-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bmitch/churn-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bmitch/churn-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Bookdown.io With Bootswatch Styles And Prism Syntax Highlighting
Editable JSON AST with visitor traversal and formatting-preserving printing.
An extensible package of custom Rector rules for automated PHP refactoring and coding standard enforcement.
TwigStan is a static analyzer for Twig templates powered by PHPStan
Sentiment analysis library for PHP.
Database Standardization and Analysis Tool for Laravel
统计信息
- 总下载量: 1.52M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1379
- 点击次数: 40
- 依赖项目数: 15
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-06-11
