Search results aggregations use cases and recipes
Here are some common use cases for the in-search-results aggregations powered by code insights.
Popular
What versions of Go are we using most?
See all the go versions in your codebase (group by capture group)
SGQUERYfile:go\.mod$ /go\s*(\d\.\d+)/
What are the open source licenses most used in our codebase?
See all the licenses included, by frequency (group by capture group)
SGQUERYfile:package.json /"license":\s(.*),/
Which repositories use a specific internal library the most?
See which repositories import a library (group by repository)
SGUQERYfrom '@sourcegraph/wildcard'
Which directories have the longest eslint ignore file?
See which files have the most linter override rules within a repository (group by file)
SGQUERYfile:^\.eslintignore /.\n/ repo:^github\.com/sourcegraph/sourcegraph$
Who knows most about a library or component?
See who has added the most uses of a component to a specific repository in the last three months
SGQUERYnodeComponent type:diff select:commit.diff.added repo:sourcegraph/sourcegraph$ after:"3 months ago"
By capture group
What versions of log4j exist in our codebase?
See all the different subversions of log4j present in your code
SGQUERYlang:gradle /org\.apache\.logging\.log4j['"].*?(2\.\d+\.\d+)/
What breaks most commonly?
See what topics most frequently appear in "fix [x]" commit messsages
SGQUERYtype:commit repo:^github\.com/sourcegraph/sourcegraph$ after:"5 days ago" /Fix (\\w+)/
What are the most common email addresses we direct users to?
See every email address hardcoded, by frequency
SGQUERY/(\w+)\@sourcegraph\.com/
How can we see all our different tracer calls to remove unnecessary ones or encourage proper usage?
See all your tracer calls to track the growth of, or minimize spend on, tools like Datadog.
SGQUERY/tracer\.trace\(([\s"'\w@\/:^.#,+-=]+)\)/
By repository
Which repositories use a specific internal library the most?
See which repositories import a library
SGUQERY/from\s'\@sourcegraph\/wildcard/
Which teams (repositories) have the most usages of a vulnerable function or library?
SGQUERYvulnerableFunc(
Which repositories have the longest top-level eslint ignore files?
See which repositories are using the most linter overrides
SGQUERYfile:^\.eslintignore /.\n/
By file
Which files should we migrate first?
See which files have the most usage of a library you want to deprecate, such as the log15 library
SGQUERYrepo:^github\.com/sourcegraph/sourcegraph$ /log15\.(?:Debug|Info|Warn|Error)/
Which are our biggest package.json files?
See which repositories have the most scripts or dependencies
SGQUERYfile:package\.json ,
Which directories have the longest eslint ignore file?
See which files have the most linter override rules within a repository
SGQUERYfile:^\.eslintignore /.\n/ repo:^github\.com/sourcegraph/sourcegraph$
By author
Who knows most about a library or component?
See who has added the most uses of a component to a specific repository in the last three months
SGQUERYnodeComponent type:diff select:commit.diff.added repo:sourcegraph/sourcegraph$ after:"3 months ago"
Who worked on a recent migration?
See who most often had commits mentioning what you migrated away from (for example: migrating off bootstrap)
SGQUERYbootstrap type:commit r:sourcegraph/sourcegraph$ after:"3 months ago"