Releases: Yoast/yoastcs
Releases · Yoast/yoastcs
Release list
2.1.0
2.1.0 - 2020-10-27
Added
- PHPCS: A new check to the
Yoast.Files.TestDoublessniff to verify that all double/mock classes have eitherDoubleorMockin the class name. - PHPCS: Metrics to the
Yoast.NamingConventions.NamespaceNamesniff to see the breakdown of the number of levels used in namespace names across a code base.
To see the metrics, run PHPCS with the--report=infooption. - PHPCS: Metrics to the
Yoast.NamingConventions.ObjectNameDepthsniff to see the breakdown of the number of words used in object names across a code base.
To see the metrics, run PHPCS with the--report=infooption. - PHPCS: Metrics to the
Yoast.NamingConventions.ValidHookNamesniff to see the breakdown of the number of words used in hook names across a code base, as well as a break down of old-style versus new-style hook name usage.
To see the metrics, run PHPCS with the--report=infooption.
Changed
- PHPCS: The default value for the
minimum_supported_wp_versionproperty which is used by various WPCS sniffs has been updated to WP5.4(was5.3). - Composer: Supported version of the DealerDirect Composer PHPCS plugin has been changed to allow for the newly released
0.7.0version which adds support for Composer 2.0.
Note: this requirement is flexible to prevent conflicts with included standards which may include the plugin as well. - Travis: improved testing against the upcoming PHP 8.0.
- Various housekeeping.
Fixed
- PHPCS: The
Yoast.Files.FileNamesniff expects a-functionssuffix for a function-only file. The sniff has been updated to also allow such a file to be calledfunctions.phpwithout further specification.
This widening is specifically intended for namespaced function-only files. - PHPCS: The
Yoast.NamingConventions.NamespaceNamesniff has improved handling of the allowance for an extra namespace level for test double directories for non-conventional test directory set-ups (like YoastSEO).
2.0.2
2.0.1
[2.0.1] - 2020-02-06
Changed
- Composer: Supported version of the DealerDirect Composer PHPCS plugin has been changed from
^0.5.0to^0.5 || ^0.6.
Note: this requirement is flexible to prevent conflicts with included standards which may include the plugin as well. - Various housekeeping.
Fixed
Yoast.NamingConventions.NamespaceName: fixed a potential "undefined index" notice.
2.0.0
[2.0.0] - 2019-12-17
Added
- PHPCS: New
Yoast.NamingConventions.ObjectNameDepthsniff.- For objects declared within a namespace, this sniff verifies that an object name consist of maximum three words separated by underscores.
- For objects which are part of a unit test suite, a
_Test,_Mockor_Doublesuffix at the end of the object name will be disregarded for the purposes of the word count. - The sniff has two configurable properties
max_words(error) andrecommended_max_words(warning). The default for both is3.
- PHPCS: New
Yoast.NamingConventions.NamespaceNamesniff.
This sniff verifies that:- Namespace names consist of a maximum of three levels (excluding the plugin specific prefix) and recommends for the name to be maximum two levels deep.
For unit test files,Tests\(Doubles\)directly after the prefix will be ignored when determining the level depth. - The levels in the namespace name directly translate to the directory path to the file.
- The sniff has four configurable properties:
max_levels(error) andrecommended_max_levels(warning) which are by default set to3and2respectively.src_directoryto indicate the project root(s) for the path-to-name translation when the project root is not the repo root directory.prefixesto set the plugin specific prefix(es) to take into account.
- Namespace names consist of a maximum of three levels (excluding the plugin specific prefix) and recommends for the name to be maximum two levels deep.
- PHPCS: New
Yoast.NamingConventions.ValidHookNamesniff.
This sniff extends and adds to the upstreamWordPress.NamingConventions.ValidHookNamesniff.
The sniff will ignore non-prefixed hooks and hooks with a prefix unrelated to the plugin being examined, to prevent errors being thrown about hook names which are outside of our control.
This sniff verifies that:- Hook names are in lowercase with words separated by underscores (same as WordPressCS).
- Hook names are prefixed with the plugin specific prefix in namespace format, i.e.
Yoast\WP\PluginName.
Note: The prefix is exempt from the lowercase with words separated by underscores rule.
If the non-namespace type prefix for a plugin is used, the sniff will throw awarning. - The actual hook name (after the prefix) consist of maximum four words separated by underscores.
- Note: The hook_name part should be descriptive for the (dev-)user and does not need to follow the namespace or file path of the file they are in.
- Also note: for dynamic hook names where the hook name length can not reliably be determined, the sniff will throw a
warningat severity3suggesting the hook name be inspected manually.
As the defaultseverityfor PHPCS is5, thiswarningat severity3will normally not be shown.
It is there to allow for intermittently checking of the dynamic hook names. To trigger it,--severity=3should be passed on the command line.
- The sniff has three configurable properties:
maximum_depth(error) andsoft_maximum_depth(warning). The default for both is4.prefixesto set the plugin specific prefix(es) to take into account.
- PHPCS: The
Generic.Arrays.DisallowLongArraySyntaxsniff.
WPCS 2.2.0 demands long array syntax. In contrast to that, YoastCS demands short array syntax. - PHPCS: The
Generic.ControlStructures.DisallowYodaConditionssniff.
In contrast to WPCS, YoastCS never demanded Yoda conditions. With the addition of this sniff, "normal" (non-Yoda) conditions will now be enforced. - PHPCS: The
Generic.WhiteSpace.SpreadOperatorSpacingAftersniff.
Enforces no space between the...spread operator and the variable/function call it applies to. - PHPCS: The
PEAR.WhiteSpace.ObjectOperatorIndentsniff.
Enforce consistent indentation of chained method calls to one more or less than the previous call in the chain and always at least one in from the start of the chain. - PHPCS: The
PSR12.Classes.ClosingBracesniff.
This sniff disallows the outdated practice of// end ...comments for OO stuctures. - PHPCS: The
PSR12.Files.ImportStatementsniff.
Importusestatements must always be fully qualified, so a leading backslash is redundant (and discouraged by PHP itself).
This sniff enforces that no leading backslash is used for importusestatements. - PHPCS: The
PSR12.Files.OpenTagsniff.
Enforces that a PHP open tag is on a line by itself in PHP-only files. - PHPCS: A
CustomPrefixesTraitto handle checking names against a list of custom prefixes. - Composer:
lintscript which uses the Parallel-Lint package for faster and more readable linting results.
Changed
⚠️ PHPCS:Yoast.Files.FileNamesniff: the public$prefixesproperty, which can be used to indicate which prefixes should be stripped of a class name when translating it to a file name, has been renamed to$oo_prefixes.
Custom repo specific rulesets using the property should be updates to reflect this change.⚠️ PHPCS:Yoast.Files.FileNamesniff: the public$excludeproperty, which can be used to indicate which files to exclude from the file name versus object name check, has been renamed to$excluded_files_strict_check.
Custom repo specific rulesets using the property should be updates to reflect this change.- PHPCS: The default setting for the minimum supported PHP version for repos using YoastCS is now PHP 5.6 (was 5.2).
- PHPCS: The default value for the
minimum_supported_wp_versionproperty which is used by various WPCS sniffs has been update to WP5.2(was4.9). - Composer: Supported version of PHP_CodeSniffer has been changed from
^3.4.2to^3.5.0.
Note: this makes the option--filter=gitstagedavailable which can be used in gitpre-commithooks to only check staged files. - Composer: Supported version of WordPressCS has been changed from
^2.1.1to^2.2.0. - Composer: Supported version of PHPCompatibilityWP has been changed from
^2.0.0to^2.1.0. - Travis: the build check is now run in stages.
- Travis: Tests against PHP 7.4 are no longer allowed to fail.
- Various housekeeping & code compliance with YoastCS 2.0.0.
1.3.0
1.3.0 - 2019-07-31
Added
- PHPCS: New
Yoast.Commenting.CoversTagsniff.
This sniff verifies that:- the contents of a
@coversannotation is valid based on what's supported by PHPUnit; - there are no duplicate
@coversor@coversNothingtags in a docblock; - a docblock doesn't contain both a
@coverstag as well as a@coversNothingtag;
Includes a fixer for common errors.
- the contents of a
- PHPCS: New
Yoast.Commenting.TestsHaveCoversTagsniff.
This sniff verifies that all unit test functions have at least one@coverstag - or a@coversNothingtag - in the function docblock or in the class docblock. - PHPCS: New
Yoast.Yoast.AlternativeFunctionssniff.
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.MemberVarSpacingsniff.
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_versionproperty which is used by various WPCS sniffs. The current default is WP4.9.
Previously this value would have to be set via aconfigdirective in custom repo specific rulesets.
For those rulesets which use the Yoast default, thisconfigdirective 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-csscript. - 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.MultipleStatementAlignmentandWordPress.Arrays.MultipleStatementAlignmentsniffs, has been upgraded fromwarningtoerror. - PHPCS: The WPCS native check for the
json_encode()function in theWordPress.WP.AlternativeFunctionshas been disabled in favor of the new YoastCS nativeYoast.Yoast.AlternativeFunctionssniff. - Composer: Supported version of PHP_CodeSniffer has been changed from
^3.4.0to^3.4.2. - Composer: Supported version of WordPressCS has been changed from
^2.0.0to^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.FileNamesniff 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.2to^3.4.0. - Composer: Supported version of WordPressCS has been changed from
^1.2.0to^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.FileCommentsniff.
This sniff is a wrapper around theFileCommentsniff 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.NamespaceDeclarationsniff.
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.CodeCoverageIgnoreDeprecatedsniff.
This sniff verifies that functions which have a@deprecatedtag in the function docblock, also have a@codeCoverageIgnoretag 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.jsonand 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.TestDoublessniff now allows setting multiple valid paths for test doubles to be placed in.
To this end, the publicdoubles_pathproperty has been changed from astringto anarray. - Composer: Supported version of PHP_CodeSniffer has been changed from
^3.3.1to^3.3.2. - Composer: Supported version of WordPressCS has been changed from
^1.0.0to^1.2.0. - Composer: Supported version of PHPCompatibilityWP has been changed from
^1.0.0to^2.0.0, which uses PHPCompatibility^9.0.0under the hood. - Composer: The
config-setscript for use with this repo has been renamed toconfig-yoastcsto be in line with the same script in other repos. - Minor housekeeping: updated
.gitignore.
Removed
- PHPCS: Minor housekeeping: removed some unused code.
- Composer:
suggestsection. The DealerDirect Composer PHPCS plugin is now included in therequiresection.
Fixed
- PHPCS: Various fixes to the
Yoast.Files.TestDoublessniff.- If the
basepathcontained a trailing slash, the sniff could give incorrect results. - Prevent the sniff from recognizing a path like
/tests/doublesniffas correct when/test/doublesis in the allowed list. - The
OneObjectPerFilecheck 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.TestDoublessniff.
This sniff verifies that testdouble/mockclasses are in their own file in adoublestest sub-directory. - PHPCS: New
Yoast.WhiteSpace.FunctionSpacingsniff.
This sniff is based on the PHPCS nativeSquiz.WhiteSpace.FunctionSpacingsniff and verifies and auto-fixes the amount of blank lines between methods within OO-structures. - PHPCS: The
Generic.PHP.LowerCaseTypesniff, as introduced in PHP_CodeSniffer 3.3.0, to the YoastCS ruleset. - PHPCS: The
PSR2.Methods.FunctionClosingBracesniff to the YoastCS ruleset. - PHPCS: The
PSR12.Keywords.ShortFormTypeKeywordssniff, as introduced in PHP_CodeSniffer 3.3.0, to the YoastCS ruleset. - Composer:
roave/security-advisoriesdependency 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:
--devrequirement of the PHPCompatibility library at version^8.2.0.
Changed
- Composer: Supported version of PHP_CodeSniffer has been changed from
^3.2.0to^3.3.1. - Composer: Supported version of WordPressCS has been changed from
~0.14.0to^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-csover 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.lockfile.
This file is not necessary for library packages and makes the testing of YoastCS sniffs more involved. - PHPCS: Custom excludes for the
PHPCompatibilityruleset.
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).