GitHub released its new code search and code view to enable developers to quickly search, navigate and understand their code, and put critical information into context.

The new code search engine has been remodeled to be two times faster than the old one and has more capabilities such as supporting substring queries, regular expressions, and symbol search.

Code Search understands a user’s code and brings relevant results at high speeds by searching across multiple repositories. Users can search using regular expressions, boolean operations, keyboard shortcuts, and more.

“Imagine that a user complains that they received an error message from your service saying ‘query is not satisfiable.’ You’re not sure which system produced this error message, or which repository the code is in,” ​​Colin Merkel, software engineer at GitHub, wrote in a blog post

“Without code search, you might have to clone a bunch of repositories and grep through them, or ask a knowledgeable coworker. But with code search, you can instantly search across all of an organization’s code at once.” 

As an example, if a company uses Kubernetes and their infrastructure team reports a shortage of memory in their cluster, one approach could be to search for YAML configuration files containing the term “memory” across the team’s code. The search results, which can be saved with a query such as “saved:blackbird lang:yaml memory,” would reveal the Kubernetes configuration files for the team’s services and their allocated memory. The search results could then be shared with the infrastructure team to initiate a discussion on the memory allocation for those services.

For teams using React, the prop dangerouslySetInnerHTML is a well-known feature that enables the direct injection of HTML into an element using a string. However, it can pose a security risk if the string being injected is untrusted. One way to identify potential vulnerabilities is by searching for the usage of this prop across GitHub’s codebase using a query such as “repo:github/github dangerouslySetInnerHTML.” The search results could reveal any occurrences of the prop, including some linter rules that forbid its use. 

GitHub also redesigned its code view to integrate search, browsing, and code navigation. The company stated that this launch is just the beginning and it is infusing intelligence into every aspect of software development moving forward.