This package is abandoned and no longer maintained. No replacement package was suggested.

Shell script wrapper around PHP_CodeSniffer and JSCS

Installs: 12 914

Dependents: 1

Suggesters: 0

Security: 0

Stars: 32

Watchers: 2

Forks: 5

Open Issues: 10

Language:Shell

0.3.0 2016-09-08 02:52 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:57:10 UTC


README

Circle CI Latest Stable Version Total Downloads License

Bring all your code review dependencies with one command!

Installation

There are 3 options:

1. Global installation

Install once, init for each project or run "as-is" to scan custom files.

composer global require alexdesignworks/dcr
dcr install && source ~/.profile
cd your_project_dir
dcr init

Global build status (https://github.com/alexdesignworks/dcr-global-demo): Circle CI

2. Local per-project installation

composer require alexdesignworks/dcr
vendor/bin/dcr install && source ~/.profile

Local build status (https://github.com/alexdesignworks/dcr-demo): Circle CI

3. Install as composer dependency for specific project:

In composer.json:

{
  "minimum-stability": "dev",
  "require-dev": {
    "alexdesignworks/dcr": "0.1.*"
  },
  "scripts": {
    "post-update-cmd": [
      "bash vendor/bin/dcr install"
    ]
  }
}

Usage

From previously initialised directory:

dcr

For custom code linting (provided that DCR was installed globally):

dcr file_or_directory

FAQ

What is it?

DCR (Drupal Code Review) is a command-line utility to check that produced code follows Drupal coding standards and best practices.

More specifically

It is a shell script wrapper around PHP_CodeSniffer and JSCS with Drupal-related code sniffs. It uses native and custom 3rd party phpcs sniffs.

Why should I use it?

Simply put - convenience. Run code review by only one command dcr.

Why does it exist?

  1. Ease of install: composer require alexdesignworks/dcr
  2. Less false-positives: Drupal-specific exceptions allow to have clean DCR output.
  3. Simple call: no need to call phpcs with tones of confusing parameters. Just use dcr.
  4. JS Linting: no need to install standalone JS linter.
  5. Project-based configuration: use .dcr.yml file to configure dcr for each project and make sure that your teammates are using exactly the same standards.

Why is it a separate tool?

There was a need in a dead-simple solution to review code using a single command, but also be flexible enough to handle project-based sniff rule customisations and pluggable into a CI pipeline.

DCR installs as a single composer dev dependency either into your project or globally.

DCR contains the following:

  • PHP_CodeSniffer with Drupal, Drupal Practice sniffs.
  • Additional DCR sniff with more specific Drupal rules that.
  • Custom project-related sniff - very handy for any custom inclusions.
  • JavaScript code review using JSCS.
  • Colour CLI output - easy to spot issues.

Can it automatically review code on commit?

Yes. Use it in git pre-commit hook.

Can it be used as a part of automated build?

Yes. In fact, there is a dcr-demo and dcr-global-demo projects were setup to test dcr integration.

Does it automatically fix code?

Yes! If you run dcr fix it will try to fix code in all files using phpcbf with your current sniffs configuration.

So, what about PHP_CodeSniffer and Drupal Coder module?

DCR is just a wrapper around PHP_CodeSniffer and Drupal Coder. It does not add more constrains on the code standards.

Roadmap

  • Show success and fail status messages DONE
  • Allow DCR sniffs DONE
  • Allow custom sniffs DONE
  • Automated fix DONE dcr fix
  • Allow running only from project root dir or any subdirs DONE
  • Add JS linting DONE Using JSCS
  • Limit files scan to N failed files
  • Scan only files changed in current branch comparing to a main branch.

License

GPL2