remove commented out code from openmrs-core

Hello friends of clean code :yum:

Im wondering what the best approach to removing commented out code from openmrs-core is

there is quite a lot of dead stuff around, see sonar https://ci.openmrs.org/sonar/drilldown/issues/1865?&rule=squid%3ACommentedOutCodeLine&rule_sev=MAJOR

and some example candidates

seems like this was a bad habit from way back which nobody dares to remove because who know what the intention was :wink:

I suggest one issue and separate PRs for each file to ensure we handle this correctly case by case?

  • treat TODOs the same way as comments? or keep them

Most of that code has been commented out for ages. So i think removing it should not be a problem as long as there is a ticket for it, just in case. :slight_smile:

I would do one ticket if they are just a few. But if they are many, i would vote for a parent ticket with sub tasks for each.

Kill … them … all

I’m fine with getting rid of it, I personally ask devs to remove any commented out code they introduce in their pull requests and I think we should update our conventions and pull requests pages to mention this.

1 Like

should I add it to one or both of them?

or maybe better I could also add this ‘remove your comments’ rule to the code style page and link the code style page into the Pull request tips

Both, do we have multiple code conventions pages? I also see this

interesting, in that page there is even a section on commented out code :smile:

https://wiki.openmrs.org/display/docs/Coding+Conventions#CodingConventions-Donotcommentoutcode

number 1 is more elaborate than number 2

  1. https://wiki.openmrs.org/display/docs/Coding+Conventions
  2. https://wiki.openmrs.org/display/docs/Code+Style

should we merge number 2 into number 1 and then remove it?

Then we should update the pull request tips page

added “Follow our coding conventions” bullet point to https://wiki.openmrs.org/display/docs/Pull+Request+Tips with link to https://wiki.openmrs.org/display/docs/Coding+Conventions

Great! That is exactly what i would do. :smile: