HiveMinds / Productivity-setup

Automatically sets up a productivity setup on Ubuntu 20.04 OS.
GNU Affero General Public License v3.0
2 stars 4 forks source link

Remove duplicate functions from `test/helper.sh`. #2

Open a-t-0 opened 3 years ago

a-t-0 commented 3 years ago

When an actual test result and a list of allowed results is passed, they arrive at a function that checks if the actual result is in some position in the list of allowed results. This position can be:

However, passing the actual test result is 1 argument, the list is the second argument.Assumption: one cannot pass 3 arguments to a bash function. If that assumption is valid, it is not possible to simply pass an additional argument that tells the receiving function which position should be checked. Hence I triplicated the receiving function and just call the right function directly. However that is a lot of duplicate code, which is undesirable.

Possible solutions are:

  1. Push the position argument in the first entry of the list and read it out and remove that first element from the list.
  2. Push the position argument in the list and loop over the list starting at the second element in the list.

Doing either would allow me to remove 2 functions and turn them into a single function.

DevNinja5 commented 2 years ago

I wanna give it a try on this @a-t-0 @HiveMinds

a-t-0 commented 2 years ago

Thank you for the enthousiasm! It is not quite clear to me at this point in time what the exact issue is I described here. I briefly checked and there are no literal duplicate functions in https://github.com/HiveMinds/Productivity-setup/blob/main/test/helper.sh So you are free to give it a try, however, I think it would perhaps be more effective to either look into: https://github.com/HiveMinds/Productivity-setup/issues/4 https://github.com/HiveMinds/Productivity-setup/issues/3 (Once the GitLab CI is up and running, I intend to do a significant overhaul of this repository and structure, so I can imagine small contributions in content (besides Style Guide compliance) may be overturned in that refactoring. Hence, I think quality and GitLab deployment improvements would be more effective:

https://github.com/Simple-Setup/Self-host-GitLab-Server-and-Runner-CI/issues/54 Or if you want to dive into the deep(the current bottleneck): https://github.com/Simple-Setup/Self-host-GitLab-Server-and-Runner-CI/issues/42

However, feel free to decide as you deem fun!