Skip to content

Canary provides powerful linting and static analysis for Laravel projects.

License

Notifications You must be signed in to change notification settings

stickeeuk/canary

Repository files navigation

Stickee Canary

Contributors Total Downloads License Latest Stable Version PHP Version

Introduction

Canary provides linting and static analysis for stickee Laravel projects.

It includes:

Installation

Composer

composer require --dev stickee/canary

# Add scripts to composer.json
composer config --json scripts.analyse "vendor/bin/phpstan analyse -c phpstan.dist.neon"
composer config --json scripts.analyze "composer analyse"
composer config --json scripts.fix "vendor/bin/php-cs-fixer fix --config .php-cs-fixer.php"
composer config --json scripts.improve "vendor/bin/rector"
composer config --json scripts.suggest "vendor/bin/rector --dry-run"

Config

cp vendor/stickee/php-cs-fixer-config/dist/.php-cs-fixer.php .
cp vendor/stickee/larastan-config/dist/phpstan.dist.neon .
cp vendor/stickee/larastan-config/dist/phpstan.ci.neon .
cp vendor/stickee/rector-config/dist/rector.php .

You should commit these config files.

.gitignore

if grep -q '.php-cs-fixer.cache' .gitignore;
then
    echo ".gitignore contains .php-cs-fixer.cache";
else
    echo "Adding .php-cs-fixer.cache to .gitignore";
    echo ".php-cs-fixer.cache" >> .gitignore;
    echo "Done";
fi

Usage

Canary provides a unified package that brings together powerful linting and static analysis tools that we make heavy use of at stickee.

Tools

analyse

PHPStan

composer analyse
# or vendor/bin/phpstan analyse -c phpstan.dist.neon

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

It could be run as part of a pre-commit hook.

See stickee/larastan-config for more details.

fix

PHP CS Fixer

composer fix
# or vendor/bin/php-cs-fixer fix --config .php-cs-fixer.php

This command will attempt to fix minor code style issues.

It can be run against a single file.

It could be run against staged files as part of a pre-commit hook.

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

improve

Rector

composer improve
# or vendor/bin/rector

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

Any improved code must be checked before committing.

It can be run against a single file.

It should not be run as part of a pre-commit hook.

See stickee/rector-config for more details.

suggest

Rector in --dry-run mode

composer suggest
# or vendor/bin/rector --dry-run

This command will suggest improvements as diffs in the terminal.

See stickee/rector-config for more details.

Contributions

Contributions are welcome!

Improvements to any of the amalgamated open source tools should be directed towards their respective repositories.

License

Canary is open source software licensed under the MIT license.