GithubHelp home page GithubHelp logo

flavien-metivier / phpmetrics Goto Github PK

View Code? Open in Web Editor NEW

This project forked from phpmetrics/phpmetrics

0.0 2.0 0.0 10.88 MB

Static analysis tool for PHP

Home Page: http://www.phpmetrics.org/

License: MIT License

Makefile 0.15% PHP 99.85%

phpmetrics's Introduction

PhpMetrics

Gives metrics about PHP project and classes.

License Build Status Scrutinizer Code Quality Latest Stable Version Dependency Status

Installation

As phar archive:

wget https://github.com/Halleck45/PhpMetrics/raw/master/build/phpmetrics.phar
chmod +x phpmetrics.phar
mv phpmetrics.phar /usr/local/bin/phpmetrics

With Composer (Make sure you have ~/.composer/vendor/bin/ in your path):

php composer.phar global require 'halleck45/phpmetrics'

Usage

Do not hesitate to visit the official documentation.

The command command phpmetrics <folder or filename> will output:

Standard report

If you want to get the summary HTML report (with charts):

phpmetrics --report-html=/path/of/your/choice.html <folder or filename>

No panic : you can read the How to read the HTML report page

If you need a pure string representation of the reports in StdOut, just use phpmetrics -q --report-xml=php://stdout <folder or filename>

Conditions of failure

Customizing the conditions of failure is very easy with the--failure-condition option. For example:

--failure-condition="average.maintainabilityIndex < 100 or sum.loc > 10000"

With this example, PhpMetrics script returns 1 if the average of Maintainability index is lower than 100 or if the total number of lines of code is greater than 10000.

You can also work with package:

--failure-condition="My/Package1/XXXX.average.bugs > 0.35"

Remember that in PhpMetrics packages are file oriented (and not object oriented).

Conditions are evaluated with the Hoa Ruler component. Available operators are and, or, xor, not, = (is as an alias), !=, >, >=, <, <=, in and sum

List of availables metrics is documented here.

## IDE integration

## Jenkins and CI

You'll find a complete tutorial in the documentation

You can easily export results to XML with the --report-xml option:

phpmetrics --report-xml=/path/of/your/choice.xml <folder or filename>

You can also export results as violations (MessDetector report), in XML format with the --violations-xml option:

phpmetrics --violations-xml=/path/of/your/choice.xml <folder or filename>

## Configuration file

You can customize configuration with the --config=<file> option.

The file should be a valid yaml file. For example:

# file <my-config.yml>
myconfig:
    # paths to explore
    path:
        extensions: php|inc
        exclude: Features|Tests|tests

    # report and violations files
    logging:
        report:
            xml:    ./log/phpmetrics.xml
            html:   ./log/phpmetrics.html
            csv:    ./log/phpmetrics.csv
        violations:
            xml:    ./log/violations.xml
        chart:
            bubbles: ./log/bubbles.svg

    # condition of failure
    failure: average.maintainabilityIndex < 50 or sum.loc > 10000

    # rules used for color
    rules:
      cyclomaticComplexity: [ 10, 6, 2 ]
      maintainabilityIndex: [ 0, 69, 85 ]
      [...]

Each rule is composed from three values.

  • If A < B < C : A: min, B: yellow limit, C: max
  • If A > B > C : A: max, B: yellow limit, C: min

Contribute

In order to run unit tests, please install the dev dependencies:

curl -sS https://getcomposer.org/installer | php
php composer.phar install
gem install semver

Then, in order to run the test suite:

./vendor/bin/phpunit

Finally, build the phar:

make

# Author

# License

See the LICENSE file.

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.