Follow-up to #2887052: Ignore Diff component files in phpcs coding standards
Problem/Motivation
We hav following files in core with @codingStandardsIgnoreFile comment.
core/lib/Drupal/Core/Archiver/ArchiveTar.php
core/lib/Drupal/Core/Command/DbDumpCommand.php
core/lib/Drupal/Core/Command/GenerateProxyClassCommand.php
core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php
core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php
core/lib/Drupal/Core/ProxyClass/Batch/BatchStorage.php
core/lib/Drupal/Core/ProxyClass/Config/ConfigInstaller.php
core/lib/Drupal/Core/ProxyClass/Cron.php
core/lib/Drupal/Core/ProxyClass/Entity/ContentUninstallValidator.php
core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php
core/lib/Drupal/Core/ProxyClass/Extension/RequiredModuleUninstallValidator.php
core/lib/Drupal/Core/ProxyClass/Field/FieldModuleUninstallValidator.php
core/lib/Drupal/Core/ProxyClass/File/MimeType/ExtensionMimeTypeGuesser.php
core/lib/Drupal/Core/ProxyClass/File/MimeType/MimeTypeGuesser.php
core/lib/Drupal/Core/ProxyClass/Lock/DatabaseLockBackend.php
core/lib/Drupal/Core/ProxyClass/Lock/PersistentDatabaseLockBackend.php
core/lib/Drupal/Core/ProxyClass/PageCache/ChainResponsePolicy.php
core/lib/Drupal/Core/ProxyClass/ParamConverter/AdminPathConfigEntityConverter.php
core/lib/Drupal/Core/ProxyClass/ParamConverter/MenuLinkPluginConverter.php
core/lib/Drupal/Core/ProxyClass/Plugin/CachedDiscoveryClearer.php
core/lib/Drupal/Core/ProxyClass/Render/BareHtmlPageRenderer.php
core/lib/Drupal/Core/ProxyClass/Routing/MatcherDumper.php
core/lib/Drupal/Core/ProxyClass/Routing/RouteBuilder.php
core/modules/book/src/ProxyClass/BookUninstallValidator.php
core/modules/field/src/ProxyClass/FieldUninstallValidator.php
core/modules/filter/src/ProxyClass/FilterUninstallValidator.php
core/modules/forum/src/ProxyClass/ForumUninstallValidator.php
core/modules/language/src/ProxyClass/LanguageConverter.php
core/modules/migrate_drupal/tests/fixtures/drupal6.php
core/modules/migrate_drupal/tests/fixtures/drupal7.php
core/modules/node/src/ProxyClass/ParamConverter/NodePreviewConverter.php
core/modules/simpletest/files/php-1.txt
core/modules/simpletest/files/php-2.php
core/modules/system/tests/fixtures/update/drupal-8.language-enabled.php
core/modules/system/tests/src/Kernel/Scripts/DbDumpCommandTest.php
core/modules/user/src/MigratePassword.php
core/modules/user/src/UserServiceProvider.php
core/modules/views_ui/src/ProxyClass/ParamConverter/ViewUIConverter.php
core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.phpThe apporach has been confirmed by @xjm in #2887052: Ignore Diff component files in phpcs coding standards.
Proposed resolution
Come up with the pattern(s) in core/phpcs.xml.dist so that we can ignore them cleanly.
Remaining tasks
- Create pattern(s).
- Create patch.
- Review.
- RTBC.
- Commit.
User interface changes
None
API changes
None
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | remove-2891586-16.patch | 19.58 KB | jibran |
| #12 | remove-2891586-11.patch | 20.18 KB | jibran |
Comments
Comment #2
jibranOnly files with
@codingStandardsIgnoreFilein core right now areWe should remove the files anyway.
Comment #4
jibran:/
Comment #5
tstoecklerSo the proxy classes and database dump files are auto-generated by
\Drupal\Core\Command\GenerateProxyClassCommandand\Drupal\Core\Command\DbDumpCommand, respectively. So we need to remove that line from the templates in those files. And ideally re-run them (at least on a couple files) to validate that the output still matches.Comment #6
jibranI ran
GenerateProxyClassCommandonce for core and once for modules. Feel free to verify theDbDumpCommand.Comment #7
jibranThat's already done.
Comment #8
tstoecklerOops, I am a total dummy. Sorry about that!
Comment #9
xjmI'm not sure about this; it's really broad. There are a lot more fixtures than the ones ignored:
Also, most of those 111 files are not intentionally empty or violating coding standards (which is what the header comment says).
Hm, can we confirm with references that these should be considered "third-party code"? A blame/reference of the issue that added the the ignore would be nice to confirm this.
Nit: auto-generated.
Also, it looks like this is missing an initial space. I introduced that problem in the other patch I think. The comment on the first section has neither an initial nor trailing space; the later ones have both initial and trailing spaces. AFAIK initial and trailing spaces are the correct standard.
I wasn't sure about this, but I did confirm that the namespace for the proxy class is enforced:
I wonder if we could use something narrower than
*? OTOH it's not that likely that we're going to add other things with this namespace pattern if they aren't the generated classes.Comment #10
xjmAnother thing to note is that a trailing asterisk doesn't seem to be necessary to recursively match all the files within a directory (see the diff rule and others). So we could probably be consistent about that too.
Comment #11
xjmFor #2, I noticed this as well when looking into the other issue. Yet another issue probably? And 8.4.x-only for that issue since (unfortunately) file removals can be disruptive when backported.
If we tighten the rules up on this one, I think we can probably consider it for backport since then it would just be implementing the same coding standards coverage and avoiding branch divergence.
Thanks!
Comment #12
jibranThanks, for the review.
Comment #13
xjmThe thing is it's not just one or a handful of files. There are over 100 test fixtures, 57 of which are PHP files, and clearly the majority already comply with our coding standards. I don't think we should disregard coding standards on arbitrary PHP test fixtures.
Ideally this patch would mostly replace the current ignore comments so that the same files are ignored, rather than significantly broadening the scope of what's ignored.
Thanks for the issue links in #12.2. It doesn't look like any of those issues added the comments to ignore the files though? Edit: What I'm trying to get at is the reasoning behind the decision to ignore them in each case, which presumably is discussed in the issues where we started ignoring them.
Comment #14
jibranSorry, I linked to the original issues in which file we introduced.
These are the issues which added the ignore comment to those files #2572307: Fix 'Generic.PHP.UpperCaseConstant' coding standard and #2572619: Fix 'Drupal.Classes.ClassDeclaration' coding standard.
Comment #16
jibranReroll after #2887052: Ignore Diff component files in phpcs coding standards.
@xjm how would you like to proceed with this?
Comment #24
quietone commentedClosing as a duplicate of #3207968: Replace @codingStandards comments with phpcs: comments.