Skip to content

Fixes phpcs errors and warnings for Magento\Framework\Image #26036

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

Merged
merged 2 commits into from
Apr 10, 2020

Conversation

krisdante
Copy link
Contributor

@krisdante krisdante commented Dec 13, 2019

Description (*)

I was working with those classes and spotted a few warnings and errors
that prevent smooth pull requests. This PR fixes them.
It introduces Localized Exceptions in place of \Exception too.

Manual testing scenarios (*)

  1. vendor/bin/phpcs --standard=dev/tests/static/framework/Magento/ruleset.xml lib/internal/Magento/Framework/Image/

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Dec 13, 2019

Hi @krisdante. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

@krisdante krisdante changed the title Fixes phpcs errors and warnings for Magento\Framework\View\Element Fixes phpcs errors and warnings for Magento\Framework\Image Dec 13, 2019
@krisdante krisdante force-pushed the csfix-fw-image branch 2 times, most recently from 947174b to 9131cff Compare December 14, 2019 12:43
* If some folders of path does not exist they will be created
*
* @param null|string $destination
* @param null|string $newName
* @return void
* @throws \Exception If destination path is not writable
* @throws \Magento\Framework\Exception\LocalizedException If destination path is not writable
Copy link
Contributor

Choose a reason for hiding this comment

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

Use imported class name

@@ -241,7 +253,7 @@ public function crop($top = 0, $left = 0, $right = 0, $bottom = 0)
* @param bool $tile
* @return void
* @throws \LogicException
Copy link
Contributor

Choose a reason for hiding this comment

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

Import class.

@ghost ghost assigned lbajsarowicz Dec 14, 2019
@krisdante krisdante force-pushed the csfix-fw-image branch 3 times, most recently from 8360c5a to 61d5a4b Compare December 17, 2019 22:43
*
* @param $positionX
* @param $positionY
* @param \Imagick $watermark
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd import the \Imagick class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is the benefit of such import?

Copy link
Contributor

Choose a reason for hiding this comment

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

The imports are consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I followed this suggestion and phpstan raged. Reversing

@lbajsarowicz
Copy link
Contributor

@krisdante Fix the Static tests and import Imagick class, then I'll approve PR 👍

@lbajsarowicz
Copy link
Contributor

@magento run tests

@krisdante
Copy link
Contributor Author

Jezus this is boring.... what now. Why the way to test is locally is not documented. phpcs is passing for me.

@krisdante krisdante force-pushed the csfix-fw-image branch 2 times, most recently from 9a2190a to a54e356 Compare January 18, 2020 10:33
I was working with those classes and spotted a few warnings and errors
that prevent from smooth pull requests. This PR fixes them.

It introduces Localized Exceptions in place of \Exception too.

Watermark method was to long so it was devided to separate parts
@krisdante
Copy link
Contributor Author

krisdante commented Jan 18, 2020

/usr/bin/php /var/www/magentosrc/./vendor/phpunit/phpunit/phpunit -v --testdox testsuite/Magento/Test/Php/LiveCodeTest.php
PHPUnit 6.5.14 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.1.27 with Xdebug 2.7.2
Configuration: /var/www/creativeshop/magentosrc/dev/tests/static/phpunit.xml.dist

Magento\Test\Php\LiveCode
 [x] Code style
 [x] Code mess
 [x] Copy paste
 [x] Strict types
 [x] Php compatibility
 [x] Php stan

Those tests are passing with my clone of Magento. I do not know why they are failing for B2B test here. I cannot reproduce it. Also, the failed functional test has nothing to do with the change here .

@lbajsarowicz
Copy link
Contributor

@krisdante Don't worry about Functional Tests - this is known bug of Magento 2.4-develop branch and will be merged soon to 2.4-develop (then you'll be able to rebase your branch onto it). Unless - just fix static tests.or optionally restart them if you believe that your code is fine.

Use

@magento run Static Tests

@krisdante
Copy link
Contributor Author

I do not know how to fix them. They are passing on local. See my message.

@lbajsarowicz
Copy link
Contributor

lbajsarowicz commented Jan 22, 2020

@krisdante Let me ping the right person for that kind of issue.
Looks like a missing library in the Testing environment...

@lenaorobei
Copy link
Contributor

This issue is caused because ImageMagick adapter is non default one and can be configured.

Please add lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php to the dev/tests/static/testsuite/Magento/Test/Php/_files/phpstan/blacklist/common.txt.

ImageMagick adapter is non default one and can be configured
It is not included in Test Enviroment
@krisdante
Copy link
Contributor Author

@lbajsarowicz I did. Static tests are now passing. Failing B2B test is irrelevant.

Copy link
Contributor

@lbajsarowicz lbajsarowicz left a comment

Choose a reason for hiding this comment

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

Thank you for the great contribution!

@magento-engcom-team
Copy link
Contributor

Hi @lbajsarowicz, thank you for the review.
ENGCOM-7260 has been created to process this Pull Request
✳️ @lbajsarowicz, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@krisdante
Copy link
Contributor Author

This DB error is false. I am not going to re-run this test anymore. Merge it or delete the whole PR.

@lbajsarowicz
Copy link
Contributor

@krisdante Don't worry about false negatives. These are also verified manually by Commeng team, so as long as it's false negative, we're able to skip it.

@engcom-Alfa
Copy link
Contributor

✔️ QA Passed

vendor/bin/phpcs --standard=dev/tests/static/framework/Magento/ruleset.xml lib/internal/Magento/Framework/Image/

Before:
Screenshot from 2020-04-07 14-27-30

After:
phpcs

@engcom-Echo
Copy link
Contributor

Failed Database Compare not related to the changes in this PR

@engcom-Echo engcom-Echo self-assigned this Apr 8, 2020
@VladimirZaets VladimirZaets added this to the 2.4.0 milestone Apr 8, 2020
@VladimirZaets VladimirZaets added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. labels Apr 8, 2020
@slavvka slavvka added the Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests label Apr 8, 2020
@magento-engcom-team magento-engcom-team merged commit bd3d7eb into magento:2.4-develop Apr 10, 2020
@m2-assistant
Copy link

m2-assistant bot commented Apr 10, 2020

Hi @krisdante, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@krisdante krisdante deleted the csfix-fw-image branch April 10, 2020 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests Component: Image Component: View Event: Global-Contribution-Day Partner: creativestyle partners-contribution Pull Request is created by Magento Partner Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: accept Release Line: 2.4 Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants