Code Monkey home page Code Monkey logo

php-code-quality's Introduction

    Build Status Code Style

❗️ This package is no longer being actively developed. ❗

Code Quality for PHP packages

This package provides code quality scripts that can be run via Composer.

The scripts also work on continous integration (CI) servers like Jenkins.

Used packages

Used for testing (SpecBDD) the code.
Must be configured with a phpspec.yml file in your root folder.

We are using the leanphp/phpspec-code-coverage extension for generating coverage reports.
This extension requires a phpspec-coverage.yml file in your root folder and Xdebug enabled.

Currently used for checking (linting) and fixing the code.
Sniffs all files in src directory.

Used for mess detection.
Runs the defined ruleset (config/phpmd.xml) on all files in src directory.

Installation

Run composer require --dev karriere/code-quality to install this package.

After installing, insert the desired scripts to your composer.json.

{
    "scripts": {
        "test": "Karriere\\CodeQuality\\SpecificationTest::run",
        "lint": "Karriere\\CodeQuality\\CodeStyleChecker::run",
        "fix": "Karriere\\CodeQuality\\CodeStyleFixer::run",
        "coverage": "Karriere\\CodeQuality\\CodeCoverage::run",
        "md": "Karriere\\CodeQuality\\MessDetector::run"
    }
}

Usage

You can run a script like this: composer {script} -- {options}.

If you are using Git-Shell on Windows (or Git-Shell in Intellij Terminal on Windows), call scripts like this: composer.bat {script}. Otherwise colors will not work.

You can disable TTY by adding the --notty flag (needed for Jenkins).
On Windows platform it's disabled automatically.

composer {script} -- --env=jenkins --notty

Scripts

test

Usage:
  test [--] [options]

Options:
      --fail     Exit with 1 if tests fail.
      --notty    Disable TTY.
      --ptimeout Set process timeout (defaults to 60 seconds).
   -v --verbose  Increase the verbosity of messages.

coverage

Usage:
  coverage [--] [options]

Options:
      --env       Specifiy the environment. Possible values:
                  'local': prints output on command-line.
                  'jenkins': generates a JUnit report file.
      --notty     Disable TTY.
      --ptimeout  Set process timeout (defaults to 60 seconds).

lint

Usage:
  lint [--] [options]

Options:
      --env       Specifiy the environment. Possible values:
                  'local': prints output on command-line.
                  'jenkins': generates a checkstyle report file.
      --fail      Exit with 1 if linting fails.
      --notty     Disable TTY.
      --ptimeout  Set process timeout (defaults to 60 seconds).

md

Usage:
  lint [--] [options]

Options:
      --env       Specifiy the environment. Possible values:
                  'local': prints output on command-line.
                  'jenkins': generates a xml report file.
      --notty     Disable TTY.
      --ptimeout  Set process timeout (defaults to 60 seconds).

fix

Usage:
  fix [--] [options]

Options:
      --notty     Disable TTY.
      --ptimeout  Set process timeout (defaults to 60 seconds).

Using custom matchers

This package integrates karriere/phpspec-matchers. In order to use the custom matchers defined in this package, please include the extension configuration in your phpspec.yml.

FAQ

Why do I have to provide two phpspec configuration files?

The code-coverage-extension slows down the phpspec tests, so we excluded it from the normal configuration file. Keep tests fast!

How do I increase the verbosity of the test-script output?

Run composer test -- -v.

php-code-quality's People

Contributors

fetzi avatar jaylinski avatar k9ordon avatar munsio avatar witti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-code-quality's Issues

Add configuration for base folder

All used tools are executed for the src folder.

This source code folder should be configurable. Maybe in a yaml file in the project directory.

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.