Metastatic.Analysis.BusinessLogic.SyncOverAsync
(Metastatic v0.10.4)
View Source
Detects blocking synchronous operations used where async alternatives exist.
Universal pattern: synchronous HTTP/network calls in contexts where async is available.
Examples
Python (blocking httpx in async function):
async def fetch_data():
response = httpx.get("https://api.example.com") # Should use await httpx.AsyncClient
return response.json()JavaScript (sync fs in async context):
async function processFile() {
const data = fs.readFileSync('file.txt'); // Should use fs.promises.readFile
return data;
}Elixir (sync HTTP in async GenServer):
def handle_cast(:fetch, state) do
{:ok, response} = HTTPoison.get(url) # Should use Task.async or async library
{:noreply, response}
endC# (sync in async method):
async Task<string> GetDataAsync() {
var client = new WebClient();
return client.DownloadString(url); // Should use DownloadStringTaskAsync
}Go (blocking I/O in goroutine):
go func() {
resp, _ := http.Get(url) // Consider using context.Context for cancellation
processResponse(resp)
}()Ruby (sync in async Fiber):
Fiber.new do
response = Net::HTTP.get(uri) # Should use async HTTP library
process(response)
end.resume