Skip to content
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

Release 1.0.0-alpha3 #71

Merged
merged 57 commits into from
Jun 29, 2020
Merged

Release 1.0.0-alpha3 #71

merged 57 commits into from
Jun 29, 2020

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Jun 29, 2020

Release checklist

jrfnl and others added 30 commits March 10, 2020 01:39
... as the original appears not to be maintained anymore and is not compatible with PHP 7.4.
…fork

CI: switch to fork of Parallel-lint package
The upstream PHPCS `Generic.Arrays.DisallowShortArraySyntax` sniff does not account for short lists and will cause parse errors during auto-fixing when these are encountered.

As the utilities from PHPCSUtils were never merged into PHPCS itself, fixing it upstream would be tedious and would involve duplicating more code than I care to.

So instead, this duplicates the sniff, including the fix which was originally contained in the Refactor branch as pulled to PHPCS.

Includes fixer.
Includes unit tests.
Includes documentation.

Co-authored-by: Greg Sherwood <gsherwood@squiz.net>
…-array-syntax-sniff

New `Universal.Arrays.DisallowShortArraySyntax` sniff
Start testing against PHPCS 4.x-dev, for which development has started, to get early warning about cross-version compatibility issues which need fixing.

The build against `4.x-dev` has been added to `allow_failures` for now.

Note: The `composer install` needs `--prefer-source` for PHPCS 4.x, otherwise the tests directory will not be available, i.e. the abstract test class being used won't be available.
…t-phpcs-4.x

Travis: add a test run against PHPCS 4.x-dev
New sniff to disallow using short ternaries.

While short ternaries are useful when used correctly, the principle of them is often misunderstood and they are more often than not used incorrectly, leading to hard to debug issues and/or PHP warnings/notices.

Includes unit tests.
Includes documentation.
Includes metrics.
…shortternary

New `Universal.Operators.DisallowShortTernary` sniff
The Travis docs say that `$TRAVIS_BUILD_STAGE_NAME` is in "proper case" form:

> TRAVIS_BUILD_STAGE_NAME: The build stage in capitalized form, e.g. Test or Deploy. If a build does not use build stages, this variable is empty ("").

However, it looks like they made an (undocumented) change (probably a bug in their script handling) which means that the `$TRAVIS_BUILD_STAGE_NAME` name is now in the case as given, which in this case is _lowercase_.

This means that some of the comparisons are failing and the wrong things are executed for certain builds.

As I expect this to be a bug in Travis, I'm not changing the case for the comparisons at this time.
Instead I'm fixing this by inline fixing the case of the variable for the comparisons.

Refs:
* https://docs.travis-ci.com/user/environment-variables#default-environment-variables (near the bottom of the list)
New sniff to enforce using spaces for mid-line alignment.

While tab versus space based indentation is a question of preference, for mid-line alignment, spaces should always be preferred, as using tabs will result in inconsistent formatting depending on the dev-user's chosen tab width.

> _This sniff is especially useful for tab-indentation based standards which use the `Generic.Whitespace.DisallowSpaceIndent` sniff to enforce this._
>
> **DO** make sure to set the PHPCS native `tab-width` configuration for the best results.
> ```xml
>    <arg name="tab-width" value="4"/>
> ```
>
> The PHPCS native `Generic.Whitespace.DisallowTabIndent` sniff (used for space-based standards) oversteps its reach and silently does mid-line tab to space replacements as well.
>
> However, the sister-sniff `Generic.Whitespace.DisallowSpaceIndent` leaves mid-line tabs/spaces alone.
> This sniff fills that gap.

Implementation notes:
* Includes a `DummyTokenizer` to allow use of the PHPCS native intelligent tabs to spaces replacement using the default tab-width if none was set.

Includes fixers.
Includes unit tests.
Includes documentation.
…llow-inline-tab-sniff

New `Universal.WhiteSpace.DisallowInlineTabs` sniff
When PHPCS annotations are part of a comment, they get a different token, which led to the sniff triggering on the indentation of the comment line following the annotation.

Fixed now.

Includes unit test safeguarding the fix.
…-bug-fix-mixed-comments-annotations

DisallowInlineTabs: bug fix / indentation vs annotation
…-docs-improve-code-sample

DisallowInlineTabs: improve code sample in docs
New sniff to enforce the use of strict comparisons as loose type comparisons will type juggle the values being compared, which often results in bugs.

Warning: the auto-fixer for this sniff _may_ cause bugs in applications and should be used with care!
This is considered a _risky_ fixer.

Includes fixer.
Includes unit tests.
Includes documentation.
Includes metrics.
New sniff to verify that a name being imported in an import use statement does not start with a leading backslash.

Names in import `use` statements should always be fully qualified, so a leading backslash is not needed and it is strongly recommended not to use one.

This sniff handles all types of import use statements supported by PHP, in contrast to any of the other sniffs for the same in, for instance, the PSR12 or the Slevomat standard, all of which are incomplete.

Includes fixer.
Includes unit tests.
Includes documentation.
Includes metrics.
…no-leading-backslash-sniff

New `Universal.UseStatements.NoLeadingBackslash` sniff
…sons-sniff

New `Universal.Operators.StrictComparisons` sniff
Add metrics to the sniff.

Example report:
```
PHP CODE SNIFFER INFORMATION REPORT
----------------------------------------------------------------------
Import use with leading backslash:
        yes   =>  6 ( 54.55%)
        no    =>  5 ( 45.45%)
        ----------------------
        total => 11 (100.00%)

----------------------------------------------------------------------
```
…-add-metrics

Universal/NoLeadingBackslash: add metrics
New sniff to disallow the use of namespace declarations without a namespace name.

Declaring a namespace declaration without a namespace name is only possible using the curly brace syntax and makes it so the code within the braces is considered to be in the global namespace.

A namespace declaration without curly braces without a name would be a parse error and will be ignored for the purposes of this sniff.

Includes unit tests.
Includes documentation.
Includes metrics.
…allowdeclarationwithoutname-sniff

New `Universal.Namespaces.DisallowDeclarationWithoutName` sniff
New sniff to enforce the use of the boolean `&&` and `||` operators instead of the logical `and`/`or` operators.

Note: as the [operator precedence](https://www.php.net/manual/en/language.operators.precedence.php) of the logical operators is significantly lower than the operator precedence of boolean operators, this sniff does not contain an auto-fixer.

Includes unit tests.
Includes documentation.
Includes metrics.
Add metrics to the sniff.

Example report:
```
PHP CODE SNIFFER INFORMATION REPORT
----------------------------------------------------------------------
Type of comparison used:
        loose  => 3 ( 60.00%)
        strict => 2 ( 40.00%)
        ----------------------
        total  => 5 (100.00%)

----------------------------------------------------------------------
```
…add-metrics

Universal/StrictComparisons: add metrics
…landor-sniff

New `Universal.Operators.DisallowLogicalAndOr` sniff
New sniff to verify that the names used in a class "implements" statement or an interface "extends" statement are listed in alphabetic order.

Notes:
* This sniff contains a public `orderby` property to determine the sort order to use for the statement.
    If all names used are unqualified, the sort order won't make a difference.
    However, if one or more of the names are partially or fully qualified, the chosen sort order will determine how the sorting between unqualified, partially and fully qualified names is handled.
    The sniff supports two sort order options:
    - 'name' : sort by the interface name only (default);
    - 'full' : sort by the full name as used in the statement (without leading backslash).
    In both cases, the sorting will be done using natural sort, case-insensitive.
* The sniff has modular error codes to allow for selective inclusion/exclusion:
    - `ImplementsWrongOrder` - for "class implements" statements.
    - `ImplementsWrongOrderWithComments` - for "class implements" statements interlaced with comments. These will not be auto-fixed.
    - `ExtendsWrongOrder` - for "interface extends" statements.
    - `ExtendsWrongOrderWithComments` - for "interface extends" statements interlaced with comments. These will not be auto-fixed.
* When fixing, the existing spacing between the names in an `implements`/`extends` statement will not be maintained.
    The fixer will separate each name with a comma and one space.
    If an alternative formatting is desired, a sniff which will check and fix the formatting should be added to the ruleset.

Includes fixer.
Includes unit tests.
Includes documentation.
Includes metrics.

Fixes 54
…4.1`

Support for the `installed_paths` being set when the plugin is a requirement of a standard itself, was only added in version `0.4.0` and a pertinent bug in this feature was fixed in `0.4.1`, which effectively makes version `0.4.1` the minimum workable version for both use as a stand-alone standard, as well as when this standard is required as a dependency.

Refs:
* https://github.com/Dealerdirect/phpcodesniffer-composer-installer/releases/tag/v0.4.0
* https://github.com/Dealerdirect/phpcodesniffer-composer-installer/releases/tag/v0.4.1
jrfnl and others added 27 commits May 6, 2020 00:45
…-plugin-dependency

Composer: set minimum Composer PHPCS plugin dependency version to `0.4.1`
…mplementsextends-sniff

New `Universal.OOStructures.AlphabeticExtendsImplements` sniff
New sniff to verify that `function` and `const` keywords when used in an import `use` statement are always lowercase.

Companion sniff to the upstream `Generic.PHP.LowerCaseKeyword` sniff which doesn't cover these keywords as they are not tokenized as `T_FUNCTION`/`T_CONST`, but as `T_STRING`.

Includes fixer.
Includes unit tests.
Includes documentation.
Includes metrics.

Related:
* squizlabs/PHP_CodeSniffer 2963
…-fix-fixed-test-case-filename

Universal.UseStatements.NoLeadingBackslash: fix filename of fixed test case file
…w-lowercasefunctionconst-sniff

New `Universal.UseStatements.LowercaseFunctionConst` sniff
The minimum supported version for this standard is PHPCS 3.3.1, while the bugs which necessitate sniffing for `T_OPEN_SQUARE_BRACKET` are from before that time, so just sniffing for `T_OPEN_SHORT_ARRAY` should work just fine.
The minimum supported version for this standard is PHPCS 3.3.1, while the bugs which necessitate sniffing for `T_OPEN_SQUARE_BRACKET` are from before that time, so just sniffing for `T_OPEN_SHORT_ARRAY` should work just fine.
…-shortlist-efficiency-fix

DisallowShort[Array|List]Syntax: register fewer tags
The DealerDirect Composer plugin has just released version `0.7.0`.
As Composer treats minors < 1.0 as majors, updating to this version requires an update to the `composer.json` requirements.

> For pre-1.0 versions it also acts with safety in mind and treats `^0.3` as `>=0.3.0 <0.4.0`.

Refs:
* https://github.com/Dealerdirect/phpcodesniffer-composer-installer/releases/tag/v0.7.0
* https://getcomposer.org/doc/articles/versions.md#caret-version-range-
…oser-plugin-version

Composer: update PHPCS Composer plugin dependency
Use `composer global` instead of a project local install for the CS check as PHPCSExtra will become a dependency of PHPCSDevCS and it would otherwise create a conflicting, circular dependency.

To make this simpler, split the old "Sniff" stage into "Sniff" and "Validate" and skip the `install` and `before_script` steps for the "Sniff" stage.
QA/CI: change the way the CS check is run
New sniff to verify that the PHP native magic constants are in uppercase when used.

Refs:
* https://www.php.net/manual/en/language.constants.predefined.php

Includes fixer.
Includes unit tests.
Includes documentation.
Includes metrics.
…sniff

New sniff to disallow the use of post-in/decrements in stand-alone statements and discourage the use of multiple increment/decrement operators in a stand-alone statement.

> Post-in/decrement returns the value and in/decrements afterwards.
> Pre-in/decrement in/decrements the value and returns afterwards.
> Using pre-in/decrement is more in line with the principle of least astonishment
> and prevents bugs when code gets moved around at a later point in time.

Includes fixer.
Includes unit tests.
Includes documentation.
Includes metrics.
…rcase-magic-constants-sniff

New `Universal.Constants.UppercaseMagicConstants` sniff
…llow-standalone-post-indecrement-sniff

New `Universal.Operators.DisallowStandalonePostIncrementDecrement` sniff
Up to now, the DealerDirect plugin was a blocker for testing the standard against PHP `nightly`/ PHP 8 as it would refuse to install.

With the new version having been tagged, this issue has been removed, so we can now run the unit tests against PHP 8 to get early warning about cross-version compatibility issues which need fixing.

The build against `nightly` remains in `allow_failures` for now.

Refs:
* https://github.com/Dealerdirect/phpcodesniffer-composer-installer/releases/tag/v0.7.0
Includes two minor code formatting tweaks elsewhere.
…or-tweaks

Test bootstrap: improve documentation and some minor code tweaks.
* Update the branch conditions for the Travis script.
* Update the badges in the Readme.
... in as far necessary.
Misc updates for the `master` branch being renamed to `stable`
…pha3

Changelog and readme updates for release `1.0.0-alpha3`
@jrfnl jrfnl added this to the 1.0.0-alpha3 milestone Jun 29, 2020
@jrfnl jrfnl merged commit a8415f9 into stable Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant