Skip to content

Releases: Yoast/yoastcs

2.1.0

Choose a tag to compare

@IreneStr IreneStr released this 27 Oct 09:54

2.1.0 - 2020-10-27

Added

  • PHPCS: A new check to the Yoast.Files.TestDoubles sniff to verify that all double/mock classes have either Double or Mock in the class name.
  • PHPCS: Metrics to the Yoast.NamingConventions.NamespaceName sniff 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=info option.
  • PHPCS: Metrics to the Yoast.NamingConventions.ObjectNameDepth sniff 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=info option.
  • PHPCS: Metrics to the Yoast.NamingConventions.ValidHookName sniff 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=info option.

Changed

  • PHPCS: The default value for the minimum_supported_wp_version property which is used by various WPCS sniffs has been updated to WP 5.4 (was 5.3).
  • Composer: Supported version of the DealerDirect Composer PHPCS plugin has been changed to allow for the newly released 0.7.0 version 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.FileName sniff expects a -functions suffix for a function-only file. The sniff has been updated to also allow such a file to be called functions.php without further specification.
    This widening is specifically intended for namespaced function-only files.
  • PHPCS: The Yoast.NamingConventions.NamespaceName sniff 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

Choose a tag to compare

@IreneStr IreneStr released this 02 Apr 17:18

2.0.2 - 2020-04-02

Changed

  • PHPCS: The default value for the minimum_supported_wp_version property which is used by various WPCS sniffs has been updated to WP 5.3 (was 5.2).

2.0.1

Choose a tag to compare

@IreneStr IreneStr released this 06 Feb 11:59

[2.0.1] - 2020-02-06

Changed

  • Composer: Supported version of the DealerDirect Composer PHPCS plugin has been changed from ^0.5.0 to ^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

Choose a tag to compare

@IreneStr IreneStr released this 17 Dec 07:46

[2.0.0] - 2019-12-17

Added

  • PHPCS: New Yoast.NamingConventions.ObjectNameDepth sniff.
    • 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, _Mock or _Double suffix 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) and recommended_max_words (warning). The default for both is 3.
  • PHPCS: New Yoast.NamingConventions.NamespaceName sniff.
    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) and recommended_max_levels (warning) which are by default set to 3 and 2 respectively.
      • src_directory to indicate the project root(s) for the path-to-name translation when the project root is not the repo root directory.
      • prefixes to set the plugin specific prefix(es) to take into account.
  • PHPCS: New Yoast.NamingConventions.ValidHookName sniff.
    This sniff extends and adds to the upstream WordPress.NamingConventions.ValidHookName sniff.
    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 a warning.
    • 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 warning at severity 3 suggesting the hook name be inspected manually.
        As the default severity for PHPCS is 5, this warning at severity 3 will normally not be shown.
        It is there to allow for intermittently checking of the dynamic hook names. To trigger it, --severity=3 should be passed on the command line.
    • The sniff has three configurable properties:
      • maximum_depth (error) and soft_maximum_depth (warning). The default for both is 4.
      • prefixes to set the plugin specific prefix(es) to take into account.
  • PHPCS: The Generic.Arrays.DisallowLongArraySyntax sniff.
    WPCS 2.2.0 demands long array syntax. In contrast to that, YoastCS demands short array syntax.
  • PHPCS: The Generic.ControlStructures.DisallowYodaConditions sniff.
    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.SpreadOperatorSpacingAfter sniff.
    Enforces no space between the ... spread operator and the variable/function call it applies to.
  • PHPCS: The PEAR.WhiteSpace.ObjectOperatorIndent sniff.
    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.ClosingBrace sniff.
    This sniff disallows the outdated practice of // end ... comments for OO stuctures.
  • PHPCS: The PSR12.Files.ImportStatement sniff.
    Import use statements 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 import use statements.
  • PHPCS: The PSR12.Files.OpenTag sniff.
    Enforces that a PHP open tag is on a line by itself in PHP-only files.
  • PHPCS: A CustomPrefixesTrait to handle checking names against a list of custom prefixes.
  • Composer: lint script which uses the Parallel-Lint package for faster and more readable linting results.

Changed

  • ⚠️ PHPCS: Yoast.Files.FileName sniff: the public $prefixes property, 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.FileName sniff: the public $exclude property, 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_version property which is used by various WPCS sniffs has been update to WP 5.2 (was 4.9).
  • Composer: Supported version of PHP_CodeSniffer has been changed from ^3.4.2 to ^3.5.0.
    Note: this makes the option --filter=gitstaged available which can be used in git pre-commit hooks to only check staged files.
  • Composer: Supported version of WordPressCS has been changed from ^2.1.1 to ^2.2.0.
  • Composer: Supported version of PHPCompatibilityWP has been changed from ^2.0.0 to ^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

Choose a tag to compare

@IreneStr IreneStr released this 31 Jul 12:09

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.
  • 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 the json_encode() and wp_json_encode() functions and suggests using WPSEO_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 WP 4.9.
    Previously this value would have to be set via a config directive in custom repo specific rulesets.
    For those rulesets which use the Yoast default, this config 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 and WordPress.Arrays.MultipleStatementAlignment sniffs, has been upgraded from warning to error.
  • PHPCS: The WPCS native check for the json_encode() function in the WordPress.WP.AlternativeFunctions has been disabled in favor of the new YoastCS native Yoast.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

Choose a tag to compare

@IreneStr IreneStr released this 21 Jan 11:01

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

Choose a tag to compare

@moorscode moorscode released this 28 Dec 09:48
48dc26f

Fixed

  • Undefined variable in Yoast.Namespaces.NamespaceDeclaration sniff.

1.2.0

Choose a tag to compare

@moorscode moorscode released this 21 Dec 13:22
3c9bed0

Added

  • PHPCS: New Yoast.Commenting.FileComment sniff.
    This sniff is a wrapper around the FileComment 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.

1.1.0

Choose a tag to compare

@moorscode moorscode released this 18 Dec 09:16
9172d2e

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 which require(-dev) YoastCS, will no longer need to have the plugin in their own composer.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 public doubles_path property has been changed from a string to an array.
  • 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 to config-yoastcs to be in line with the same script in other repos.
  • Minor housekeeping: updated .gitignore.

Removed

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.

1.0

1.0

Choose a tag to compare

@moorscode moorscode released this 24 Aug 09:08
3b3498c

Added

  • PHPCS: New Yoast.Files.TestDoubles sniff.
    This sniff verifies that test double/mock classes are in their own file in a doubles test sub-directory.
  • PHPCS: New Yoast.WhiteSpace.FunctionSpacing sniff.
    This sniff is based on the PHPCS native Squiz.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 to PHPCompatibilityWP.
  • 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).