Review main Abandoned

83125[TASK] Make duplicateExceptionCodeCheck.sh warning free

Simon Schaufelberger CR 0 V 0 Easy +11 −11 updated 12/19/24, 18:03

Commit message

This patch resolves a couple of warnings shown in PhpStorm with the
"Shell Script" plugin enabled:

- https://github.com/koalaman/shellcheck/wiki/SC2179
- https://github.com/koalaman/shellcheck/wiki/SC2207
- https://github.com/koalaman/shellcheck/wiki/SC2086
- https://github.com/koalaman/shellcheck/wiki/SC2004
- https://github.com/koalaman/shellcheck/wiki/SC2162
- https://github.com/koalaman/shellcheck/wiki/SC2006
- https://github.com/koalaman/shellcheck/wiki/SC2203
- https://github.com/koalaman/shellcheck/wiki/SC2199
- https://github.com/koalaman/shellcheck/wiki/SC2076
- https://github.com/koalaman/shellcheck/wiki/SC2164

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 1

Review log 1114

  1. Simon Schaufelberger uploaded patch set 1 02/25/24, 20:39

  2. Simon Schaufelberger updated the commit message in patch set 2 02/25/24, 20:41

  3. core-ci voted on patch set 1 V +1 02/25/24, 20:45 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53557

  4. Simon Schaufelberger commented on patch set 2 02/25/24, 20:45

    duplicateExceptionCodeCheck.sh:19

    this used to be an array but is now used as a simple string concatenation below.

    duplicateExceptionCodeCheck.sh:132

    if an array should be used instead, this should be rewritten differently but the way how it is currently seams wrong.
  5. core-ci voted on patch set 2 V +1 02/25/24, 20:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/53558

  6. Stefan Bürk commented on patch set 2 CR -1 02/27/24, 20:58

    duplicateExceptionCodeCheck.sh:19 Reply

    keep the array. It's pretty fine to use `+=` to also add a element to the end of an array. `+=` has different outcomes in bash. https://linuxhandbook.com/bash-append-array/

    duplicateExceptionCodeCheck.sh:132 Reply

    Please keep the original syntax along with keeping it an array above (see comment above). This is pretty normal regexp usage to check if something is in an array: https://www.baeldung.com/linux/check-bash-array-contains-value
  7. Simon Schaufelberger commented on patch set 2 02/27/24, 22:16

    duplicateExceptionCodeCheck.sh:19 Reply

    According to the website, it should be written as: ``` ignoreFiles=() ignoreFiles+=("sysext/core/Tests/Acceptance/Support/_generated/ApplicationTesterActions.php") ``` but that has a totally different outcome where the ignoreFiles variable is used later as there is a comparison made between a string and an array and that doesn't work.
  8. Stefan Bürk commented on patch set 2 02/27/24, 23:17

    duplicateExceptionCodeCheck.sh:19 Reply Unresolved

    That would be the correct fix to add the parentheese here. The original check below is a regexp style check -> https://www.baeldung.com/linux/check-bash-array-contains-value#using-anifcondition-with-aregex-pattern However, feel free to change it to a for loop check if you feel better with it and keep(make) it here a correct array. We need to stay with this array syntax due to bash 3.x support (default macos bash version)

    duplicateExceptionCodeCheck.sh:132 Reply

    Note: the currentFilename is used as regexp for an regexp check against an array. Feel free to change it to a for-loop (in array) check. Simply using the currentFilename as regexp pattern is a little scary - at least without an proper quoting/escaping which is missing here. (dots etc).
  9. Stefan Bürk commented on patch set 2 02/27/24, 23:56

    duplicateExceptionCodeCheck.sh:132 Reply Unresolved

    We could check the exact bash default version on a mac. At least, using the filename from a variable should automatically quote things like dots and slashes, so it is matches literally and not in a regexp style: ``` In bash-3.2, the shell was changed to internally quote characters in single- and double-quoted string arguments to the =~ operator, which suppresses the special meaning of the characters special to regular expression processing ('.', '[', '\', '(', ')', '*', '+', '?', '{', '|', '^', and '$') and forces them to be matched literally. This is consistent with how the `==' pattern matching operator treats quoted portions of its pattern argument. ``` So i'd say keeping the current condition with with ignoreFiles as array (fixing above) and the currentFilename can stay and is safe.

    duplicateExceptionCodeCheck.sh:159 Unresolved

    Isn't the removing of the spaces for left and rightside (and removing the quotes) change in behaviour and changing the check here ? Guess have to recheck this after some sleep. I would say that this would now match "456" if the array contains "12345678" as already found exception code ... and the spaces has been used to have a better matching. Not sure, needs some playground tests.
  10. Stefan Bürk commented on patch set 2 04/21/24, 00:58

    @simonschaufi+typo3@gmail.com ping
  11. Benni Mack updated the commit message in patch set 3 CR -1 V +1 10/18/24, 13:28

  12. core-ci voted on patch set 3 V -1 10/18/24, 17:53 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67969

  13. Christian Kuhn commented on patch set 3 12/19/24, 18:02

    Hey. i hope it is ok to abandon here for a couple of reasons: * this patch did not see activity for while * this is "only" a Build/ related script, mainly used within CI * this script is usually executed within the given CI / runTests.sh environment, where it works without issues * there are no apparent bugs within the given CI / runTests.sh enviroment that really have to be fixed at the moment. In case this is still a pressing issue, the patch could be resurrected and finished of course.
  14. Christian Kuhn abandoned the change 12/19/24, 18:03