Releases: Yoast/yoastcs
Releases · Yoast/yoastcs
1.3.0
1.3.0 - 2019-07-31
Added
- PHPCS: New
Yoast.Commenting.CoversTag
sniff.
This sniff verifies that:- the contents of a
@covers
annotation is valid based on what's supported by PHPUnit; - there are no duplicate
@covers
or@coversNothing
tags in a docblock; - a docblock doesn't contain both a
@covers
tag as well as a@coversNothing
tag;
Includes a fixer for common errors.
- the contents of a
- PHPCS: New
Yoast.Commenting.TestsHaveCoversTag
sniff.
This sniff verifies that all unit test functions have at least one@covers
tag - or a@coversNothing
tag - in the function docblock or in the class docblock. - PHPCS: New
Yoast.Yoast.AlternativeFunctions
sniff.
This sniff allows for discouraging/forbidding the use of PHP/WP native functions in favor of using Yoast native functions.
In this initial version, the sniff checks for the use of thejson_encode()
andwp_json_encode()
functions and suggests usingWPSEO_Utils::format_json_encode()
instead.
Note: this sniff contains an auto-fixer. If for any of the repos, the auto-fixer should not be used, the auto-fixer can be disabled from within the repo specific ruleset using<rule ref="..." phpcs-only="true"/>
. - PHPCS: The
Squiz.WhiteSpace.MemberVarSpacing
sniff.
This sniff verifies and auto-fixes the number of blank lines between property declarations within OO-structures. - PHPCS: A default value for the
minimum_supported_wp_version
property which is used by various WPCS sniffs. The current default is WP4.9
.
Previously this value would have to be set via aconfig
directive in custom repo specific rulesets.
For those rulesets which use the Yoast default, thisconfig
directive can now be removed.
For more details, see #131. - PHPCS: All YoastCS native sniffs are now accompanied by documentation which can be viewed from the command-line using
phpcs --generator=Text --standard=Yoast
. - Repo/QA: Various templates for typical pull requests to this repo.
- Composer:
fix-cs
script. - Travis: Testing of the code against PHP 7.4 (unstable).
Changed
- PHPCS: Files in the following directories will now be excluded from all scans by default:
/.git/
/.wordpress-svn/
/node-modules/
/vendor/
/vendor_prefixed/
Custom repo specific rulesets which contain excludes to this effect, can now remove them safely.
- PHPCS: The message type for issues reported by the
Generic.Formatting.MultipleStatementAlignment
andWordPress.Arrays.MultipleStatementAlignment
sniffs, has been upgraded fromwarning
toerror
. - PHPCS: The WPCS native check for the
json_encode()
function in theWordPress.WP.AlternativeFunctions
has been disabled in favor of the new YoastCS nativeYoast.Yoast.AlternativeFunctions
sniff. - Composer: Supported version of PHP_CodeSniffer has been changed from
^3.4.0
to^3.4.2
. - Composer: Supported version of WordPressCS has been changed from
^2.0.0
to^2.1.1
. - Travis: As there is now a sniff which extends a WPCS sniff, the unit tests will now run against various combinations of PHPCS and WPCS combined.
- Minor housekeeping.
Removed
- PHPMD is no longer part of the YoastCS repo.
PHPMD was not used as a stand-alone tool by any of the repos, only in combination with CodeClimate. - Travis: Testing of the repo against PHP
nightly
(PHP 8, unstable) as no viable PHPUnit version is currently available.
Fixed
- PHPCS: The
Yoast.Files.FileName
sniff will now always suggest removing the longest prefix of the prefixes passed in the configuration.
1.2.2
Changed
- Composer: Supported version of PHP_CodeSniffer has been changed from
^3.3.2
to^3.4.0
. - Composer: Supported version of WordPressCS has been changed from
^1.2.0
to^2.0.0
. - PHPCS: The PHPCompatibility ruleset will now explicitly only be applied to PHP files.
1.2.1
1.2.0
Added
- PHPCS: New
Yoast.Commenting.FileComment
sniff.
This sniff is a wrapper around theFileComment
sniff used in WordPressCS and manages the slightly different requirements for file comments set for the Yoast organisation, in particular:- If a file is namespaced, no file comment is needed (and having one is discouraged).
- PHPCS: New
Yoast.Namespaces.NamespaceDeclaration
sniff.
This sniff forbids the use of:- Namespace declarations without a namespace name, i.e.
namespace;
which in effect means "global namespace". - Scoped namespace declarations.
- Multiple namespace declarations in one file.
- Namespace declarations without a namespace name, i.e.
1.1.0
Added
- PHPCS: New
Yoast.Commenting.CodeCoverageIgnoreDeprecated
sniff.
This sniff verifies that functions which have a@deprecated
tag in the function docblock, also have a@codeCoverageIgnore
tag in the same docblock. - PHPCS: Added XSD schema tags to the ruleset.
- Composer: requirement of the DealerDirect Composer PHPCS plugin at version
^0.5.0
.
This means that - in most cases - projects whichrequire(-dev)
YoastCS, will no longer need to have the plugin in their owncomposer.json
and will still get the benefit of it. - Travis: Validation of the ruleset against the PHPCS XSD schema.
- Travis: Testing of the code against PHP 7.3.
Changed
- PHPCS: The
Yoast.Files.TestDoubles
sniff now allows setting multiple valid paths for test doubles to be placed in.
To this end, the publicdoubles_path
property has been changed from astring
to anarray
. - Composer: Supported version of PHP_CodeSniffer has been changed from
^3.3.1
to^3.3.2
. - Composer: Supported version of WordPressCS has been changed from
^1.0.0
to^1.2.0
. - Composer: Supported version of PHPCompatibilityWP has been changed from
^1.0.0
to^2.0.0
, which uses PHPCompatibility^9.0.0
under the hood. - Composer: The
config-set
script for use with this repo has been renamed toconfig-yoastcs
to be in line with the same script in other repos. - Minor housekeeping: updated
.gitignore
.
Removed
- PHPCS: Minor housekeeping: removed some unused code.
- Composer:
suggest
section. The DealerDirect Composer PHPCS plugin is now included in therequire
section.
Fixed
- PHPCS: Various fixes to the
Yoast.Files.TestDoubles
sniff.- If the
basepath
contained a trailing slash, the sniff could give incorrect results. - Prevent the sniff from recognizing a path like
/tests/doublesniff
as correct when/test/doubles
is in the allowed list. - The
OneObjectPerFile
check will now check both code above the detected mock/double class as well as code below it.
- If the
1.0
Added
- PHPCS: New
Yoast.Files.TestDoubles
sniff.
This sniff verifies that testdouble
/mock
classes are in their own file in adoubles
test sub-directory. - PHPCS: New
Yoast.WhiteSpace.FunctionSpacing
sniff.
This sniff is based on the PHPCS nativeSquiz.WhiteSpace.FunctionSpacing
sniff and verifies and auto-fixes the amount of blank lines between methods within OO-structures. - PHPCS: The
Generic.PHP.LowerCaseType
sniff, as introduced in PHP_CodeSniffer 3.3.0, to the YoastCS ruleset. - PHPCS: The
PSR2.Methods.FunctionClosingBrace
sniff to the YoastCS ruleset. - PHPCS: The
PSR12.Keywords.ShortFormTypeKeywords
sniff, as introduced in PHP_CodeSniffer 3.3.0, to the YoastCS ruleset. - Composer:
roave/security-advisories
dependency to prevent dependencies with known security issues from being installed. - Composer: An explanation about the DealerDirect Composer PHPCS plugin dependency suggestion this package makes.
- Composer:
--dev
requirement of the PHPCompatibility library at version^8.2.0
.
Changed
- Composer: Supported version of PHP_CodeSniffer has been changed from
^3.2.0
to^3.3.1
. - Composer: Supported version of WordPressCS has been changed from
~0.14.0
to^1.0.0
. - Composer/PHPCS: Switched from using the external PHPCompatibility standard to using PHPCompatibilityWP at version
^1.0.0
. - Composer: The command to run
check-cs
over the code in this repo.
PHP_CodeSniffer 3.3.0 allows overruling config directives from the command-line. This also simplies the ruleset used for the YoastCS codebase. - PHPCS: The format for declaring array properties in the ruleset has been updated to the new format available in PHP_CodeSniffer 3.3.0.
- Travis: The installation of dependencies is now done via Composer instead of via cloning repos.
- Travis: CS warnings are no longer allowed in this codebase. The codebase is currently 100% clean, let's keep it that way.
Removed
- Composer: The
composer.lock
file.
This file is not necessary for library packages and makes the testing of YoastCS sniffs more involved. - PHPCS: Custom excludes for the
PHPCompatibility
ruleset.
These are no longer necessary after the switch toPHPCompatibilityWP
. - PHPCS: Some stray debug code.
- PHPCS:
// End ...
comments from the codebase. - Travis: Work-around for the PHPUnit version in the PHP 7.2 and nightly images as PHP_CodeSniffer supports PHPUnit 6.x since version 3.3.0.
Fixed
- Travis: Builds on PHP 7.2 and nightly were failing because of changes in the Travis images (higher PHPUnit version).
0.5
Added
- PHPCS: New
Yoast.Files.FileName
sniff and exclude the wholeWordPress.Files.FileName
sniff.
TheYoast.Files.FileName
sniff verifies that file names comply with the Yoast specific file name rules. - PHPCS: The external PHPCompatibility standard to the YoastCS ruleset at version
^8.1.0
.
Checking against this standard was previously disabled as it was incompatible with Composer. This has since been fixed. - PHPCS: A WP specific set of excludes for the
PHPCompatibility
standard to prevent false positives for native PHP functionality which is back-filled by WordPress. - PHPCS: A custom configuration for the new
WordPress.Arrays.MultipleStatementAlignment
sniff as introduced in WordPressCS 0.14.0. - PHPCS: An exclusion for the
WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
error code. - PHPCS: An exclusion for the
WordPress.PHP.StrictInArray.FoundNonStrictFalse
error code. - Composer: Repository
type
indicator for compatibility with Composer plugins which handle the setting of the PHP_CodeSnifferinstalled_paths
directive. - Composer: Suggest requiring the DealerDirect Composer PHPCS plugin, i.e.
dealerdirect/phpcodesniffer-composer-installer
, for handling the PHP_CodeSnifferinstalled_paths
directive at version^0.4.3
. - Travis: Validation and CS check of the XML files.
- Travis: Testing of the repo against PHP 7.2.
- Travis: Checking of the code style of the YoastCS native PHP files.
- Travis: Validation of the
composer.json
file. - A
.gitattributes
file to keep the code distributed via GH archives and Packagist clean of development related files. - A custom PHPCS ruleset,
.phpcs.xml.dist
, based on YoastCS to check the code style of the code in the YoastCS repository itself. - A
phpunit.xml.dist
file to document the PHPUnit configuration used for testing the YoastCS native sniffs.
Changed
- The minimum supported PHP version for YoastCS is now PHP 5.4 (was 5.2).
- Composer: Supported version of PHP_CodeSniffer has been changed from
2.8.1
to^3.2.0
. - Composer: Supported version of WordPressCS has been changed from
~0.10.0
to~0.14.0
. - PHPCS: The native YoastCS sniffs are now compatible with PHP_CodeSniffer 3.x.
- PHPCS: Improvements to the native
Yoast.ControlStructures.IfElseDeclaration
sniff:- The sniff now has improved detection of issues when non-custom code style is used.
- The sniff has been made more efficient and will exit earlier when no issues are or can be detected.
- The error message has been made more descriptive.
- The sniff will no longer hide one error behind another.
- The sniff will no longer throw false positives when the new PHP_CodeSniffer 3.2.0 inline annotations are encountered.
- Improved inline documentation in the PHPCS ruleset.
- Travis: Minor tweaks to make the builds more efficient.
Removed
- Composer: Superfluous
conflict
directive.
This has been superseded by a higher minimum PHP_CodeSniffer requirement. - PHPCS: Support for PHP_CodeSniffer 2.x for the YoastCS native sniffs.
- PHPCS: The exclusion of the
Generic.Files.LineEndings.InvalidEOLChar
error code. - PHPCS: The inclusion of the
Generic.Strings.UnnecessaryStringConcat
sniff, including custom configuration.
This sniff is now included in WordPressCS since version 0.11.0. - PHPCS: The exclusion of the
PEAR.Functions.FunctionCallSignature.Indent
error code as code should comply with this. - PHPCS: The inclusion of the
Squiz.ControlStructures
category and the related detail configuration.
This is now largely covered by WordPressCS 0.14.0. - PHPCS: The exclusion of the whole
WordPress.Variables.GlobalVariables
sniff.
This sniff was previously excluded because of a bug in WordPressCS. This bug has been fixed in WordPressCS 0.11.0. - PHPCS: The exclusion of the
WordPress.VIP.DirectDatabaseQuery
,WordPress.VIP.FileSystemWritesDisallow
,WordPress.XSS.EscapeOutput
,WordPress.VIP.ValidatedSanitizedInput
sniffs and theGeneric.Commenting.DocComment.MissingShort
error code.
These kind of excludes should be handled in the plugin specific rulesets, not across the board in the YoastCS ruleset. - PHPCS: The group exclusion configurations for the
WordPress.VIP.RestrictedFunctions
,WordPress.VIP.RestrictedVariables
and theWordPress.VIP.PostsPerPage
sniffs.
This kind of configuration should be handled in the plugin specific rulesets, not across the board in the YoastCS ruleset.
Fixed
- Code style consistency for the
xml
files in this repository. - Code style consistency for the
php
files in this repository. - PHPCS: Exclusion patterns for the empty
index.php
files.
0.4.3
Added
- PHPCS: The
Generic.Strings.UnnecessaryStringConcat
sniff to the YoastCS ruleset. - PHPCS: An exclusion for the
Generic.PHP.Syntax
sniff.
The Yoast plugins all runphp lint
against a variety of PHP versions, which is the recommended way to check for PHP syntax errors. - PHPCS: Exclusions for the following additional function groups for the
WordPress.VIP.RestrictedFunctions
sniff:error_log
,runtime_configuration
,prevent_path_disclosure
,url_to_postid
.
Changed
- Travis: Limit the testing of the sniff unit tests to PHP_CodeSniffer 2.x as YoastCS does not yet support PHP_CodeSniffer 3.x.
Fixed
- Travis: Builds for PHP 5.2 and 5.3 were failing because of changes in the Travis images.
0.4.2
Changed
- Composer: Included version of PHP_CodeSniffer has been changed from
2.7.0
to2.8.1
.
The minimum supported version remains at2.8.1
as updated in YoastCS 0.4.1. - Composer: Included version of PHP Mess Detector has been updated from
2.4.3
to2.6.0
.
The minimum supported version remains at2.2.3
. - PHPCS: YoastCS is now based on the full
WordPress
ruleset, rather than theWordPress-VIP
ruleset. See: #16.
Removed
- PHPCS: The exclusion of the whole
WordPress.NamingConventions.ValidVariableName
sniff.
This sniff was previously excluded because of a bug in WordPressCS. This bug has been fixed in WordPressCS 0.10.0.
0.4.1
Added
- PHPCS: Unit tests for the
Yoast.ControlStructures.IfElseDeclaration
sniff. - Travis build testing.
Changed
- Composer: Supported version of PHP_CodeSniffer has been changed from
2.7.0
to~2.8.1
. - PHPCS: Exclude function groups rather than individual error codes for WordPressCS sniffs which allow for this.
Removed
- PHPCS: The exclusion for the
Squiz.Commenting.FunctionComment.ScalarTypeHintMissing
error code.
This is already taken care of upstream in WordPressCS 0.10.0. - PHPCS: Explicit inclusion of the YoastCS native
Yoast.ControlStructures.IfElseDeclaration
sniff from the YoastCS ruleset.
AllYoast
sniffs are automatically included, so the explicit inclusion was redundant.