Review main Merged

84190[TASK] Remove unused local variables

Simon Schaufelberger CR +2 V +2 Normal +63 −55 updated 07/11/24, 15:22

Commit message

Add test coverage for GeneralUtility::getFilesInDir with sorting by
mtime.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Georg Ringer +1
  • Verified V +2 Done
    • Benni Mack +2
    • Georg Ringer +1
    • core-ci +1 CI

Issues 1

Files 41

Show 21 more files

Review log 4151

Show 2126 earlier messages
  1. Simon Schaufelberger uploaded patch set 1 05/11/24, 12:21

  2. Simon Schaufelberger commented on patch set 1 05/11/24, 12:24

    All places have been found through Phpstorm's inspection "unused local variable"
  3. Simon Schaufelberger commented on patch set 1 05/11/24, 12:26

    One line has been skipped as this one has a separate issue: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84189
  4. core-ci voted on patch set 1 V -1 05/11/24, 12:26 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/57517

  5. Simon Schaufelberger uploaded patch set 2 V -1 05/11/24, 12:35

  6. core-ci voted on patch set 2 V +1 05/11/24, 12:40 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/57518

  7. Simon Schaufelberger uploaded patch set 3 V +1 05/11/24, 12:41

  8. core-ci voted on patch set 3 V +1 05/11/24, 12:45 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/57519

  9. Ayke Halder commented on patch set 3 05/13/24, 13:27

    I started to review the changes and came to a general assumption: In case of an `foreach` loop the named index might be intersting for debugging in case the index has some meaning/purpose on the data-object. Indexes which are just a counting number are of course unnecessary in case of a `foreach` loop when they are not in use.

    TcaColumnsProcessPlaceholders.php:35

    For debugging it might be nice to have `$fieldName` around.

    TcaFlexProcess.php:87

    For debugging it might be nice to have `$dataStructureSheetName` around.

    TcaFlexProcess.php:92

    For debugging it might be nice to have `$dataStructureFieldName` around.

    NodeFactory.php:170

    It might be nice to have `$priority` around: for debugging and in general to see what's the index' purpose.
  10. Willi Wehmeier commented on patch set 3 05/13/24, 13:28

    LinkController.php:84

    In case of an Exception thrown in the try block `$link` will be undefined here.
  11. Oliver Klee voted on patch set 3 V +1 05/13/24, 13:34

  12. Ayke Halder commented on patch set 3 CR -1 05/13/24, 13:36

    MessengerMiddlewarePass.php:67

    Calling `findDefinition($serviceName)` throws ServiceNotFoundException if the service definition does not exist. So calling this has a purpose and cannot be removed. Storing this inside a variable that is never used has no purpose. Maybe change `$service = $container->findDefinition($serviceName);` to `$container->findDefinition($serviceName);`
  13. Ayke Halder commented on patch set 3 05/13/24, 13:38

    LinkController.php:84 Reply

    In case of an Exception the catch-block does a `return` by itself.
  14. Willi Wehmeier commented on patch set 3 05/13/24, 13:40

    LinkController.php:84 Reply

    You're right. :)
  15. Ayke Halder commented on patch set 3 CR 0 05/13/24, 15:15

    MessengerMiddlewarePass.php:67 Reply

    Looking into this again: * `$container->findTaggedServiceIds($this->tagName)` calls `ContainerBuilder::getDefinitions()` * `$container->findDefinition($serviceName)` make some checks and might throw `ServiceCircularReferenceException`. In the end it also calls `ContainerBuilder::getDefinitions()` So we might actually remove the call to `ContainerBuilder::findDefinitions()`. Someone with experience in Symfony Dependency injection must decide on this.
  16. Simon Schaufelberger commented on patch set 3 05/13/24, 16:20

    TcaColumnsProcessPlaceholders.php:35 Reply

    Done

    TcaFlexProcess.php:87 Reply

    Done

    TcaFlexProcess.php:92 Reply

    Done

    NodeFactory.php:170 Reply

    Done

    MessengerMiddlewarePass.php:67 Reply

    Done
  17. Simon Schaufelberger uploaded patch set 4 V +1 05/13/24, 16:21

  18. Simon Schaufelberger commented on patch set 4 05/13/24, 16:23

    MessengerMiddlewarePass.php:67 Reply

    not done yet
  19. core-ci voted on patch set 4 V +1 05/13/24, 16:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/57632

  20. Oliver Klee voted on patch set 4 V +1 05/13/24, 17:08

  21. Ayke Halder commented on patch set 4 CR -1 05/13/24, 17:53

    GeneralUtility.php:1836

    Must be `$key => $value` here. As either one is used by `${$valueName}` with ``` $valueName = 'value'; if ($order === 'mtime') { asort($files); $valueName = 'key'; } ```
  22. Simon Schaufelberger uploaded patch set 5 CR -1 V +1 05/13/24, 21:57

  23. core-ci voted on patch set 5 V +1 05/13/24, 22:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/57651

  24. Simon Schaufelberger commented on patch set 5 05/14/24, 07:46

    GeneralUtility.php:1836 Reply

    good catch! This shows that this method is not fully covered. I've added a test for this case.
  25. Ayke Halder commented on patch set 5 05/14/24, 07:53

    Great, you are improving test coverage!

    GeneralUtility.php:1836 Reply

    Done

    GeneralUtilityTest.php:2481

    Remove this test-directory again: `GeneralUtility::rmdir($path, true);`
  26. Oliver Klee commented on patch set 5 05/14/24, 07:55

    GeneralUtilityTest.php:2481 Reply

    Note: This then needs to happen in `tearDown`, not in the test method itself, to ensure that the directory is removed even if the test fails or if an exception gets thrown.
  1. Ayke Halder commented on patch set 5 05/14/24, 07:59

    GeneralUtilityTest.php:2481 Reply

    So this test actually does not need to remove its test-directory: `createVersionNumberedFilenameKeepsInvalidAbsolutePathInFrontendAndAddsQueryString`
  2. Ayke Halder commented on patch set 5 05/14/24, 08:01

    GeneralUtilityTest.php:2481 Reply

    Another test that does not need to remove its test-directory: `getAllFilesAndFoldersInPathReturnsArrayWithMd5Keys`
  3. Ayke Halder commented on patch set 5 05/14/24, 08:14

    Move deletion of test-directories into test `tearDown`.

    GeneralUtilityTest.php:2469

    Use `getTestDirectory` here to have path registered for deletion upon test ending: `$path = $this->getTestDirectory();`

    GeneralUtilityTest.php:2481 Reply

    Done

    GeneralUtilityTest.php:3153

    `rmdir` can be removed. directory is created via `getTestDirectory` and therby already registered for deletion in `tearDown` upon test ending.

    GeneralUtilityTest.php:3588

    Register path for tear-down upon test ending: `$this->testFilesToDelete[] = $testFileDirectory;`

    GeneralUtilityTest.php:3604

    Might not be needed anymore - directory registered for deletion on tear-down.
  4. Simon Schaufelberger commented on patch set 5 05/14/24, 10:31

    GeneralUtilityTest.php:2469 Reply

    Done

    GeneralUtilityTest.php:3153 Reply

    Done

    GeneralUtilityTest.php:3588 Reply

    Done

    GeneralUtilityTest.php:3604 Reply

    Done
  5. Simon Schaufelberger uploaded patch set 6 V +1 05/14/24, 10:31

  6. core-ci voted on patch set 6 V -1 05/14/24, 10:36 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/57705

  7. Simon Schaufelberger uploaded patch set 7 V -1 05/14/24, 21:09

  8. core-ci voted on patch set 7 V +1 05/14/24, 21:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/57733

  9. Simon Schaufelberger uploaded patch set 8 V +1 05/15/24, 21:04

  10. core-ci voted on patch set 8 V +1 05/15/24, 21:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/57789

  11. Ayke Halder commented on patch set 8 05/16/24, 12:13

    MessengerMiddlewarePass.php:67 Reply

    In general I'd keep the call for now and just add a comment here: ``` /* * TODO: check if additonal call to `findDefinition` is actually necessary. * Especially check if there is a valid case where `ServiceCircularReferenceException` might get thrown. */ ``` But as this is going into `main` only: Remove the call to `findDefinition` and be prepared for some breaking. If it breaks, fix the problem again and ship a specific test-case for the breaking behaviour.
  12. Benjamin Franzke commented on patch set 8 05/24/24, 10:33

    MessengerMiddlewarePass.php:67 Reply

    This is for sure a copy&paste left-over and can be removed. The service is available (as it is listed by `findTaggedServiceIds`), no explicit call to `findDefinition()` is needed.
  13. Simon Schaufelberger commented on patch set 8 05/24/24, 10:47

    MessengerMiddlewarePass.php:67 Reply

    thank you!
  14. Simon Schaufelberger commented on patch set 8 05/24/24, 10:47

    MessengerMiddlewarePass.php:67 Reply

    Done
  15. Simon Schaufelberger uploaded patch set 9 V +1 05/24/24, 10:47

  16. core-ci voted on patch set 9 V +1 05/24/24, 10:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/58149

  17. Oliver Klee voted on patch set 9 V +1 05/24/24, 10:59

  18. Oliver Klee voted on patch set 9 CR +1 05/24/24, 11:21

  19. Simon Schaufelberger uploaded patch set 10 CR +1 V +1 07/09/24, 21:01

  20. core-ci voted on patch set 10 V +1 07/09/24, 21:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/61260

  21. Georg Ringer voted on patch set 10 CR +1 V +1 07/10/24, 08:54

  22. Benni Mack commented on patch set 10 07/11/24, 12:08

    TcaColumnsProcessPlaceholders.php:35

    why is this needed?
  23. Simon Schaufelberger commented on patch set 10 07/11/24, 12:24

    TcaColumnsProcessPlaceholders.php:35 Reply

    You mean the annotation or the unused variable "fieldName"? Ayke said that it would be helpful to leave it, because I removed it before. The annotation just makes it clear that $fieldName is not in use but just there for debugging purpose
  24. Benni Mack commented on patch set 10 CR +2 V +2 07/11/24, 15:22

    TcaColumnsProcessPlaceholders.php:35 Reply

    the annotation. really not a fan to leave such comments for tools that we don't use in CI.
  25. Benni Mack merged patch set 11 07/11/24, 15:22