Giter Club home page Giter Club logo

code-quality's Introduction

Code Quality

CircleCI

This composer package will provide some basic code quality checks before committing code by using https://github.com/phpro/grumphp.

It checks only modified files or new files on git commit, but check on all configured paths can be executed running vendor/bin/grumphp run

This tool only extends GrumPHP. Please read its documentation on how to configure tool itself.

Checks performed

This repository currently has following checks:

Pre-requisites

  • Composer
  • PHP >= 7.1

Installation

This needs to be done only once either while creating a project or enabling code checks in existing project.

composer require wunderio/code-quality --dev
cp vendor/wunderio/code-quality/config/grumphp.yml ./grumphp.yml
cp vendor/wunderio/code-quality/config/phpstan.neon ./phpstan.neon

The commit hook for GrumPHP is automatically installed on composer require.

Customization

Configuration

Details of the configuration are broken down into the following sections.

Task parameters

If you need to customize the rules for PHP CodeSniffer then drop in phpcs.xml in the same folder as composer.json and configure grumphp.yml:

parameters:
  tasks:
    phpcs:
      standard:
        - phpcs.xml

Same applies to any task that uses other configuration file (easy-coding-standards).

Each code quality tool allows you to define at least 3 things:

  • run_on - Multiple paths that will be checked and files staged must be from same path
  • ignore_patterns - path parts that will exclude files from check
  • extensions - file extensions of files that should be checked

Please see individual task documentation for more information on what are other configurable options.

Commands

Since GrumPHP is just a CLI tool, these commands can be triggered:

Usage

The pre-commit hook will be automatically run upon executing git commit.

The code scanning can be avoided by git commit --no-verify or git commit -n.

You can run the checks manually with: ./vendor/bin/grumphp run

Usage in Continuous Integration

You can easily use the code quality checkers on your CI (CircleCi/Jenkins/GitLab CI) by adding this line:

./vendor/bin/grumphp run --no-ansi --no-interaction

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.