From 5e99f1f313c537180ed5db39f7b278cf0b0d278e Mon Sep 17 00:00:00 2001 From: Gertjan Krol Date: Sat, 20 Aug 2022 00:50:26 +0200 Subject: [PATCH] Initial commit & release --- .gitignore | 6 + .gitlab-ci.yml | 31 + CHANGELOG.md | 7 + CONTRIBUTING.md | 53 ++ LICENSE.md | 21 + README.md | 55 ++ composer.json | 39 ++ config/phpcs-laravel.xml | 28 + config/phpcs-package.xml | 21 + .../extras/generic-coding-standard.xml | 531 +++++++++++++++ src/rulesets/extras/laravel-exclusions.xml | 30 + src/rulesets/extras/pear-coding-standard.xml | 10 + .../extras/phased-coding-standard.xml | 28 + src/rulesets/extras/psr-coding-standard.xml | 234 +++++++ .../extras/slevomat-coding-standard.xml | 605 ++++++++++++++++++ src/rulesets/extras/squiz-coding-standard.xml | 474 ++++++++++++++ src/rulesets/phpcs-laravel.xml | 5 + src/rulesets/phpcs-package.xml | 6 + src/rulesets/phpcs.xml | 9 + src/rulesets/settings.xml | 61 ++ 20 files changed, 2254 insertions(+) create mode 100644 .gitignore create mode 100644 .gitlab-ci.yml create mode 100644 CHANGELOG.md create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 composer.json create mode 100644 config/phpcs-laravel.xml create mode 100644 config/phpcs-package.xml create mode 100644 src/rulesets/extras/generic-coding-standard.xml create mode 100644 src/rulesets/extras/laravel-exclusions.xml create mode 100644 src/rulesets/extras/pear-coding-standard.xml create mode 100644 src/rulesets/extras/phased-coding-standard.xml create mode 100644 src/rulesets/extras/psr-coding-standard.xml create mode 100644 src/rulesets/extras/slevomat-coding-standard.xml create mode 100644 src/rulesets/extras/squiz-coding-standard.xml create mode 100644 src/rulesets/phpcs-laravel.xml create mode 100644 src/rulesets/phpcs-package.xml create mode 100644 src/rulesets/phpcs.xml create mode 100644 src/rulesets/settings.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9c00e42 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/.idea/ +/vendor/ +composer.lock +*cache* +*.log +*.tmp diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..6577228 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,31 @@ +stages: + - prepare + - test + +prepare:composer-install: + stage: prepare + tags: + - prepare + image: composer:2.4 + script: + - echo "Start composer install" + - composer install --no-scripts --verbose --prefer-dist --no-progress --no-interaction --optimize-autoloader + artifacts: + expire_in: 1h + paths: + - composer.lock + - vendor/ + interruptible: true + +test:composer-security-check: + stage: test + tags: + - test + needs: + - job: prepare:composer-install + artifacts: true + image: composer:2.4 + script: + - echo "Start package security check" + - composer security-checker + interruptible: true diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..bfef99a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog +All notable changes to this package will be documented in this file + +## Unreleased + +## 1.0.0 - 2022-08-20 +- Initial release [major] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..cc4c643 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,53 @@ +# Contributing + +Contributions are **welcome** and will be fully **credited**. + +Please read and understand the contribution guide before creating an issue or pull request. + +## Etiquette + +This project is open source, and as such, the maintainers give their free time to build and maintain the source code +held within. They make the code freely available in the hope that it will be of use to other developers. It would be +extremely unfair for them to suffer abuse or anger for their hard work. + +Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the +world that developers are civilized and selfless people. + +It's the duty of the maintainer to ensure that all submissions to the project are of sufficient +quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. + +## Viability + +When requesting or submitting new features, first consider whether it might be useful to others. Open +source projects are used by many developers, who may have entirely different needs to your own. Think about +whether or not your feature is likely to be used by other users of the project. + +## Procedure + +Before filing an issue: + +- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. +- Check to make sure your feature suggestion isn't already present within the project. +- Check the pull requests tab to ensure that the bug doesn't have a fix in progress. +- Check the pull requests tab to ensure that the feature isn't already in progress. + +Before submitting a pull request: + +- Check the codebase to ensure that your feature doesn't already exist. +- Check the pull requests to ensure that another person hasn't already submitted the feature or fix. + +## Requirements + +- **Follow the [Crawl Coding Standard](https://git.gertjankrol.nl/crawl/coding-standard)** - Basically run `composer style` before committing/pushing. + +- **Add tests!** + +- **Document any change in behaviour** - Make sure the `CHANGELOG.md`, `README.md` and any other relevant documentation are kept up-to-date. + +- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. + +- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. + +- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. + +**Happy coding**! diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..e344d12 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Author + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..8669e79 --- /dev/null +++ b/README.md @@ -0,0 +1,55 @@ +# crawl/coding-standard + +[![Latest Version on Packagist](https://img.shields.io/packagist/v/crawl/coding-standard.svg?style=flat-square)](https://packagist.org/packages/crawl/coding-standard) +[![Total Downloads](https://img.shields.io/packagist/dt/crawl/coding-standard.svg?style=flat-square)](https://packagist.org/packages/crawl/coding-standard) + +This package provides rule sets for the Crawl Coding Standard.\ +It requires `squizlabs/php_codesniffer` and some extensions (see [composer.json](composer.json)). + +## Installation + +You can install the package via composer (you should only need it for development): + +```bash +composer require crawl/coding-standard --dev +``` + +## Usage +Depending on your project, copy `phpcs-laravel.xml` or `phpcs-package.xml` from `config/` to your project.\ +**Note:** don't forget to update `Package\Namespace` when using `phpcs-package.xml`. + +You can then run PHP Code Sniffer/Beautifier: +```bash +$ vendor/bin/phpcs --standard=./path/to/copied/phpcs.xml +$ vendor/bin/phpcbf --standard=./path/to/copied/phpcs.xml +``` + +For easier usage, add the following to `scripts` in your project's `composer.json`: +```json + ... + "scripts": { + "style": "vendor/bin/phpcs --standard=./path/to/copied/phpcs.xml", + "fix-style": "vendor/bin/phpcbf --standard=./path/to/copied/phpcs.xml", + }. + ... +``` +You can then use `composer style` to run the sniffer, and `composer fix-style` to run the beautifier. + +### Changelog + +Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. + +## Contributing + +Please see [CONTRIBUTING](CONTRIBUTING.md) for details. + +### Security + +If you discover any security related issues, please email security@gkcld.net instead of using the issue tracker. + +## Authors +- [Gertjan Krol](https://git.gertjankrol.nl/gertjan) + +## License + +The MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information. diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..2267ccd --- /dev/null +++ b/composer.json @@ -0,0 +1,39 @@ +{ + "name": "crawl/coding-standard", + "description": "The Crawl Coding Standard", + "keywords": [ + "crawl", + "coding standard", + "code sniffer", + "code quality" + ], + "homepage": "https://git.gertjankrol.nl/crawl/coding-standard", + "license": "MIT", + "type": "library", + "authors": [ + { + "name": "Gertjan Krol", + "email": "hello@gertjankrol.nl" + } + ], + "require": { + "php": "^8.1", + "phpcompatibility/php-compatibility": "^9.3", + "sirbrillig/phpcs-variable-analysis": "^2.11", + "slevomat/coding-standard": "^7.2", + "squizlabs/php_codesniffer": "^3.7" + }, + "require-dev": { + "enlightn/security-checker": "^1.10" + }, + "scripts": { + "security-checker": "vendor/bin/security-checker security:check composer.lock" + }, + "config": { + "optimize-autoloader": true, + "sort-packages": true, + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } + } +} diff --git a/config/phpcs-laravel.xml b/config/phpcs-laravel.xml new file mode 100644 index 0000000..7a809ab --- /dev/null +++ b/config/phpcs-laravel.xml @@ -0,0 +1,28 @@ + + + Crawl Coding Standard for Laravel projects + + + + + + + + + + + + + + + + app + bootstrap + config + database + resources + routes + tests + + bootstrap/cache + diff --git a/config/phpcs-package.xml b/config/phpcs-package.xml new file mode 100644 index 0000000..1d62018 --- /dev/null +++ b/config/phpcs-package.xml @@ -0,0 +1,21 @@ + + + Crawl Coding Standard for Packages + + + + + + + + + + + + + config + database + resources + src + tests + diff --git a/src/rulesets/extras/generic-coding-standard.xml b/src/rulesets/extras/generic-coding-standard.xml new file mode 100644 index 0000000..da21cfa --- /dev/null +++ b/src/rulesets/extras/generic-coding-standard.xml @@ -0,0 +1,531 @@ + + + + extension of Generic Coding Standard + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/rulesets/extras/laravel-exclusions.xml b/src/rulesets/extras/laravel-exclusions.xml new file mode 100644 index 0000000..b32c66d --- /dev/null +++ b/src/rulesets/extras/laravel-exclusions.xml @@ -0,0 +1,30 @@ + + + + + + + */resources/lang/* + config/ + + + + + database/ + + + + + database/migrations/* + database/seeders/* + + + database/migrations/* + database/seeders/* + + + + */*.blade.php$ + ^vendor/* + ^\.git/* + diff --git a/src/rulesets/extras/pear-coding-standard.xml b/src/rulesets/extras/pear-coding-standard.xml new file mode 100644 index 0000000..39b5c8b --- /dev/null +++ b/src/rulesets/extras/pear-coding-standard.xml @@ -0,0 +1,10 @@ + + + + extension of Squiz Coding Standard + + + + + + diff --git a/src/rulesets/extras/phased-coding-standard.xml b/src/rulesets/extras/phased-coding-standard.xml new file mode 100644 index 0000000..f7872ad --- /dev/null +++ b/src/rulesets/extras/phased-coding-standard.xml @@ -0,0 +1,28 @@ + + + extension for Phased Coding Standard + + + + + + + + + + + + + + + + + + diff --git a/src/rulesets/extras/psr-coding-standard.xml b/src/rulesets/extras/psr-coding-standard.xml new file mode 100644 index 0000000..e27f03a --- /dev/null +++ b/src/rulesets/extras/psr-coding-standard.xml @@ -0,0 +1,234 @@ + + + + extension of PSR Coding Standard + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/rulesets/extras/slevomat-coding-standard.xml b/src/rulesets/extras/slevomat-coding-standard.xml new file mode 100644 index 0000000..c062f24 --- /dev/null +++ b/src/rulesets/extras/slevomat-coding-standard.xml @@ -0,0 +1,605 @@ + + + + extension of Slevomat Coding Standard + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/rulesets/extras/squiz-coding-standard.xml b/src/rulesets/extras/squiz-coding-standard.xml new file mode 100644 index 0000000..27ce688 --- /dev/null +++ b/src/rulesets/extras/squiz-coding-standard.xml @@ -0,0 +1,474 @@ + + + + extension of Squiz Coding Standard + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/rulesets/phpcs-laravel.xml b/src/rulesets/phpcs-laravel.xml new file mode 100644 index 0000000..9a0227c --- /dev/null +++ b/src/rulesets/phpcs-laravel.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/rulesets/phpcs-package.xml b/src/rulesets/phpcs-package.xml new file mode 100644 index 0000000..d86652a --- /dev/null +++ b/src/rulesets/phpcs-package.xml @@ -0,0 +1,6 @@ + + + Coding Standard for Packages + + + diff --git a/src/rulesets/phpcs.xml b/src/rulesets/phpcs.xml new file mode 100644 index 0000000..f0cebf4 --- /dev/null +++ b/src/rulesets/phpcs.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/rulesets/settings.xml b/src/rulesets/settings.xml new file mode 100644 index 0000000..964f035 --- /dev/null +++ b/src/rulesets/settings.xml @@ -0,0 +1,61 @@ + + + + + Coding Standard + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +