Helps discover good candidates for refactoring.
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:
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.
If you want to install
churn-php in Symfony project, your Symfony components version must be 3.3 or higher.
Install via Composer:
composer require bmitch/churn-php --dev
vendor/bin/churn run <one or more paths to source code> ... vendor/bin/churn run src vendor/bin/churn run src tests
You can also use churn-php via Docker:
docker run --rm -ti -v $PWD:/app dockerizedphp/churn run src
You may add an optional
churn.yml file which can be used to configure churn-php. The location of the churn.yml file can be customized using these commands:
Default: "churn.yml" vendor/bin/churn run -c <path> vendor/bin/churn run --configuration[=CONFIGURATION] <path>
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. # Default: 0.1 minScoreToShow: 0 # The number of parallel jobs to use when processing files. # Default: 10 parallelJobs: 10 # How far back in the git 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
churn.yml file is omitted or an individual setting is omitted the default values above will be used.
You can configure
churn to output the result in different formats. The available formats are:
To use a different format use
--format option. Example command for
vendor/bin/churn run --format json
By leveraging automation, code generation, and machine learning, we are capable of delivering secure, stable, and change-embracing software. Through research and education, we push the boundaries of technology forward.
© 2020 Protoku. All rights reserved.