diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000000000000000000000000000000000..c394f5014f27a47bd99ee010987ad626ae7e31c8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,22 @@ +# This file is for unifying the coding style for different editors and IDEs +# editorconfig.org + +# WordPress Coding Standards +# https://make.wordpress.org/core/handbook/coding-standards/ + +root = true + +[*] +indent_style = space +indent_size = 4 +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.yml] +indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..6b71fc789360605b77f8f82161887ac88953f392 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,12 @@ +.git/ export-ignore +tests/ export-ignore +vendor/ export-ignore +.editorconfig export-ignore +.gitattributes export-ignore +.gitignore export-ignore +.gitlab-ci.yml export-ignore +.idea export-ignore +apigen.neon export-ignore +phpcs.xml.dist export-ignore +phpunit-integration.xml export-ignore +phpunit-unit.xml export-ignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..30babffc625009b7f4b9bf238b959329fe3c4d06 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/vendor/ +.idea +composer.lock diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..1b1c48bad376d88b97ab42c92de343b0cd565a4b --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,7 @@ +variables: + DISABLE_PHP_5_5: 1 + DISABLE_INTEGRATION_TESTS: 1 + DISABLE_CODECEPTION: 1 + IS_LIBRARY: 1 + +include: 'https://gitlab.com/wpdesk/gitlab-ci/raw/master/gitlab-ci-1.2.yml' diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..1758120dfffde740dfa25429c968e20f4907361b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +[1.0.0] - 2019-05-30 +# Added +* First version diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000000000000000000000000000000000000..ffa89b56e1d2c45e2843d47aa541b65f2cffcd55 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 WP Desk + +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. diff --git a/README.md b/README.md index 0fbd5551444e621b6ff08a668c2976a745ef9d5a..3eb6c9da572b8200b25ca44776fa6db73bcd1eb4 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,14 @@ -# wp-code-sniffer +[](https://gitlab.com/wpdesk/wp-code-sniffer/pipelines) +[](https://gitlab.com/wpdesk/wp-code-sniffer/commits/master) +[](https://packagist.org/packages/wpdesk/wp-code-sniffer) +[](https://packagist.org/packages/wpdesk/wp-code-sniffer) +[](https://packagist.org/packages/wpdesk/wp-code-sniffer) +[](https://packagist.org/packages/wpdesk/wp-code-sniffer) + +Library for Wp Desk Coding Standards in plugins. +=============================================== + +# Installation + +`composer require --dev wpdesk/wp-code-sniffer` diff --git a/apigen.neon b/apigen.neon new file mode 100644 index 0000000000000000000000000000000000000000..1aec8cf79a0fc4b0035465c5e90d65b85b3449e7 --- /dev/null +++ b/apigen.neon @@ -0,0 +1,27 @@ +destination: docs +templateConfig: /app/theme-woocommerce/config.neon +extensions: [php] +source: + - src +exclude: + - vendor + - tests + - languages + +charset: [UTF-8] +main: Wordpress plugin +title: Plugin template more info +baseUrl: "/" + +templateTheme: default +php: false +sourceCode: false +tree: true +deprecated: false +todo: false +download: false + +accessLevels: + - public + - private + - protected diff --git a/composer.json b/composer.json new file mode 100644 index 0000000000000000000000000000000000000000..5ab7fa2ce0df4d17119b4d948cc4219f27d2c462 --- /dev/null +++ b/composer.json @@ -0,0 +1,36 @@ +{ + "name": "wpdesk/wp-code-sniffer", + "description": "Library for WP Desk Coding standards in plugins.", + "license": "MIT", + "keywords": ["wordpress", "code sniffer", "admin"], + "homepage": "https://gitlab.com/wpdesk/wp-code-sniffer", + "type": "library", + "minimum-stability": "stable", + "authors": [ + { + "name": "grola", + "email": "grola@wpdesk.net" + } + ], + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2", + "phpcompatibility/php-compatibility": "^9.3", + "squizlabs/php_codesniffer": "^3.5", + "wp-coding-standards/wpcs": "^2.2" + }, + "require-dev": { + "phpunit/phpunit": "<7", + "mockery/mockery": "*", + "10up/wp_mock": "*" + }, + "autoload": { + }, + "autoload-dev": { + }, + "scripts": { + "phpcs": "phpcs" + }, + "extra": { + "class": "WPDesk\\Composer\\Codeception\\Plugin" + } +} diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000000000000000000000000000000000000..0f63900cfbe1be9f9130316e1fe247a6d7bbc470 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,28 @@ +<?xml version="1.0"?> +<ruleset name="WordPress Coding Standards for WP Desk Plugin"> + <description>Sniffs for WordPress WPDesk plugins</description> + + <config name="testVersion" value="5.6-"/> + + <arg name="extensions" value="php"/> + + <rule ref="PHPCompatibility"/> + <rule ref="WordPress"/> + + <!-- Remove checking if classes are in class- files --> + <rule ref="WordPress.Files.FileName"> + <exclude-pattern>/class/.*\.php</exclude-pattern> + </rule> + + <rule ref="WordPress.Files.FileName.InvalidClassFileName"> + <exclude-pattern>/class/.*\.php</exclude-pattern> + </rule> + + <rule ref="WordPress.NamingConventions.ValidVariableName"> + <exclude-pattern>/class/.*\.php</exclude-pattern> + </rule> + + <rule ref="Generic.Commenting.DocComment.MissingShort"> + <exclude-pattern>\.php</exclude-pattern> + </rule> +</ruleset> diff --git a/phpunit-integration.xml b/phpunit-integration.xml new file mode 100644 index 0000000000000000000000000000000000000000..634b884c1c32948885c7e1ff159b3531e235d298 --- /dev/null +++ b/phpunit-integration.xml @@ -0,0 +1,34 @@ +<phpunit bootstrap="tests/integration/bootstrap.php" + backupGlobals="false" +> + <testsuites> + <testsuite> + <directory prefix="Test" suffix=".php">./tests/integration</directory> + </testsuite> + </testsuites> + + <filter> + <whitelist> + <directory suffix=".php">src</directory> + <exclude> + <file>src/init.php</file> + <directory>src/assets</directory> + <directory suffix=".php">tests</directory> + <directory suffix=".php">vendor</directory> + </exclude> + </whitelist> + </filter> + + <logging> + <log type="junit" target="build-coverage/report.junit.xml"/> + <log type="coverage-html" target="build-coverage/coverage" charset="UTF-8" yui="true" highlight="true"/> + <log type="coverage-text" target="build-coverage/coverage.txt"/> + <log type="coverage-clover" target="build-coverage/clover.xml"/> + </logging> + + <php> + <env name="WP_DEVELOP_DIR" value="/tmp/wordpress-develop"/> + <env name="WC_DEVELOP_DIR" value="/tmp/woocommerce"/> + </php> + +</phpunit> diff --git a/phpunit-unit.xml b/phpunit-unit.xml new file mode 100644 index 0000000000000000000000000000000000000000..06391cd41721311f1bae1e3fe1a60977b932a94a --- /dev/null +++ b/phpunit-unit.xml @@ -0,0 +1,21 @@ +<phpunit bootstrap="tests/unit/bootstrap.php"> + <testsuites> + <testsuite> + <directory prefix="test-" suffix=".php">./tests/unit/</directory> + </testsuite> + </testsuites> + + <filter> + <whitelist> + <directory suffix=".php">src</directory> + </whitelist> + </filter> + + <logging> + <log type="junit" target="build-coverage/report.junit.xml"/> + <log type="coverage-html" target="build-coverage/coverage" charset="UTF-8" yui="true" highlight="true"/> + <log type="coverage-text" target="build-coverage/coverage.txt"/> + <log type="coverage-clover" target="build-coverage/clover.xml"/> + </logging> + +</phpunit>