Problem/Motivation

Fix duplicated words in core, i.e. 'settings settings'. Keep in mind that in English there are situations where a duplicate word is correct. Here are examples from https://www.grammarphobia.com/blog/2013/08/this-and-that.html

  1. “I can see that that is going to be a problem.”
  2. “I received this this morning.”


Original report

Repeated 'settings' word in multiple files

Steps to reproduce

Proposed resolution

Grep for all potential instances of incorrectly duplicated words and remove the instances that are clearly wrong:

This should find any duplicated words in docblocks:

egrep -r '\<([a-zA-Z]+)\> \<\1\>' ./ | grep -v 'node_modules' | grep -v 'vendor' | grep '* '

This should find any duplicated words in inline comments:
egrep -r '\<([a-zA-Z]+)\> \<\1\>' ./ | grep -v 'node_modules' | grep -v 'vendor' | grep '// '

Occasionally, a duplicated word is actually correct. (E.g. "that that" is grammatically correct in some cases in English, and there are also other instances like annotation/parameter declarations where it might be correct.) So don't just blindly remove the duplicated word -- check each one.

Remaining tasks

Patch
Review

User interface changes

API changes

Data model changes

Release notes snippet

Problem/Motivation

Comments

anmolgoyal74 created an issue. See original summary.

abhijith s’s picture

Assigned: Unassigned » abhijith s
abhijith s’s picture

Applied patch .It works fine .Those additional words are removed

Checking patch core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php...
Checking patch core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/LanguageFormatter.php...
Checking patch core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php...
Checking patch core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php...
Checking patch core/modules/media/src/Plugin/Field/FieldFormatter/MediaThumbnailFormatter.php...
Applied patch core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php cleanly.
Applied patch core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/LanguageFormatter.php cleanly.
Applied patch core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php cleanly.
Applied patch core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php cleanly.
Applied patch core/modules/media/src/Plugin/Field/FieldFormatter/MediaThumbnailFormatter.php cleanly.

abhijith s’s picture

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

xjm’s picture

Title: Repeated 'settings' word in multiple files » Remove accidentally duplicated words in code comments
Priority: Minor » Normal
Status: Reviewed & tested by the community » Needs work

Instead of fixing these one word at a time, we should grep for all potential instances of incorrectly duplicated words and remove the instances that are clearly wrong:

This should find any duplicated words in docblocks:

egrep -r '\<([a-zA-Z]+)\> \<\1\>' ./ | grep -v 'node_modules' | grep -v 'vendor' | grep '* '

This should find any duplicated words in inline comments:

egrep -r '\<([a-zA-Z]+)\> \<\1\>' ./ | grep -v 'node_modules' | grep -v 'vendor' | grep '// '

Occasionally, a duplicated word is actually correct. (E.g. "that that" is grammatically correct in some cases in English, and there are also other instances like annotation/parameter declarations where it might be correct.) So don't just blindly remove the duplicated word -- check each one.

Thanks!

xjm’s picture

Issue tags: +Novice
quietone’s picture

Issue summary: View changes

@xjm, That make much more sense.

Updated the IS to include #6.

I ran the grep commands on core to see how many instances need to be examined.

$ egrep -r '\<([a-zA-Z]+)\> \<\1\>' ./core | grep -v 'node_modules' | grep -v 'vendor' | grep '* ' | nl | tail -1 | awk '{print $1}'
49

$ egrep -r '\<([a-zA-Z]+)\> \<\1\>' ./core | grep -v 'node_modules' | grep -v 'vendor' | grep '// ' | nl | tail -1| awk '{print $1}'
28

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.

alvar0hurtad0’s picture

Still working on this @Abhijith S?

sarvjeetsingh’s picture

Assigned: abhijith s » sarvjeetsingh
sarvjeetsingh’s picture

Assigned: sarvjeetsingh » Unassigned
Status: Needs work » Needs review
StatusFileSize
new35.07 KB

Used grep commands to find out instances that had repetitive words. Please review.

pranali.lanjewar’s picture

Assigned: Unassigned » pranali.lanjewar
pranali.lanjewar’s picture

Assigned: pranali.lanjewar » Unassigned
quietone’s picture

Status: Needs review » Needs work
StatusFileSize
new2.83 KB
new35.18 KB

Came to do a review but the patch did not apply so I rerolled it. Then ran the grep commands and looks like there is more work to do.
Not running the tests because this is changes to comments and there is work to do.

$ egrep -r '\<([a-zA-Z]+)\> \<\1\>' ./core | grep -v 'node_modules' | grep -v 'vendor' | grep '* ' | nl | tail -1 | awk '{print $1}'
15
$ egrep -r '\<([a-zA-Z]+)\> \<\1\>' ./core | grep -v 'node_modules' | grep -v 'vendor' | grep '// ' | nl | tail -1| awk '{print $1}'
10
sivaprasadc’s picture

Assigned: Unassigned » sivaprasadc
sivaprasadc’s picture

Assigned: sivaprasadc » Unassigned
Status: Needs work » Needs review
StatusFileSize
new971 bytes
new36.13 KB

@quietone Thanks for the patch. It is applied cleanly.

I have created the patch file to fix the duplicate words. Please find the attached.

After applying the patch, Still, we can see the duplicated words in docblocks:

egrep -r '\<([a-zA-Z]+)\> \<\1\>' ./ | grep -v 'node_modules' | grep -v 'vendor' | grep '* '

./core/core.api.php: * @link http://wikipedia.org/wiki/YAML YAML files. @endlink Configuration is
./core/core.api.php: * @link http://php.net/assert assert() @endlink statement. If an
./core/lib/Drupal/Core/Access/AccessResultInterface.php:   * A |A A F
./core/lib/Drupal/Core/Access/AccessResultInterface.php:   * F |F F F
./core/lib/Drupal/Core/Access/AccessResultInterface.php:   * N |N N F
./core/lib/Drupal/Core/Access/AccessResultInterface.php:   * F |F F F
./core/lib/Drupal/Core/Config/FileStorageFactory.php:   * @return \Drupal\Core\Config\FileStorage FileStorage
./core/lib/Drupal/Core/Template/Attribute.php: *   $value = t('Highlight the @tag tag', ['@tag' => '<em>']);
./core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php:   * Asserts that $key is a $type type dependency of $display config entity.
./core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php:   * Asserts that $key is not a $type type dependency of $display config entity.
./core/modules/file/tests/src/Functional/Formatter/FileAudioFormatterTest.php:   * @dataProvider dataProvider
./core/modules/file/tests/src/Functional/Formatter/FileVideoFormatterTest.php:   * @dataProvider dataProvider
./core/modules/filter/tests/src/Kernel/Plugin/migrate/process/FilterSettingsTest.php:   * @dataProvider dataProvider
./core/modules/system/tests/src/Functional/Mail/HtmlToTextTest.php:   * stuffed) line consisting of DASH DASH SP is neither fixed nor flowed."
./core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Fixtures.php:   * This is equivalent to running `composer composer-scaffold`, but we do the

we can see the duplicated words in inline comments:

$ egrep -r '\<([a-zA-Z]+)\> \<\1\>' ./ | grep -v 'node_modules' | grep -v 'vendor' | grep '// '
./core/includes/install.core.inc:        // If the new $file file has the same owner as $default_file this means
./core/modules/big_pipe/src/EventSubscriber/HtmlResponseBigPipeSubscriber.php:    // If there are no no-JS BigPipe placeholders, unwrap the scripts_bottom
./core/modules/big_pipe/src/Render/BigPipe.php:    // If there are no no-JS BigPipe placeholders, we can send the pre-</body>
./core/modules/ckeditor/js/views/AuralView.es6.js:        // otherwise the UA will speak 'button separator separator'.
./core/modules/comment/tests/src/Functional/CommentInterfaceTest.php:    // Change the node comment field formatter to use $mode mode instead of
./core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php:    // Unless it's very very old content. Everything in the query is already
./core/modules/quickedit/js/models/FieldModel.es6.js:        // User is saving changed field data in in-place editor to
./core/modules/update/tests/src/Functional/UpdateCoreTest.php:    // Make sure admin/appearance warns you you're missing a security update.
./core/modules/views/views.api.php:  //   ... FROM example_table et ... JOIN foo foo

These seem to be valid to me. Kindly review and share the feedback.

volkswagenchick’s picture

Issue tags: +Europe2020

This is already tagged novice, I am adding the Europe2020tag. Thanks.

Novice issue reserved for the Mentored Contribution during the Contribution Day at Europe2020. After the 11th December 2020, this issue returns to being open to all. Thanks
michaellenahan’s picture

Issue tags: -Europe2020

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.

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.

vikashsoni’s picture

Patch not applying in drupal-9.3.x-dev
Needs to reoll

volkswagenchick’s picture

Status: Needs review » Needs work

Marking this Needs Work, thanks.

murilohp’s picture

StatusFileSize
new37.2 KB
new28.09 KB

Hey I made the reroll of patch #17 to branch 9.4.x.

Thanks!

murilohp’s picture

Status: Needs work » Needs review

Moving to needs review again!

ankithashetty’s picture

StatusFileSize
new35.08 KB
new1.74 KB

Updated the patch in #24 to remove the changes made to core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ComposerHookTest.php file, as it's already been merged here #3255836: Test fails due to Composer 2.2.

Thanks!

avpaderno’s picture

All the changes done by last patch are correct.

longwave’s picture

Status: Needs review » Needs work
+++ b/core/modules/filter/src/Plugin/migrate/process/FilterID.php
@@ -15,9 +15,9 @@
-// cspell:ignore gotwo htmlpurifier htmltidy intlinks intlinks lazyloader
+// cspell:ignore gotwo htmlpurifier htmltidy intlinks lazyloader
 // cspell:ignore linktitle multicolumn multilink mytube openlayers opengraph
-// cspell:ignore sanitizable shortcode shortcode spamspan typogrify wordfilter
+// cspell:ignore sanitizable shortcode spamspan typogrify wordfilter
 // cspell:ignore xbbcode

This can now be rewrapped at 80 characters.

Once this is done this looks ready to go.

murilohp’s picture

Status: Needs work » Needs review
StatusFileSize
new35.3 KB
new931 bytes

Hey @ankithashetty thanks for your help! @longwave I rewrapped, on this new patch, thanks for bringing this up!

Thanks!

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Thanks - this all looks good to me.

alexpott’s picture

Version: 9.4.x-dev » 9.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed adff905c9ef to 10.0.x and 9caf7d9aaf4 to 9.4.x and 923ad8611fa to 9.3.x. Thanks!

Backported to 9.3.x to keep code aligned and since this only changed comments.

diff --git a/core/modules/comment/src/CommentStorage.php b/core/modules/comment/src/CommentStorage.php
index 5440bfa4e2c..6bf70252189 100644
--- a/core/modules/comment/src/CommentStorage.php
+++ b/core/modules/comment/src/CommentStorage.php
@@ -319,9 +319,8 @@ public function loadThread(EntityInterface $entity, $field_name, $mode, $comment
       $query->orderBy('c.cid', 'ASC');
     }
     else {
-      // See comment above. Analysis reveals that this doesn't cost too
-      // much. It scales much better than having the whole comment
-      // structure.
+      // See comment above. Analysis reveals that this doesn't cost too much. It
+      // scales much better than having the whole comment structure.
       $query->addExpression('SUBSTRING([c].[thread], 1, (LENGTH([c].[thread]) - 1))', 'torder');
       $query->orderBy('torder', 'ASC');
     }
diff --git a/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php b/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php
index ef8f5fdda4b..a657d2cacba 100644
--- a/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php
+++ b/core/modules/image/tests/src/Functional/ImageFieldDefaultImagesTest.php
@@ -251,8 +251,7 @@ public function testDefaultImages() {
     $field->setSetting('default_image', $default_image_settings);
     $field->save();
 
-    // Confirm the new field default is used on the article field
-    // admin form.
+    // Confirm the new field default is used on the article field admin form.
     $this->drupalGet("admin/structure/types/manage/article/fields/$field_id");
     $this->assertSession()->hiddenFieldValueEquals('settings[default_image][uuid][fids]', $default_images['field_private']->id());
   }
diff --git a/core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php b/core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
index 1f987fece9d..d4e23b3e738 100644
--- a/core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
+++ b/core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
@@ -713,9 +713,9 @@ public function testAlt() {
     $assert_session->fieldValueEquals('attributes[alt]', $cobra_commander_bio);
 
     // Test that setting alt value to two double quotes will signal to the
-    // MediaEmbed filter to unset the attribute on the media image field.
-    // We intentionally add a space after the two double quotes to test
-    // the string is trimmed to two quotes.
+    // MediaEmbed filter to unset the attribute on the media image field. We
+    // intentionally add a space after the two double quotes to test the string
+    // is trimmed to two quotes.
     $page->fillField('attributes[alt]', '"" ');
     $this->submitDialog();
     $this->getSession()->switchToIFrame('ckeditor');
diff --git a/core/modules/media_library/media_library.module b/core/modules/media_library/media_library.module
index e8374143d54..24a534ce809 100644
--- a/core/modules/media_library/media_library.module
+++ b/core/modules/media_library/media_library.module
@@ -479,8 +479,8 @@ function _media_library_configure_view_display(MediaTypeInterface $type) {
  * Implements hook_form_FORM_ID_alter().
  */
 function media_library_form_filter_format_edit_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
-  // Add an additional validate callback so we can ensure the media_embed
-  // filter is enabled when the DrupalMediaLibrary button is enabled.
+  // Add an additional validate callback so we can ensure the media_embed filter
+  // is enabled when the DrupalMediaLibrary button is enabled.
   $form['#validate'][] = 'media_library_filter_format_edit_form_validate';
 }
 
@@ -488,8 +488,8 @@ function media_library_form_filter_format_edit_form_alter(array &$form, FormStat
  * Implements hook_form_FORM_ID_alter().
  */
 function media_library_form_filter_format_add_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
-  // Add an additional validate callback so we can ensure the media_embed
-  // filter is enabled when the DrupalMediaLibrary button is enabled.
+  // Add an additional validate callback so we can ensure the media_embed filter
+  // is enabled when the DrupalMediaLibrary button is enabled.
   $form['#validate'][] = 'media_library_filter_format_edit_form_validate';
 }
 
diff --git a/core/modules/views/src/Plugin/views/argument_validator/ArgumentValidatorPluginBase.php b/core/modules/views/src/Plugin/views/argument_validator/ArgumentValidatorPluginBase.php
index 0b4cacd46a7..c89479f9dc6 100644
--- a/core/modules/views/src/Plugin/views/argument_validator/ArgumentValidatorPluginBase.php
+++ b/core/modules/views/src/Plugin/views/argument_validator/ArgumentValidatorPluginBase.php
@@ -14,9 +14,9 @@
  * Views argument validator plugins validate arguments (contextual filters) on
  * views. They can ensure arguments are valid, and even do transformations on
  * the arguments. They can also provide replacement patterns for the view title.
- * For example, the 'content' validator verifies that the argument
- * value corresponds to a node, loads that node, and provides the node title
- * as a replacement pattern for the view title.
+ * For example, the 'content' validator verifies that the argument value
+ * corresponds to a node, loads that node, and provides the node title as a
+ * replacement pattern for the view title.
  *
  * Argument validator plugins extend
  * \Drupal\views\Plugin\views\argument_validator\ArgumentValidatorPluginBase.
diff --git a/core/modules/workspaces/workspaces.install b/core/modules/workspaces/workspaces.install
index a69fdf2764a..2c37233f92f 100644
--- a/core/modules/workspaces/workspaces.install
+++ b/core/modules/workspaces/workspaces.install
@@ -50,8 +50,8 @@ function workspaces_module_preinstall($module) {
  * Implements hook_install().
  */
 function workspaces_install() {
-  // Set the owner of these default workspaces to be first user which has
-  // the 'administrator' role. This way we avoid hard coding user ID 1 for sites
+  // Set the owner of these default workspaces to be first user which has the
+  // 'administrator' role. This way we avoid hard coding user ID 1 for sites
   // that prefer to not give it any special meaning.
   $admin_roles = \Drupal::entityTypeManager()->getStorage('user_role')->getQuery()
     ->condition('is_admin', TRUE)
diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationQueryTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationQueryTest.php
index 1ca9652b7b9..fe9da095025 100644
--- a/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationQueryTest.php
+++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTranslationQueryTest.php
@@ -49,8 +49,8 @@ protected function visitInstaller() {
    * {@inheritdoc}
    */
   protected function setUpLanguage() {
-    // The language was preset by passing a query parameter in the URL, so
-    // no explicit language selection is necessary.
+    // The language was preset by passing a query parameter in the URL, so no
+    // explicit language selection is necessary.
   }
 
   /**

Re-flowed the above comments now that we can fit more on a line.

  • alexpott committed adff905 on 10.0.x
    Issue #3175287 by murilohp, quietone, SivaprasadC, ankithashetty,...

  • alexpott committed 9caf7d9 on 9.4.x
    Issue #3175287 by murilohp, quietone, SivaprasadC, ankithashetty,...

  • alexpott committed 923ad86 on 9.3.x
    Issue #3175287 by murilohp, quietone, SivaprasadC, ankithashetty,...

Status: Fixed » Closed (fixed)

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