/canary

Canary provides powerful linting and static analysis for Laravel projects.

Primary LanguagePHPMIT LicenseMIT

Stickee Canary

Contributors Total Downloads License Latest Stable Version PHP Version

Introduction

Canary provides linting and static analysis for stickee Laravel projects.

It includes:

Husky and Lint Staged

Lint Staged can be used to lint staged files and Husky can be used to manage the pre-commit hook that would call it.

The install command will copy example configs over for these tools but you must install them before running it.

Installation

mkdir -p tools/canary
composer require --working-dir=tools/canary stickee/canary
tools/canary/vendor/bin/canary install

Why do we install tools into their own directory?

You should commit this new directory and the config files that are installed.

Usage

Canary provides a unified and decoupled platform for making use of powerful linting and static analysis tools that we make heavy use of at stickee.

Options

To pass options through you must write them after a --.

tools/canary/vendor/bin/canary analyse -- -c phpstan.ci.neon --error-format=github

Commands

analyse

PHPStan

tools/canary/vendor/bin/canary analyse -- -c phpstan.dist.neon

This command will perform static-analysis of your whole project.

It should be ran as part of the pre-commit hook.

See stickee/larastan-config for more details.

fix

PHP CS Fixer

tools/canary/vendor/bin/canary fix -- --config .php-cs-fixer.dist.php

This command will attempt to fix minor code style issues.

It can be ran against a single file.

It should be ran against staged files as part of the pre-commit hook.

See stickee/php-cs-fixer-config for more details.

suggest

Rector in --dry-run mode

tools/canary/vendor/bin/canary suggest

This command will suggest improvements as diffs in the terminal.

Any suggested improvements must be performed manually or you can run the improve command to do it for you.

See stickee/rector-config for more details.

improve

Rector

tools/canary/vendor/bin/canary improve

This command will refactor your code in an attempt to improve it.

Any improved code must be checked before committing.

It can be ran against a single file.

It should not be ran as part of the pre-commit hook.

See stickee/rector-config for more details.

Note

You may find it useful to add these improvements as patches with Git.

You could use a Git integration in your editor or stage the improvements as patches with:

git add <file> -p

Contributions

Contributions are welcome! Canary is written using Laravel Zero. Improvements to any of the amalgamated open source tools should be directed towards their respective repositories.

You are encouraged to provide tests, which are written using the Pest testing framework.

License

Canary is open source software licensed under the MIT license.