Skip to content

Minor update whitespace PHPCS rules#6666

Merged
Alkarex merged 5 commits intoFreshRSS:edgefrom
Alkarex:phpcs-psr12
Aug 1, 2024
Merged

Minor update whitespace PHPCS rules#6666
Alkarex merged 5 commits intoFreshRSS:edgefrom
Alkarex:phpcs-psr12

Conversation

@Alkarex
Copy link
Member

@Alkarex Alkarex commented Jul 30, 2024

To simplify our PHPCS configuration, apply more rules, and be clearer about what is added or removed compared with PSR12.
Does not change our current conventions, but just a bit more consistent.

Useful commands:

make test-all
make fix-all
# or individually:
composer run-script phpcs
composer run-script phpcbf

To simplify our configuration, apply more rules, and be clearer about what is added or removed compared with PSR12.
Does not change our current conventions, but just a bit more consistent.
@Alkarex Alkarex added the System care Everything related to system care label Jul 30, 2024
@Alkarex Alkarex added this to the 1.24.2 milestone Jul 30, 2024
@Alkarex Alkarex mentioned this pull request Jul 30, 2024
2 tasks
Comment on lines -82 to -83
switch($type_get) {
case 'c':
Copy link
Member Author

Choose a reason for hiding this comment

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

Most modified lines are due to wrongly indented switch cases.

@Alkarex
Copy link
Member Author

Alkarex commented Jul 30, 2024

@math-GH FYI, in VS Code, the extension https://marketplace.visualstudio.com/items?itemName=ValeryanM.vscode-phpsab will offer live feedback about those PHPCS rules, including whitespace:

image

image

@Alkarex
Copy link
Member Author

Alkarex commented Aug 1, 2024

Any comment @Frenzie ?

Copy link
Member

@Frenzie Frenzie left a comment

Choose a reason for hiding this comment

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

Any comment @Frenzie ?

I left some stray thoughts. I think some of the phpcs rules are overzealous resulting in reduced clarity but it's not a big deal either.

case 'M': case 'm': return (int)$size_str;
case 'K': case 'k': return (int)$size_str / 1024;
case 'G': case 'g': return (int)$size_str * 1024;
case 'M':
Copy link
Member

Choose a reason for hiding this comment

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

I personally prefer indented case inside switch statements. But when I set up the rules I tried to make them as close to the existing style as possible, not to add in my own opinion. ;-)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, me too, and it is also more common to have indented cases in switches, I believe

private function getFilenamePrefix(string $key): string {
return preg_replace('/\..*/', '.php', $key) ?? '';
}

Copy link
Member

Choose a reason for hiding this comment

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

This strikes me as a potentially somewhat unfortunate thing to enforce.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I will exclude a few more rules

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

p/api/fever.php Outdated
* See https://github.com/dasmurphy/tinytinyrss-fever-plugin
*/

declare(strict_types=1);
Copy link
Member

Choose a reason for hiding this comment

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

Meh, reduces clarity by hiding it further down.

Copy link
Member Author

Choose a reason for hiding this comment

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

Rule about headers order disabled

as $entry) {
$type, $id, FreshRSS_Context::$state, FreshRSS_Context::$order,
$postsPerPage ?? FreshRSS_Context::$number, FreshRSS_Context::$offset, FreshRSS_Context::$first_id,
FreshRSS_Context::$search, $date_min) as $entry) {
Copy link
Member

Choose a reason for hiding this comment

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

Also clarity reduction.

Copy link
Member Author

Choose a reason for hiding this comment

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

Disabling Squiz.ControlStructures.ForEachLoopDeclaration.SpacingBeforeAs completely would prevent checking spaces in foreach ($list as $item) {}, and since the problem occurs only once in the whole codebase, I came with another workaround

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I didn't mean to insist too strongly. :-)

@Alkarex Alkarex merged commit d224722 into FreshRSS:edge Aug 1, 2024
@Alkarex Alkarex deleted the phpcs-psr12 branch August 1, 2024 18:31
Alkarex added a commit to FreshRSS/Extensions that referenced this pull request Aug 1, 2024
* Align CI rules with main FreshRSS repository
Including:
* FreshRSS/FreshRSS#6666
* FreshRSS/FreshRSS#6668

* Sync FreshRSS
Alkarex added a commit to Alkarex/FreshRSS that referenced this pull request Oct 15, 2024
Regression from FreshRSS#6666
We were not checking anymore for whitespace rules in e.g. `if (true) {`
Alkarex added a commit that referenced this pull request Oct 15, 2024
Regression from #6666
We were not checking anymore for whitespace rules in e.g. `if (true) {`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

System care Everything related to system care

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants