Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Discover files in need of refactoring.

License

NotificationsYou must be signed in to change notification settings

bmitch/churn-php

Repository files navigation

Helps discover good candidates for refactoring.

Build StatuscodecovScrutinizer Code QualityCode ClimatePackagistPackagistPackagistDonate

Table of Contents

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 thelast release ofchurn.pharor install it withPhive:

phive install churn

You can also installchurn-php via Composer:

composer require bmitch/churn-php --dev

How to Use?

churn run<one or more paths tosource code> ...churn run srcchurn run src tests# the command name can be skipped if directoriesToScan is set in churn.ymlchurn

How to Configure?

You may add an optionalchurn.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 samplechurn.yml file looks like:

# The maximum number of files to display in the results table.# Default: 10filesToShow:10# The minimum score a file need to display in the results table.# Disabled if null.# Default: 0.1minScoreToShow:0# The command returns an 1 exit code if the highest score is greater than the threshold.# Disabled if null.# Default: nullmaxScoreThreshold:0.9# The number of parallel jobs to use when processing files.# Default: 10parallelJobs: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: phpfileExtensions: -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: gitvcs:git# The path of the cache file. It doesn't need to exist before running churn.# Disabled if null.# Default: nullcachePath:.churn.cache

If achurn.yml file is omitted or an individual setting is omitted the default values above will be used.

Output formats

You can configurechurn to output the result in different formats. The available formats are:

  • csv
  • json
  • markdown
  • text (default)

To use a different format use--format option. Example command forjson:

churn run --format json

Hooks

Thehooks configuration allows you to customizechurn.

A user-defined hook must implement at least one Hook interface:

Hook interfaceCorresponding event interface
AfterAnalysisHookAfterAnalysis
AfterFileAnalysisHookAfterFileAnalysis
BeforeAnalysisHookBeforeAnalysis

Similar Packages

Contact

Questions, comments, feedback?@bmitch2112

Contributing

  • Please runcomposer test on 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 seeCONTRIBUTING.md

License

The MIT License (MIT). Please seeLicense File for more information.

About

Discover files in need of refactoring.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors36


[8]ページ先頭

©2009-2026 Movatter.jp