unison icon indicating copy to clipboard operation
unison copied to clipboard

search for string constants within codebase

Open ceedubs opened this issue 4 years ago • 6 comments

Sorry if there is already an issue for this; I couldn't find one.

As people start writing services in Unison, a really common use-case is going to be "Okay I see a log message that says couldn't load message because.... Where in my code did this come from?"

Traditionally you'd use something grep-like for this, but because Unison codebases aren't stored as text, you can't do that.

minimum requirements

  • support partial matches.

nice to have

  • fuzzy case matching
  • fast
  • search within namespace
  • search dependencies of a term

ceedubs avatar Sep 16 '21 17:09 ceedubs

The fact that there's not really a concept of "my code" vs "external library" in Unison might make this a bit tougher to make this fast. Maybe confining within a namespace or within dependents of X helps?

ceedubs avatar Sep 16 '21 18:09 ceedubs

Good idea. We don't have an index for this, but we could add one in a future iteration.

aryairani avatar Sep 16 '21 18:09 aryairani

@aryairani are you referring to a SQLite index that will end up in the SQLite file? I wonder if a useful index into the strings would end up adding a fair amount of bloat to the repo. I wonder if this should instead be a local cache, though then it might be a pain to manage. Luckily not as much of a pain, since Unison terms are content-addressed.

ceedubs avatar Sep 20 '21 20:09 ceedubs

@ceedubs The SQLite file is a local cache. I'm not familiar with the performance characteristics of sqlite full-text search, but I suppose they're in here somewhere: https://www.sqlite.org/fts5.html

aryairani avatar Sep 24 '21 04:09 aryairani

I think limiting to a namespace should be an option, but i would also like the ability to search through all of a namespace's dependencies (sometimes a log message can come from a dependency, as I'm currently experiencing).

I'm not very familiar with the Unison codebase - would it be possible to outline an approach with some of the modules involved?

bbarker avatar Jun 19 '24 22:06 bbarker

Hi @bbarker ! We'd love to have your help contributing to Unison! Glad you're here :D

Realistically though, I don't think I'd recommend this as a good first issue to tackle, though it may seem simple on the surface there are a lot of complicating factors behind the scenes on this one that make it more complex than it probably should be.

We have a few issues tagged as good first issues to tackle, though admittedly the list may be a bit stale, so it would still be good to check in with the team (probably on Discord) before jumping in on anything: https://github.com/unisonweb/unison/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22

Let us know if you have any questions on anything 😄

ChrisPenner avatar Jun 26 '24 19:06 ChrisPenner