Giter Club home page Giter Club logo

phpwtf's Introduction

phpwtf

What is it?

You know Pdepend, PHPMD? well it's a WTF counter for PHP, useful for codereviews The concept is simple, when you review some code, if you think :

  • WTF!?
  • Why? Why? Why!!!

You simply add a @wtf_start and @wtf_stop as a comment before and after the code that needs explanations or fixing. PHPWTF will parse the code and report the wtfs it finds. Ideally we could even make it usable by Jenkins with a nice graph and code exploration :)

Installation

/!\ THIS TOOL IS TO BE INSTALLED WITH COMPOSER : https://github.com/composer/composer

if you already know how to use composer you can skip this part and go to Usage section.

Basically you need to:

  1. Create a directory where you want to run your composer install, ie : phpwtf_test
  2. Download the composer.phar into your phpwtf_test folder
  3. Create a composer.json file in the phpwtf_test folder like :
    {
    	"name": "nameOfYourProject",
    	"minimum-stability": "dev",
    	"require": {
    		"php": ">=5.3.3",
    		"pem-fr/phpwtf": "dev-master"
    	}
    }
  4. Then, still from the phpwtf_test folder, run this command line : php composer.phar install
  5. Verify that in the root folder (in our example phpwtf_test) you have a composer.lock file and a vendor directory.
  6. Congratulations you have installed phpwtf through composer :)

Usage

To run the example, you just need to :

  1. Go to where you installed phpwtf, in the root folder then type in your console :
    php vendor/bin/phpwtf review --paths="./vendor/phpwtf/phpwtf/examples/*.php,./vendor/phpwtf/phpwtf/examples/*.js,./vendor/phpwtf/phpwtf/examples/*.html" -r --format=html --output-path="../reports/"
  2. Now you should see in your root folder, a reports directory with the html reports

Of course phptwtf script supports help command

Args can be written like that :

php vendor/bin/phpwtf.php review --paths="path/.php,path/.js" --format=html --output-path="path/to/reports/" -r -b

This list of options is non-exhaustive and can change anytime. You can use the help or list command to have more up to date information at any time. Also note that since they are all options, they can be put in any order.

--input-path    -p      Paths to scan for sources, 
                            ie: "/some/path/*.php,/some/other/path/*.js"
                            Default to "/". Becareful, relative path are resolved 
                            from either vendor folder or root folder if you 
                            have not installed phpwtf with composer.

--recursive     -r      If set, the paths will be scanned recursively. Defaults to *FALSE*

--format        -f      by default xml, can be set to html, html+stats, xml+stats
                            the xml is a simple xml with files, and errors
                            the html is a set of pages per file, with the errors
                            reported + stats stats will just ouput statistics
                            about the nb of WTF, etc
                            finally you can combine output format by using "+"

--output-path   -o      defaults to ./reports/
                            the directory where you want your reports to be written

--skip-error    -s      if set, errors will not stop the parsing.

--bench         -b      To display timings.

What more?

Accepting contributions (jenkins integration, code exploration, graphs, better parsing...) :)

The Logo and favicon are courtesy of David Smith and under MIT Licence of the phpwtf project.

phpwtf's People

Contributors

pem-fr avatar

Stargazers

Gabriel Koerich avatar Julien Boudry avatar da✝ avatar James Brooks avatar Kristof Coomans avatar Dmitry Balabka avatar Florent Genette avatar  avatar Adam Lundrigan avatar Chris avatar

Watchers

Chris avatar  avatar James Cloos avatar Vermeulen Maxime avatar Julien Boudry avatar

Forkers

kalyse

phpwtf's Issues

Have a navigation panel with history of checks

Somehow it would be nice to have a hstory of reviews able to modify the index.html page to reflect the selected state.
Maybe all wtf have been solved, but you might want to check what wtf there were a few days ago?

Add stats on a per folder basis

Somehow that'd be nice to have the folder hierarchy in the list of files... Maybe something along the lines of a dojox DataTreeGrid.
That would allow one to see which top folders have most wtfs and allow drilling down to the files.
Since we cannot really reproduce a "module" hierarchy, it would still help visualize more clearly the problems on some specific folders.

Rethink file organization for futur languages ports

For instance phpwtf is in php.
Later I plann on supporting python and node.js for people who don't have php on their servers.
In order to avoid having a messy root, some re-organization needs to be done.

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.