Skip to content

Introduce PHP coding-standards thresholds #15911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true

[*.txt]
[*\.txt]
trim_trailing_whitespace = false

[*.{md,json,yml}]
[*\.{md,json,yml,xml,xml\.dist}]
indent_style = space
indent_size = 2

[*.svg]
[*\.svg]
insert_final_newline = false
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,6 @@ install:
composer install --no-dev --no-interaction
composer du
fi
- |
if [[ "$PHPCS" == "1" && "$IS_PREMIUM" != "1" ]]; then
composer config-yoastcs
fi
- |
if [[ "$CHECKJS" == "1" ]]; then
yarn global add grunt-cli
Expand Down Expand Up @@ -268,8 +264,13 @@ script:
cd premium
composer check-cs
cd -
elif [[ "$TRAVIS_PULL_REQUEST" == "false" ]]; then
composer check-cs-threshold
else
vendor/bin/phpcs -qn
# For pull requests the $TRAVIS_BRANCH contains the target branch.
# We want to avoid introducing any new CS errors or warnings in PRs.
composer check-cs-threshold
composer check-branch-cs $TRAVIS_BRANCH
fi
travis_time_finish && travis_fold end "PHP.code-style"
fi
Expand Down
21 changes: 12 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
},
"require-dev": {
"yoast/php-development-environment": "^1.0",
"yoast/yoastcs": "~0.4.3",
"phpcompatibility/phpcompatibility-wp": "^2.0.0",
"yoast/yoastcs": "^2.0.0",
"humbug/php-scoper": "^0.12.0",
"brain/monkey": "^2.4",
"phpunit/phpunit": "^5.7",
Expand Down Expand Up @@ -79,13 +78,17 @@
"lint-staged": [
"Yoast\\WP\\SEO\\Composer\\Actions::lint_staged"
],
"config-yoastcs": [
"@php ./vendor/squizlabs/php_codesniffer/scripts/phpcs --config-set installed_paths ../../../vendor/wp-coding-standards/wpcs,../../../vendor/yoast/yoastcs,../../../vendor/phpcompatibility/php-compatibility,../../../vendor/phpcompatibility/phpcompatibility-paragonie,../../../vendor/phpcompatibility/phpcompatibility-wp",
"@php ./vendor/squizlabs/php_codesniffer/scripts/phpcs --config-set default_standard Yoast"
],
"cs": [
"Yoast\\WP\\SEO\\Composer\\Actions::check_coding_standards"
],
"check-cs-thresholds": [
"@putenv YOASTCS_THRESHOLD_ERRORS=625",
"@putenv YOASTCS_THRESHOLD_WARNINGS=546",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will these numbers be maintained ?

"Yoast\\WP\\SEO\\Composer\\Actions::check_cs_thresholds"
],
"check-cs-summary": [
"@check-cs-warnings --report=summary"
],
"check-cs": [
"@check-cs-warnings -n"
],
Expand All @@ -94,16 +97,16 @@
"composer check-cs"
],
"check-cs-warnings": [
"@php ./vendor/squizlabs/php_codesniffer/scripts/phpcs"
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcs"
],
"check-staged-cs": [
"Yoast\\WP\\SEO\\Composer\\Actions::check_staged_cs"
"@check-cs-warnings --filter=GitStaged"
],
"check-branch-cs": [
"Yoast\\WP\\SEO\\Composer\\Actions::check_branch_cs"
],
"fix-cs": [
"@php ./vendor/squizlabs/php_codesniffer/scripts/phpcbf"
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf"
],
"prefix-dependencies": [
"composer prefix-oauth2-client",
Expand Down
Loading