Code Monkey home page Code Monkey logo

churn-php's Introduction

churn-php

Helps discover good candidates for refactoring.

Build Status codecov Scrutinizer Code Quality Code Climate Packagist Packagist Packagist Say Thanks! Donate

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+
  • Currently does not work on Windows command line. See #71 for more details.
  • Your project uses Git as version control system.

If you want to install churn-php in Symfony project, your Symfony components version must be 3.3 or higher.

How to Install?

Install via Composer:

composer require bmitch/churn-php --dev

How to Use?

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

How to Configure?

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>

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.
# Default: 0
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

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

Tests

  • To run the PHPUnit tests execute vendor/bin/phpunit.
  • Before making a pull request please see the contributing section below.

Similar Packages

Contact

Questions, comments, feedback? @bmitch2112

Contributing

  • Please run composer test on PHP 7.0 and ensure it passes.
  • If you do have access to PHP 7.0 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.

churn-php's People

Contributors

bmitch avatar bearzk avatar matthiasnoback avatar vrishank97 avatar riverrun46 avatar joezidell-saleswarp avatar nhoag avatar rmikalkenas avatar raphaelstolt avatar dmytro-y-dev avatar tommy-muehle avatar iquito avatar bgpearson avatar campionfellin avatar dhdutoit avatar holic-cl avatar gms8994 avatar grahamcampbell avatar jakzal avatar kniepok avatar olyckne avatar sbkrogers avatar tulikavijay avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.