Gitea: Feature proposal: add UI to turn `TODOs` in the code into an issue.

Created on 23 Oct 2020  路  4Comments  路  Source: go-gitea/gitea

I often add a quick TODO in my code when I'm designing a feature or I'm in a rush. You know those:

``` # TODO: make this hard-coded value a setting

TODO: split this function

TODO: use this lib I heard about, but I don't master at the moment, instead of this ugly hack

```
I really, honestly, think it's bad. If it's something to do, it's an issue to open. I spend some time when cleaning a PR on the TODOs I added, either resolve them or open an issue, and I never merge something from another dev that contains a "dangling" TODO (not linked to an issue).

Proposed design:

  • In the repository settings, define a (set of?) regex to find TODOs in the code ( # TODO:.*$ in sh/python..., // TODO:.*$, /\*\s*TODO:.*$, whatever, depending on the language.) Sane default should be defined in project templates.
  • add a view that list all matching lines in the current branch (dangling TODOs first)
  • on this list add two possible actions for each TODO:

    • resolve : remove the TODO

    • create an issue: open the new issue page and mark the line in the code with (issue #1234) somewhere in the todo line (Just after TODO: or at the end of line). This is no more a dangling TODO.

      (note that those actions modify the code and therefore are commits)

  • add a warning on the Pull request page if the branch still contains dangling TODOs

The ugly part is that the code is modified, and therefore a new commit is added every time an action is taken. The todo list page should add an option to squash those commits into a single one, and there could even be an option to inhibit hooks for single todo-action commits. The final squashing commit should trigger the hooks, though (we need the CI to run on the merged code).

Any thoughts?

kinproposal

Most helpful comment

there's a tool called snitch
but I'm not sure if they support gitea:

All 4 comments

there's a tool called snitch
but I'm not sure if they support gitea:

Honestly this sounds like something that your CI should be doing.

You could get your CI to make comments which contain links that would create an issue, eg. a link to https://try.gitea.io/arandomer/pathological/issues/new?body=wibble+wibble&title=todo

In terms of resolve - we'd need suggestion/patch support but once that's in (I have a work in progress patch that I need to get back to) - it could easily write something like:

<details>
    <summary>Remove this TODO</summary>
    ```patch
   diff --git a/path/to-file b/path/to-file
  @@ linenum,1 linenum, 0 @@
  - // TODO: remove this TODO
    ```
</details

We should probably extend CI status to be able to provide warning rather than simply deny but - if you're a repo admin you can always merge against CI checks.

I think this is a good idea. We can add a sub tab in codes named TODO, and it will display all the todo list. The todo list will be updated once you push commit to this branch.

There is a button to jump to the line of the todo comment on the codes on current branch.

It's similiar as the feature of IDE.

The fully integrated solution would be awesome, but, thanks to @6543 I discovered snitch, that may do the trick for me (if I manage to add it seamlessly enough in my workflow).

Was this page helpful?
0 / 5 - 0 ratings