I have noticed that there are lots of unused use statements in the code.
I did a clean up in the attached patch.
Regards,

Comments

bertonha created an issue. See original summary.

bertonha’s picture

Please kindly check the patch attached in here

idebr’s picture

Title: Lots of unused use statements » Remove unused use statements
Status: Needs review » Needs work

Hi bertonha, thanks for reporting this issue!

After applying the patch there are still a few unused use statements in the Redirect repository. I suggest we clean these up as well:

$ phpcs . --sniffs=Drupal.Classes.UnusedUseStatement --standard=Drupal

FILE: /.../tests/src/Unit/RedirectRequestSubscriberTest.php
-------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------
 8 | WARNING | [x] Unused use statement
-------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------


FILE: /.../modules/redirect_404/src/Render/Redirect404LogSuppressor.php
-------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------
 7 | WARNING | [x] Unused use statement
-------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------
mahipal46’s picture

Assigned: Unassigned » mahipal46
mahipal46’s picture

Applying Patch. Please Review.

mahipal46’s picture

Assigned: mahipal46 » Unassigned
Status: Needs work » Needs review
idebr’s picture

Category: Bug report » Task
Status: Needs review » Reviewed & tested by the community

Thanks! phpcs . --sniffs=Drupal.Classes.UnusedUseStatement --standard=Drupal no longer reports any unused statements.

pifagor’s picture

Hello @berdir, any news here?

idebr’s picture

Status: Reviewed & tested by the community » Needs work

Patch no longer applies cleanly, and there are two more unused use statements:

FILE: ./redirect/tests/src/Functional/RedirectUITest.php
------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------------
 5 | WARNING | [x] Unused use statement
------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------


FILE: ./redirect/src/EventSubscriber/RedirectRequestSubscriber.php
----------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------
 5 | WARNING | [x] Unused use statement
----------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------
Deeksha B’s picture

Status: Needs work » Needs review
StatusFileSize
new5.15 KB

Please review the patch.

lucienchalom’s picture

StatusFileSize
new3.89 KB

the patch needed a reroll.

beatrizrodrigues’s picture

Assigned: Unassigned » beatrizrodrigues

I'll do the review.

beatrizrodrigues’s picture

Assigned: beatrizrodrigues » Unassigned
StatusFileSize
new4.33 KB
new342 bytes

I will leave it in needs review because I found a unused use statement in Drupal\Tests\redirect\Functional\GlobalRedirectTest. Sending new patch and a interdiff.

anagomes’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #13 applies correctly and solves all warnings about unused use statements.

kristen pol’s picture

Assigned: Unassigned » kristen pol

Assigning to myself as I'm triaging all RTBC issues.

kristen pol’s picture

I'm crediting everyone on this issue although the patch didn't fully apply. I manually fixed the missing item. Merge will happen shortly. See notes below.

@mahipal46 @Deeksha B In the future, please include an interdiff when updating unless it's a reroll. If it's a reroll, then explain that. Thanks.

@anagomes Thanks for the review. It would be good to know how you reviewed when marking something RTBC. In this case, I assume you ran phpcs . --sniffs=Drupal.Classes.UnusedUseStatement --standard=Drupal after applying the patch but it's important to be explicit in your comment so we know how something has been tested/reviewed. Thanks.

patch worked for these:


[ok] * modules/redirect_404/src/Render/Redirect404LogSuppressor.php
-use Drupal\Core\Logger\LoggerChannelFactory;

[ok] * modules/redirect_404/tests/src/Functional/Redirect404TestBase.php
-use Drupal\Component\Render\FormattableMarkup;

[ok] * redirect.generate.inc
-use Drupal\Component\Utility\Random;

[ok] * redirect.module
-use Drupal\Core\Database\Query\Condition;

[ok] * src/Plugin/Field/FieldWidget/RedirectSourceWidget.php
-use Drupal\Component\Utility\NestedArray;

[ok] * tests/src/Functional/GlobalRedirectTest.php
-use Drupal\Core\Cache\Cache;

[ok] * tests/src/Functional/RedirectUITest.php
-use Drupal\Component\Render\FormattableMarkup;

manually fixed with phpcbf . --sniffs=Drupal.Classes.UnusedUseStatement --standard=Drupal:

[ok] * tests/src/Unit/RedirectCheckerTest.php
-use Symfony\Cmf\Component\Routing\RouteObjectInterface; [used in commented-out code]

rejected in patch:

* tests/src/Unit/RedirectCheckerTest.php
* tests/src/Unit/RedirectRequestSubscriberTest.php

kristen pol’s picture

Assigned: kristen pol » Unassigned
Status: Reviewed & tested by the community » Fixed

Merged. This will be included in the next release.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.