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

Prettify codebase #1079

Closed
wants to merge 1 commit into from
Closed

Prettify codebase #1079

wants to merge 1 commit into from

Conversation

DL6ER
Copy link
Member

@DL6ER DL6ER commented Dec 15, 2019

By submitting this pull request, I confirm the following:

  • I have read and understood the contributors guide, as well as this entire template.
  • I have made only one major change in my proposed changes.
  • I have commented my proposed changes within the code.
  • I have tested my proposed changes.
  • I am willing to help maintain this change if there are issues with it later.
  • I give this submission freely and claim no ownership.
  • It is compatible with the EUPL 1.2 license
  • I have squashed any insignificant commits. (git rebase)
  • I have Signed Off all commits. (git commit --signoff)

What does this PR aim to accomplish?:

Apply PSR-12 standard to all Pi-hole PHP files

How does this PR accomplish the above?:

Run

PHP_CodeSniffer/bin/phpcbf --standard=PSR12 /var/www/html/adminLTE/*.php
PHP_CodeSniffer/bin/phpcbf --standard=PSR12 /var/www/html/adminLTE/scripts/pi-hole/php/*.php
# check with phpcs, commit

There are no functional changes in this PR
I did extensive testing and couldn't find anything that broke with these changes.

@DL6ER DL6ER added this to the v5.0 milestone Dec 15, 2019
@DL6ER DL6ER requested a review from a team December 15, 2019 08:49
@DL6ER
Copy link
Member Author

DL6ER commented Dec 15, 2019

When the review process comes to the conclusion that this change is just adding noise to git blame and is not really worth it, it can be closed right away without any discussion. It was not more than 3 minutes of work and I'm perfectly fine with leaving the code as it is. We can still have an eye on newly submitted code and can write a small step-by-step guide how to set up the linter without needing to install anything globally on the system.

@PromoFaux
Copy link
Member

I'm happy to merge this . I don't think it will add too much noise when using git blame, just an extra commit to skip back through.

@XhmikosR
Copy link
Contributor

Just please keep this until the other PRs are merged first. Also do note that I have a WIP branch with proper linting for JS not just formatting.

@@ -10,7 +10,11 @@
<div class="panel panel-default">
<div class="panel-heading">
<div class="text-center">
<img src="img/logo.svg" alt="" style="width: <?php if ($boxedlayout) { ?>50%<?php } else { ?>30%<?php } ?>;">
<img src="img/logo.svg" alt="" style="width: <?php if ($boxedlayout) {
?>50%<?php
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO these kind of changes shouldn't be made. It's quite handy to use one-liners here

Copy link
Member Author

Choose a reason for hiding this comment

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

This was made by PHP CodeSniffer, I have not manually modified a single line in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, we need to tweak the config for sure. The defaults don't cover everything.

I can't find a project I was using to make the config generation easy... I'll try to find it because the defaults clearly cannot cover every case.

Copy link
Member Author

Choose a reason for hiding this comment

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

Mind that any non-standard configuration will make the entire thing harder. Right now, it is just an still fairly easily to memorize call phpcs --standard=PSR12 ...

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, the idea is that we don't remember anything. Instead we have scripts that we run. For the JS part this is easily done, but we could also add the phpcs script in the package.json file later.

Copy link
Member Author

Choose a reason for hiding this comment

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

As long as something will be fairly easily doable in the end, this will be fine with me. I'd prefer to be still able to develop from machines not having a web browser and/or php installed locally, but nothing is forbidden from the beginning here, everything is open for discussion.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can just have it to run on CI, that's OK too. As long as the patches are kept squashed, this is viable too.

@XhmikosR
Copy link
Contributor

XhmikosR commented Jan 3, 2020

@DL6ER can you apply this only for PHP files and also please post the instructions so that I can see if we can just add a script.

@DL6ER
Copy link
Member Author

DL6ER commented Jan 3, 2020

Everything is already in the pull request description.

@XhmikosR
Copy link
Contributor

XhmikosR commented Jan 3, 2020

Alright, so unless there's a clear way to automate this, it shouldn't land IMHO.

Everything should be automated, and right now it isn't.

@DL6ER
Copy link
Member Author

DL6ER commented Jan 3, 2020

I disagree. It brings everything in a certain shape. It's better to have 99% rather than 0% matching the preferred style.

We can easily run there steps I mentioned manually to ensure our code looks good.

Furthermore, this could easily be automated on the CI, but if we don't do this, it still makes sense to do it manually.

@XhmikosR
Copy link
Contributor

XhmikosR commented Jan 3, 2020

Well, I'm not going to do manual steps and neither should any contributor have to do something manually.

@DL6ER
Copy link
Member Author

DL6ER commented Jan 3, 2020

Reran phpcbf on current development.

@liamsorsby
Copy link

This could be done automatically using composer scripts (but that isn't used) and IMO I agree with the author of this PR. Linting code improves maintainability and code quality It should be enforced by the CI. Just because you don't want to do it, it doesn't mean that you shouldn't have to do it.

@DL6ER
Copy link
Member Author

DL6ER commented Apr 14, 2020

Resolved merge conflicts

@DL6ER DL6ER requested review from a team and removed request for a team April 14, 2020 20:22
@pralor-bot
Copy link

This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/php-webscripts/31016/8

@DL6ER
Copy link
Member Author

DL6ER commented Apr 28, 2020

Closing to reduce the reviewing workload

@DL6ER DL6ER closed this Apr 28, 2020
@XhmikosR XhmikosR deleted the tweak/linting branch May 17, 2020 08:11
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

5 participants