Part of #2571965: [meta] Fix PHP coding standards in core, stage 1

Remove all unused use statements and enable the rule.

To test the patches run phpcs -p --sniffs=Drupal.Classes.UnusedUseStatement from the core directory.

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Status: Active » Needs review
StatusFileSize
new51.29 KB

Status: Needs review » Needs work

The last submitted patch, 2: 2674408-2.patch, failed testing.

alexpott’s picture

Hmm... so the "Drupal.Classes.UnusedUseStatement" has some problems...

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new16.92 KB
new58.83 KB

Created #2674598: UnusedUseStatement sniff must not be case sensitive for the false positives because of case sensitivity.

Status: Needs review » Needs work

The last submitted patch, 5: 2674408-5.patch, failed testing.

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new1.41 KB
new59.64 KB

Rebased and found a couple more after.

alexpott’s picture

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

alexpott’s picture

StatusFileSize
new65.42 KB

Rerolled and re-ran phpcs to fix the rule - plenty of new instances being added to core all the time :(

Status: Needs review » Needs work

The last submitted patch, 10: 2674408-10.patch, failed testing.

The last submitted patch, 10: 2674408-10.patch, failed testing.

alexpott’s picture

This will need to be rerolled for 8.1.x...

alexpott’s picture

Issue summary: View changes
Status: Needs work » Needs review

So #10 passes on 8.2.x - to test this run phpcs -p --sniffs=Drupal.Classes.UnusedUseStatement from the core directory.

alexpott’s picture

StatusFileSize
new62.41 KB

Due to a revert against 8.2.x this patch needs a reroll - patch might apply to both 8.2.x and 8.1.x now :)

dawehner’s picture

Went through all classes.

+++ b/core/modules/field/tests/src/Kernel/WidgetPluginManagerTest.php
@@ -7,7 +7,6 @@
 use Drupal\Tests\field\Kernel\FieldKernelTestBase;

This class is unused

alexpott’s picture

StatusFileSize
new508 bytes
new62.45 KB

Great spot PHPStorm ;) Need to file a bug against coder.

@dawehner++

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

There we go!

alexpott’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new14.37 KB
new76.82 KB

I fixed the PHPCS rule in #2685877: Drupal.Classes.UnusedUseStatement misses some and ran it again...

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Oh wow, yeah all of those instances have been caused by myself quite recently.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.2.x and cherry-picked to 8.1.x. Thanks!

alexpott’s picture

Status: Fixed » Needs review
StatusFileSize
new561 bytes

A very small followup cause one got introduced and I don't think we should have a yet-another-unused-use-removal issue.

bojanz’s picture

Status: Needs review » Reviewed & tested by the community

Boom.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.2.x and cherry-picked to 8.1.x. Thanks!

  • catch committed 4d185fa on 8.2.x
    Issue #2674408 by alexpott, dawehner: Fix Drupal.Classes....

  • catch committed 00ebd9a on 8.2.x
    Issue #2674408 by alexpott, dawehner: Fix "Drupal.Classes....

  • catch committed ff9aa91 on 8.1.x
    Issue #2674408 by alexpott, dawehner: Fix "Drupal.Classes....
alexpott’s picture

Status: Fixed » Reviewed & tested by the community
StatusFileSize
new576 bytes

One more crept in...

I'm not opening a new issue because I don;t want additional review credit for this.

dawehner’s picture

+1

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 93f9d84 and pushed to 8.1.x and 8.2.x. Thanks!

  • alexpott committed 783fead on 8.2.x
    Issue #2674408 by alexpott, dawehner: Fix "Drupal.Classes....

  • alexpott committed 93f9d84 on 8.1.x
    Issue #2674408 by alexpott, dawehner: Fix "Drupal.Classes....
alexpott’s picture

Status: Fixed » Needs review
StatusFileSize
new10.45 KB

#2686207: Convert simpletest kernel tests in modules A-I to phpunit introduced a load more and because #2685877: Drupal.Classes.UnusedUseStatement misses some has not yet been released I missed them when I reviewed...

Status: Needs review » Needs work

The last submitted patch, 33: 2674408.33.patch, failed testing.

alexpott’s picture

Status: Needs work » Needs review

DrupalCI had a hiccup.

alexpott’s picture

Version: 8.2.x-dev » 8.1.x-dev
Issue tags: -needs backport to 8.1.x
StatusFileSize
new10.47 KB

Rerolled and now it applies to both 8.1.x and 8.2.x.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

So many real life usecases!

berdir’s picture

Looks good.

It's a bit annoying that you end up with those left-overs as phpstorm adds them when you move a class around but doesn't remove it when you add them back into the same namespac.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed f33830d and pushed to 8.1.x and 8.2.x. Thanks!

  • alexpott committed f3f3800 on 8.2.x
    Issue #2674408 by alexpott: Fix "Drupal.Classes.UnusedUseStatement"...

Status: Fixed » Closed (fixed)

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

JimmyAx’s picture

It looks like this commit is somehow breaking my site.
#2716827: OptionsProviderInterface::class is causing a fatal error