Postponed on #3221049: Let ShortNotCapital allow starting with some characters that do not have case See #72

Part of meta-issue #2571965: [meta] Fix PHP coding standards in core

Step 1: Preparation

Open the file core/phpcs.xml.dist and add a line for the sniff of this ticket. The sniff name is in the issue title. Make sure your patch will include the addition of this line.

Step 2: Install & configure PHPCS

Install PHP CodeSniffer and the ruleset from the Coder module:

$ composer install
$ ./vendor/bin/phpcs --config-set installed_paths ../../drupal/coder/coder_sniffer

Once you have installed the phpcs package, you can list all the sniffs available to you like this:

$ ./vendor/bin/phpcs --standard=Drupal -e

This will give you a big list of sniffs, and the Drupal-based ones should be present.

Step 3: Prepare the phpcs.xml file

To speed up the testing you should make a copy of the file phpcs.xml.dist (in the core/ folder) and save it as phpcs.xml. This is the configuration file for PHP CodeSniffer.

We only want this phpcs.xml file to specify the sniff we're interested in. So we need to remove all the rule items, and add only our own sniff's rule. Rule items look like this:

<rule ref="Drupal.Classes.UnusedUseStatement"/>

Remove all of them, and add only the sniff from this issue title. This will make sure that our tests run quickly, and are not going to contain any output from unrelated sniffs.

Step 4: Run the test

Now you are ready to run the test! From within the core/ folder, run the following command to launch the test:

$ cd core/
$ ../vendor/bin/phpcs -p

This takes a couple of minutes. The -p flag shows the progress, so you have a bunch of nice dots to look at while it is running.

Step 5: Fix the failures

When the test is complete it will present you a list of all the files that contain violations of your sniff, and the line numbers where the violations occur. You could fix all of these manually, but thankfully phpcbf can fix many of them. You can call phpcbf like this:

$ ../vendor/bin/phpcbf

This will fix the errors in place. You can then make a diff of the changes using git. You can also re-run the test with phpcs and determine if that fixed all of them.

Issue fork drupal-2903027

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mfernea created an issue. See original summary.

mfernea’s picture

Assigned: Unassigned » mfernea
mfernea’s picture

Assigned: mfernea » Unassigned
Status: Active » Needs work
FileSize
37.29 KB

Partial work.

savkaviktor16@gmail.com’s picture

Issue tags: +Needs reroll

going to reroll it

savkaviktor16@gmail.com’s picture

jofitz’s picture

Status: Needs work » Needs review

The last submitted patch, 3: drupal-coding-standards-2903027-2.patch, failed testing. View results

savkaviktor16@gmail.com’s picture

Added some part of work an additional
@Jo, it may be useful don't put it to status "Needs review" until work done?

jofitz’s picture

I set the status to "Needs review" to run the testbot on the patch you had re-rolled. Why did you not want it run? Similarly, why have you not set the status to "Needs review for your latest patch in #8?

savkaviktor16@gmail.com’s picture

I set the status to "Needs work" because the task isn`t finished (I did it similarly to the comment #3)
Anyway, I`m willing to get all the remarks/advises about work process. I`m new in contribution ) Thanks

andypost’s picture

Status: Needs work » Needs review

It makes sense to run tests anyway - to get stats about how many inconsistencies left

Status: Needs review » Needs work

The last submitted patch, 8: drupal-coding-standards-2903027-8.patch, failed testing. View results

savkaviktor16@gmail.com’s picture

Issue tags: +Needs reroll
jofitz’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
58.58 KB

Re-rolled.

@Saviktor Are you working against the latest version of the 8.5.x branch? That might explain why your patch failed to apply.

Status: Needs review » Needs work

The last submitted patch, 14: 2903027-14.patch, failed testing. View results

jofitz’s picture

Status: Needs work » Needs review
FileSize
0 bytes

Patch in #14 no longer applies. Re-rolled.

Status: Needs review » Needs work

The last submitted patch, 16: 2903027-16.patch, failed testing. View results

jofitz’s picture

Status: Needs work » Needs review
FileSize
58.63 KB

Re-rolled #14.

mfernea’s picture

Status: Needs review » Needs work

The patch contains a lot of modifications which are out of scope. Please remove them. At 17 I also pointed out another type of issue.

  1. +++ b/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
    @@ -151,9 +151,9 @@ public function testTimestamp($input, array $initial, array $transform) {
        * @param string $input
        *   Input argument for DateTimePlus().
        * @param array $initial
    -   *   @see testTimestamp()
        * @param array $transform
    -   *   @see testTimestamp()
    +   *
    +   * @see testTimestamp()
    

    Out of scope.

  2. +++ b/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
    @@ -164,17 +164,16 @@ public function testDateTimestamp($input, array $initial, array $transform) {
    -   * Assertion helper for testTimestamp and testDateTimestamp since they need
    -   * different dataProviders.
    +   * Assertion helper for testTimestamp and testDateTimestamp since they need different dataProviders.
        *
        * @param DateTimePlus $date
        *   DateTimePlus to test.
    -   * @input mixed $input
    +   * @param mixed $input
        *   The original input passed to the test method.
        * @param array $initial
    -   *   @see testTimestamp()
        * @param array $transform
    -   *   @see testTimestamp()
    +   *
    +   * @see testTimestamp()
        */
    

    Out of scope.

  3. +++ b/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
    @@ -247,8 +246,7 @@ public function testInvalidDates($input, $timezone, $format, $message, $class) {
    -   * Tests that DrupalDateTime can detect the right timezone to use.
    -   * When specified or not.
    +   * Tests that DrupalDateTime can detect the right timezone to use. When specified or not.
    

    Out of scope.

  4. +++ b/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
    @@ -268,8 +266,7 @@ public function testDateTimezone($input, $timezone, $expected_timezone, $message
    -   * Test that DrupalDateTime can detect the right timezone to use when
    -   * constructed from a datetime object.
    +   * Test that DrupalDateTime can detect the right timezone to use when constructed from a datetime object.
    

    Out of scope.

  5. +++ b/core/tests/Drupal/Tests/Component/Utility/EnvironmentTest.php
    @@ -17,9 +17,6 @@ class EnvironmentTest extends TestCase {
    -   * @dataProvider providerTestCheckMemoryLimit
    -   * @covers ::checkMemoryLimit
    -   *
        * @param string $required
        *   The required memory argument for
        *   \Drupal\Component\Utility\Environment::checkMemoryLimit().
    @@ -29,6 +26,9 @@ class EnvironmentTest extends TestCase {
    
    @@ -29,6 +26,9 @@ class EnvironmentTest extends TestCase {
        * @param bool $expected
        *   The expected return value from
        *   \Drupal\Component\Utility\Environment::checkMemoryLimit().
    +   *
    +   * @dataProvider providerTestCheckMemoryLimit
    +   * @covers ::checkMemoryLimit
        */
    

    Out of scope.

  6. +++ b/core/tests/Drupal/Tests/Component/Utility/VariableTest.php
    @@ -64,17 +64,17 @@ public function providerTestExport() {
    -        // 2 backslashes. \\
    +        // 2 backslashes \\.
             "'\\'",
             '\\',
           ],
           [
    -        // Double-quote "
    +        // Double-quote ".
             "'\"'",
             "\"",
           ],
           [
    -        // Single-quote '
    +        // Single-quote '.
    

    Out of scope.

  7. +++ b/core/tests/Drupal/Tests/Component/Utility/VariableTest.php
    @@ -100,13 +100,13 @@ public function providerTestExport() {
    -   * @dataProvider providerTestExport
    -   * @covers ::export
    -   *
        * @param string $expected
        *   The expected exported variable.
        * @param mixed $variable
        *   The variable to be exported.
    +   *
    +   * @dataProvider providerTestExport
    +   * @covers ::export
        */
    

    Out of scope.

  8. +++ b/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php
    @@ -884,16 +884,15 @@ public function testOrIfCacheabilityMerging() {
    -   * @covers ::allowedIfHasPermissions
    -   *
    -   * @dataProvider providerTestAllowedIfHasPermissions
    -   *
        * @param string[] $permissions
        *   The permissions to check for.
        * @param string $conjunction
        *   The conjunction to use when checking for permission. 'AND' or 'OR'.
        * @param \Drupal\Core\Access\AccessResult $expected_access
        *   The expected access check result.
    +   *
    +   * @dataProvider providerTestAllowedIfHasPermissions
    +   * @covers ::allowedIfHasPermissions
    

    Out of scope.

  9. +++ b/core/tests/Drupal/Tests/Core/Common/AttributesTest.php
    @@ -57,7 +57,7 @@ public function testDrupalAttributes($attributes, $expected, $message) {
    -   * Test attribute iteration
    +   * Test attribute iteration.
    

    Out of scope.

  10. +++ b/core/tests/Drupal/Tests/Core/Config/CachedStorageTest.php
    @@ -14,6 +14,8 @@
    +   * The cache factory.
    +   *
        * @var \Drupal\Core\Cache\CacheFactoryInterface|\PHPUnit_Framework_MockObject_MockObject
    

    Out of scope.

  11. +++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php
    @@ -30,8 +30,7 @@ protected function setUpConfigEntityType($definition) {
    -   * Tests that we get an exception when the length of the config prefix that is
    -   * returned by getConfigPrefix() exceeds the maximum defined prefix length.
    +   * Tests that we get an exception when the length of the config prefix that is returned by getConfigPrefix() exceeds the maximum defined prefix length.
    
    @@ -51,8 +50,7 @@ public function testConfigPrefixLengthExceeds() {
    -   * Tests that a valid config prefix returned by getConfigPrefix()
    -   * does not throw an exception and is formatted as expected.
    +   * Tests that a valid config prefix returned by getConfigPrefix() does not throw an exception and is formatted as expected.
    

    Out of scope.

  12. +++ b/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php
    @@ -197,7 +197,7 @@ public function testFindSitePath() {
    -   * A fake autoloader for testing
    +   * A fake autoloader for testing.
    
    +++ b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php
    @@ -152,7 +152,7 @@ public function testGetModuleList() {
    -   * Confirm we get back a module from the module list
    +   * Confirm we get back a module from the module list.
    

    Out of scope.

  13. +++ b/core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php
    @@ -83,14 +83,13 @@ public function testIsDefault() {
    -   * @covers ::sort
    -   *
    -   * @dataProvider providerTestSortArrayOfLanguages
    -   *
        * @param \Drupal\Core\Language\LanguageInterface[] $languages
        *   An array of language objects.
        * @param array $expected
        *   The expected array of keys.
    +   *
    +   * @dataProvider providerTestSortArrayOfLanguages
    +   * @covers ::sort
    

    Out of scope.

  14. +++ b/core/tests/Drupal/Tests/Core/ParamConverter/EntityConverterTest.php
    @@ -95,7 +95,7 @@ public function testConvert($value, array $definition, array $defaults, $expecte
    -   * Provides test data for testConvert
    +   * Provides test data for testConvert.
    

    Out of scope.

  15. +++ b/core/tests/Drupal/Tests/Core/Path/PathValidatorTest.php
    @@ -26,6 +26,7 @@ class PathValidatorTest extends UnitTestCase {
    +   *
    

    Out of scope.

  16. +++ b/core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php
    @@ -396,7 +396,7 @@ public function testMergeAttachmentsFeedMerging($a, $b, $expected) {
    -   * Data provider for testMergeAttachmentsFeedMerging
    +   * Data provider for testMergeAttachmentsFeedMerging.
    
    @@ -455,7 +455,7 @@ public function testMergeAttachmentsHtmlHeadMerging($a, $b, $expected) {
    -   * Data provider for testMergeAttachmentsHtmlHeadMerging
    +   * Data provider for testMergeAttachmentsHtmlHeadMerging.
    
    @@ -528,7 +528,7 @@ public function testMergeAttachmentsHtmlHeadLinkMerging($a, $b, $expected) {
    -   * Data provider for testMergeAttachmentsHtmlHeadLinkMerging
    +   * Data provider for testMergeAttachmentsHtmlHeadLinkMerging.
    
    @@ -594,7 +594,7 @@ public function testMergeAttachmentsHttpHeaderMerging($a, $b, $expected) {
    -   * Data provider for testMergeAttachmentsHttpHeaderMerging
    +   * Data provider for testMergeAttachmentsHttpHeaderMerging.
    

    Out of scope.

  17. +++ b/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php
    @@ -26,7 +26,7 @@ protected function setUpRenderRecursionComplexElements() {
    -   * ::renderRoot() may not be called inside of another ::renderRoot() call.
    +   * The method ::renderRoot() may not be called inside of another ::renderRoot() call.
    

    Let's try to not add new issues.

  18. +++ b/core/tests/Drupal/Tests/Core/Routing/RouteMatchTestBase.php
    @@ -22,6 +22,7 @@
    +   *
        * @return \Drupal\Core\Routing\RouteMatchInterface
    

    Out of scope.

  19. +++ b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
    @@ -175,8 +175,7 @@ protected function setUp() {
    -   * Return value callback for the getAliasByPath() method on the mock alias
    -   * manager.
    +   * Return value callback for the getAliasByPath() method on the mock alias manager.
    

    Out of scope.

  20. +++ b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
    @@ -429,7 +428,7 @@ public function testAbsoluteURLGenerationUsingInterfaceConstants() {
    -   * Confirms that explicitly setting the base_url works with generated routes
    +   * Confirms that explicitly setting the base_url works with generated routes.
    

    Out of scope.

  21. +++ b/core/tests/Drupal/Tests/Core/Site/SettingsTest.php
    @@ -66,7 +66,7 @@ public function testGetInstance() {
    -   * Tests Settings::getHashSalt();
    +   * Tests Settings::getHashSalt().
        *
    

    Out of scope.

  22. +++ b/core/tests/Drupal/Tests/Core/StackMiddleware/NegotiationMiddlewareTest.php
    @@ -20,6 +20,8 @@
    +   * The app kernel.
    +   *
    
    +++ b/core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php
    @@ -33,6 +33,7 @@ protected function setUp() {
    +   *
    
    +++ b/core/tests/Drupal/Tests/Core/Template/AttributeTest.php
    @@ -74,6 +74,7 @@ public function testRemove() {
    +   *
    
    @@ -102,6 +103,7 @@ public function testSetAttribute() {
    +   *
    
    @@ -141,6 +143,7 @@ public function testRemoveAttribute() {
    +   *
    
    @@ -193,6 +196,7 @@ public function testAddClasses() {
    +   *
    
    @@ -224,6 +228,7 @@ public function testRemoveClasses() {
    +   *
    
    @@ -239,6 +244,7 @@ public function testHasClass() {
    +   *
    
    @@ -257,6 +263,7 @@ public function testChainAddRemoveClasses() {
    +   *
    

    Out of scope.

  23. +++ b/core/tests/Drupal/Tests/Core/Template/AttributeTest.php
    @@ -273,7 +280,7 @@ public function testTwigAddRemoveClasses($template, $expected, $seed_attributes
    -   * Provides tests data for testEscaping
    +   * Provides tests data for testEscaping.
    
    +++ b/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php
    @@ -71,7 +71,7 @@ public function setUp() {
    -   * Tests the escaping
    +   * Tests the escaping.
    
    @@ -94,7 +94,7 @@ public function testEscaping($template, $expected) {
    -   * Provides tests data for testEscaping
    +   * Provides tests data for testEscaping.
    

    Out of scope.

  24. +++ b/core/tests/Drupal/Tests/Core/Theme/AjaxBasePageNegotiatorTest.php
    @@ -17,23 +17,23 @@
    -   * @var \Drupal\Core\Theme\AjaxBasePageNegotiator
    -   *
        * The AJAX base page negotiator.
    +   *
    +   * @var \Drupal\Core\Theme\AjaxBasePageNegotiator
    ...
    -   * @var \Drupal\Core\Access\CsrfTokenGenerator|\Prophecy\Prophecy\ProphecyInterface
    -   *
        * The CSRF token generator.
    +   *
    +   * @var \Drupal\Core\Access\CsrfTokenGenerator|\Prophecy\Prophecy\ProphecyInterface
    ...
    -   * @var \Symfony\Component\HttpFoundation\RequestStack
    -   *
        * The request stack.
    +   *
    +   * @var \Symfony\Component\HttpFoundation\RequestStack
    

    Out of scope.

  25. +++ b/core/tests/Drupal/Tests/Core/TypedData/RecursiveContextualValidatorTest.php
    @@ -251,6 +251,7 @@ public function testValidatePropertyWithInvalidObjects($object) {
    +   *
    
    +++ b/core/tests/Drupal/Tests/Core/UnroutedUrlTest.php
    @@ -15,7 +15,7 @@
    -   * The URL assembler
    +   * The URL assembler.
    
    +++ b/core/tests/Drupal/Tests/EntityViewTrait.php
    @@ -30,6 +30,7 @@
    +   *
    

    Out of scope.

jofitz’s picture

Status: Needs work » Needs review
FileSize
26.08 KB
44.46 KB

Thanks for the review @mfernea.

Removed the out of scope changes and corrected a few more comments that didn't start with capital letters.

Most (if not all) of the remaining 'errors' are comments starting "(optional) ..." which I would argue should be allowed.

Any thoughts?

mfernea’s picture

Status: Needs review » Needs work

Looks better!

+++ b/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php
@@ -26,7 +26,8 @@ protected function setUpRenderRecursionComplexElements() {
-   * ::renderRoot() may not be called inside of another ::renderRoot() call.
+   * The method ::renderRoot() may not be called inside of another
+   * ::renderRoot() call.

Can we put this on one line?

I would just remove (optional) as it's not part of Coding standards and is not used consistently even in the classes where it is present.

jofitz’s picture

Status: Needs work » Needs review
FileSize
7.73 KB
51.59 KB

Removed all instances of (optional) at the beginning of comments and fixed the other coding standards error that had been introduced by the patch.

I could not think of a shorter comment that could remain on 1 line. I'm open to suggestions.

borisson_’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/content_translation/content_translation.admin.inc
    @@ -165,7 +165,7 @@ function _content_translation_is_field_translatability_configurable(EntityTypeIn
    - * (proxied) Implements hook_preprocess_HOOK();
    + * Implements hook_preprocess_HOOK() (proxied);
    

    Do we need to fix this ; in this issue as well? It should be a period instead of the semicolon.

  2. +++ b/core/modules/views/src/Annotation/ViewsAccess.php
    @@ -30,7 +30,7 @@ class ViewsAccess extends ViewsPluginAnnotationBase {
    -   * (optional) The short title used in the views UI.
    +   The short title used in the views UI.
    

    This removes the *, making it invalid.

  3. +++ b/core/modules/views/src/Annotation/ViewsArgumentDefault.php
    @@ -30,7 +30,7 @@ class ViewsArgumentDefault extends ViewsPluginAnnotationBase {
    -   * (optional) The short title used in the views UI.
    +   The short title used in the views UI.
    

    Same here.

  4. +++ b/core/modules/views/src/Annotation/ViewsArgumentValidator.php
    @@ -30,7 +30,7 @@ class ViewsArgumentValidator extends ViewsPluginAnnotationBase {
    -   * (optional) The short title used in the views UI.
    +   The short title used in the views UI.
    
    +++ b/core/modules/views/src/Annotation/ViewsCache.php
    @@ -30,7 +30,7 @@ class ViewsCache extends ViewsPluginAnnotationBase {
    -   * (optional) The short title used in the views UI.
    +   The short title used in the views UI.
    
    +++ b/core/modules/views/src/Annotation/ViewsDisplay.php
    @@ -30,7 +30,7 @@ class ViewsDisplay extends ViewsPluginAnnotationBase {
    -   * (optional) The short title used in the views UI.
    +   The short title used in the views UI.
    
    +++ b/core/modules/views/src/Annotation/ViewsDisplayExtender.php
    @@ -30,7 +30,7 @@ class ViewsDisplayExtender extends ViewsPluginAnnotationBase {
    -   * (optional) The short title used in the views UI.
    +   The short title used in the views UI.
    
    +++ b/core/modules/views/src/Annotation/ViewsExposedForm.php
    @@ -31,7 +31,7 @@ class ViewsExposedForm extends ViewsPluginAnnotationBase {
    -   * (optional) The short title used in the views UI.
    +   The short title used in the views UI.
    
    +++ b/core/modules/views/src/Annotation/ViewsPager.php
    @@ -30,7 +30,7 @@ class ViewsPager extends ViewsPluginAnnotationBase {
    -   * (optional) The short title used in the views UI.
    +   The short title used in the views UI.
    
    +++ b/core/modules/views/src/Annotation/ViewsQuery.php
    @@ -30,7 +30,7 @@ class ViewsQuery extends ViewsPluginAnnotationBase {
    -   * (optional) The short title used in the views UI.
    +   The short title used in the views UI.
    
    +++ b/core/modules/views/src/Annotation/ViewsRow.php
    @@ -30,7 +30,7 @@ class ViewsRow extends ViewsPluginAnnotationBase {
    -   * (optional) The short title used in the views UI.
    +   The short title used in the views UI.
    
    +++ b/core/modules/views/src/Annotation/ViewsStyle.php
    @@ -30,7 +30,7 @@ class ViewsStyle extends ViewsPluginAnnotationBase {
    -   * (optional) The short title used in the views UI.
    +   The short title used in the views UI.
    
    +++ b/core/modules/views/src/Annotation/ViewsWizard.php
    @@ -31,7 +31,7 @@ class ViewsWizard extends ViewsPluginAnnotationBase {
    -   * (optional) The short title used in the views UI.
    +   The short title used in the views UI.
    

    More of those.

  5. +++ b/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php
    @@ -26,7 +26,8 @@ protected function setUpRenderRecursionComplexElements() {
    -   * ::renderRoot() may not be called inside of another ::renderRoot() call.
    +   * The method ::renderRoot() may not be called inside of another
    +   * ::renderRoot() call.
    

    Verifies that ::renderRoot() is not called in another ::renderRoot() call.

    Does that make sense?

Vidushi Mehta’s picture

I've made the above mention changes in a new patch.

Vidushi Mehta’s picture

Vidushi Mehta’s picture

Status: Needs work » Needs review
Vidushi Mehta’s picture

FileSize
6.11 KB

uploading correct interdiff.

mfernea’s picture

Status: Needs review » Needs work

@borisson_'s #5 note from his last comment still needs to be addressed.

Other than that all issues mentioned by @borisson_ are solved and there aren't any new. Looks good to me!

jofitz’s picture

Status: Needs work » Needs review
FileSize
51.6 KB
622 bytes

Addressed @borisson_'s point 5 from #23.

mfernea’s picture

Status: Needs review » Needs work
+++ b/core/phpcs.xml.dist
@@ -38,7 +38,6 @@
-    <exclude name="Drupal.Commenting.DocComment.ShortNotCapital"/>
     <exclude name="Drupal.Commenting.DocComment.ShortFullStop"/>

We should add ShortNotCapital in the comment from above that statement. Please make sure it's in alpha order. Sorry for not pointing this earlier.

Other than that the patch looks fine and includes the other mentioned changes. Still applies cleanly and no cs issues.

jofitz’s picture

@mfernea But the comment above (I assume you mean lines 32-34) is not currently in alphabetical order.

mfernea’s picture

Indeed! Just add it there then. :)

jofitz’s picture

Status: Needs work » Needs review
FileSize
52.09 KB
664 bytes

Added ShortNotCapital to the list of errors to sniff for.

mfernea’s picture

Status: Needs review » Reviewed & tested by the community

Great! RTBC then!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 33: 2903027-33.patch, failed testing. View results

mfernea’s picture

Status: Needs work » Reviewed & tested by the community

The failing test doesn't relate to modifications in this patch.
I guess it's related to this #2924201: Resolve random failure in LayoutBuilderTest so that it can be added to HEAD. Back to RTBC!

xjm’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php
    @@ -94,6 +94,7 @@ public static function multipleValidate($element, FormStateInterface $form_state
       /**
        * {@inheritdoc}
    +   *
        * Used in \Drupal\field\Tests\EntityReference\EntityReferenceAdminTest::testAvailableFormatters().
        */
    

    This docblock is already invalid; either {@inheritdoc} should be the only thing in the docblock, or it needs to override the whole thing. We could spin this off into a separate issue.

  2. +++ b/core/modules/media/src/Annotation/MediaSource.php
    @@ -80,7 +80,7 @@ class MediaSource extends Plugin {
    -   * (optional) The metadata attribute name to provide the thumbnail alt.
    +   * The metadata attribute name to provide the thumbnail alt.
    
    @@ -89,7 +89,7 @@ class MediaSource extends Plugin {
    -   * (optional) The metadata attribute name to provide the thumbnail title.
    +   * The metadata attribute name to provide the thumbnail title.
    
    +++ b/core/modules/views/src/Annotation/ViewsArgumentDefault.php
    @@ -30,7 +30,7 @@ class ViewsArgumentDefault extends ViewsPluginAnnotationBase {
    -   * (optional) The short title used in the views UI.
    +   * The short title used in the views UI.
    
    +++ b/core/modules/views/src/Annotation/ViewsArgumentValidator.php
    @@ -30,7 +30,7 @@ class ViewsArgumentValidator extends ViewsPluginAnnotationBase {
    -   * (optional) The short title used in the views UI.
    +   * The short title used in the views UI.
    
    +++ b/core/modules/views/src/Annotation/ViewsCache.php
    @@ -30,7 +30,7 @@ class ViewsCache extends ViewsPluginAnnotationBase {
    -   * (optional) The short title used in the views UI.
    +   * The short title used in the views UI.
    
    +++ b/core/modules/views/src/Annotation/ViewsDisplay.php
    @@ -30,7 +30,7 @@ class ViewsDisplay extends ViewsPluginAnnotationBase {
    -   * (optional) The short title used in the views UI.
    +   * The short title used in the views UI.
    
    +++ b/core/modules/views/src/Annotation/ViewsDisplayExtender.php
    @@ -30,7 +30,7 @@ class ViewsDisplayExtender extends ViewsPluginAnnotationBase {
    -   * (optional) The short title used in the views UI.
    +   * The short title used in the views UI.
    
    +++ b/core/modules/views/src/Annotation/ViewsExposedForm.php
    @@ -31,7 +31,7 @@ class ViewsExposedForm extends ViewsPluginAnnotationBase {
    -   * (optional) The short title used in the views UI.
    +   * The short title used in the views UI.
    

    So, this issue is doing the opposite of #2909370: Fix 'Drupal.Commenting.VariableComment.IncorrectVarType' coding standard.

    Looking at all the changes in this patch, many of which are to work around what is probably valid documentation, I'm thinking we need to fix this rule to be less strict, instead of fixing it. At least this particular pattern of a parenthetical before a sentence that starts with a capital and ends with a period should be allowed. So let's file an issue to tweak the rule, and postpone this issue on that.

Thanks!

xjm’s picture

It looks like we have a standard for the callbacks here that also doesn't match how we're fixing it in the patch: https://www.drupal.org/node/1354#callback-def

neclimdul’s picture

FileSize
52.47 KB
mfernea’s picture

Status: Needs work » Postponed
Related issues: +#2925237: ShortNotCapital triggered by non-letters

Regarding "(optional)" I added #2925237: ShortNotCapital triggered by non-letters.
Regarding "{@inheritdoc}" we already have #2904801: @inheritdoc without { } is treated as a tag and gives missleading message. The problem is widespread.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Spokje made their first commit to this issue’s fork.

Spokje’s picture

Assigned: Unassigned » Spokje
Status: Postponed » Needs work

Just ran a test-run locally with this sniff, a lot seems to have changed for the better.
Unpostponing.

Spokje’s picture

Assigned: Spokje » Unassigned
Status: Needs work » Needs review
longwave’s picture

I am not 100% convinced this sniff adds anything useful, it doesn't help readability for me. It will also slow down patch authoring if test runs start to fail just because of this sniff, when they wouldn't otherwise.

Spokje’s picture

I am not 100% convinced this sniff adds anything useful, it doesn't help readability for me.

Not sure about this one either, for me it also doesn't add much, however readability is about the same for me before and after this sniff.

One could argue that the "real bad" non-capitalized comments were fixed in other sniffs, and that they might sneak in again in new code without this sniff.

One could argue that the sniff should not check for comments starting with numbers or "non-letters" (uses Get-Out-Of-Jail-Free-Card-Because-I-Am-A-Non-Native-Speaker card there) like !@#$%^&*().

Personally I would just turn this sniff on to prevent future "nasty" comments.

It will also slow down patch authoring if test runs start to fail just because of this sniff, when they wouldn't otherwise.

Although true, I think this can be said about any sniff, so I'm not sure if it's a valid argument

quietone’s picture

I disagree with #51 so went ahead and reviewed the changes, no worries if they are not used. Personally, I do like the comment starting with 'The' and not '#'. And since this sniff picked up only 60 files, it is very unlikely to be disruptive. That is people are already writing new summary lines which will pass this sniff.

Spokje’s picture

And since this sniff picked up only 60 files, it is very unlikely to be disruptive. That is people are already writing new summary lines which will pass this sniff.

Thus spoke the mighy @quietone in #54

That alone is (at least for me) a good reason to think it's not disruptive.

If it makes more readable code is up for debate, but is, of course, a matter of personal taste.
@quietone likes it, @longwave doesn't.

Personally I say: Turn this sniff on, since it's basically non-disruptive. It will only catch the (small amount of) people that incidentally write something that's not cAPITALIZED correctly.

For that reason I addressed all the issues found by @quietone and put this on NR again.

quietone’s picture

I read through the changes and it all looks good. For me, this is RTBC. Let's wait for longwave to chime in again.

longwave’s picture

Some of the changes here have swayed me to think that this is a good idea. Added a few comments/notes as I went along.

Spokje’s picture

Status: Needs review » Needs work

2 unresolved threats remaining

longwave’s picture

Added suggestions for the two outstanding.

Spokje’s picture

Status: Needs work » Needs review

Thanks @longwave for the suggestions.

Changes made, all threads resolved -> NR

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Great, it's time to see what core committers think.

Spokje’s picture

Random test fail on last run, triggered new test run.

Failed asserting that 'unknown error: session deleted because of page crash\n
from unknown error: cannot determine loading status\n
from tab crashed\n
longwave’s picture

catch’s picture

Status: Reviewed & tested by the community » Needs review

Question/comment from me in the MR..

Spokje’s picture

An attempt to comment on the question/comment/suggestion/whatever from @catch in the MR, in the...
....
Wait for it....
.
..
...
MR :)

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Spokje’s picture

Rebased MR against 9.3.x.

paulocs’s picture

I did a review and the patch fixes all doc comments that start with upper case character.
I'll move it RTBC and see if @catch will point any thing about #64.
I'm not attaching pictures from my local test because Drupal Automated Test would get it, but I ran ../vendor/bin/phpcs --extensions=php -p ./ and no error is displayed.

paulocs’s picture

Status: Needs review » Reviewed & tested by the community
Spokje’s picture

Thanks @paulocs for the Review.

I gave up on keeping MRs mergeable for non-RTBC issues, because somehow GitLab is notoriously bad at rebasing/merging with HEAD on Drupal (not noticed this on other projects), but since you made it an RTBC, here's a merge with HEAD from 9.3.x to get the Merge request !540 showing up in Green again.

Spokje’s picture

catch’s picture

Status: Reviewed & tested by the community » Postponed

I think we should patch coder to be more permissive - coder should follow core coding standards rather than the other way around.

Spokje’s picture

@catch: Although I agree with what you're saying I also see a lot of effort put in this issue now slowly being eroded by new code and code changes.

Oh well, let's wait until coder gets patched.

quietone’s picture

This is disappointing. This sniff is implementing what is in the coding standards. Does this mean the coding standards page is wrong and needs to be edited?

quietone’s picture

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.