MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / analyzeFunctionCall

Method analyzeFunctionCall

cmd/gosqlx/cmd/sql_analyzer.go:267–288  ·  view source on GitHub ↗

analyzeFunctionCall analyzes function calls

(fn *ast.FunctionCall)

Source from the content-addressed store, hash-verified

265
266// analyzeFunctionCall analyzes function calls
267func (a *SQLAnalyzer) analyzeFunctionCall(fn *ast.FunctionCall) {
268 a.functionCount++
269
270 // Check for potentially expensive functions
271 expensiveFunctions := map[string]bool{
272 "SUBSTRING": true, "UPPER": true, "LOWER": true,
273 "CONCAT": true, "REGEXP": true, "MD5": true,
274 }
275
276 if expensiveFunctions[strings.ToUpper(fn.Name)] {
277 a.addPerformanceIssue("EXPENSIVE_FUNCTION", "LOW",
278 fmt.Sprintf("Function %s may be expensive in large result sets", fn.Name),
279 "performance", "Consider precalculating values or using indexes")
280 }
281
282 // Analyze window functions
283 if fn.Over != nil {
284 a.addPerformanceIssue("WINDOW_FUNCTION", "LOW",
285 "Window functions can be resource intensive",
286 "performance", "Ensure proper indexing for window function performance")
287 }
288}
289
290// analyzeIdentifier analyzes identifiers
291func (a *SQLAnalyzer) analyzeIdentifier(id *ast.Identifier) {

Callers 1

VisitMethod · 0.95

Calls 1

addPerformanceIssueMethod · 0.95

Tested by

no test coverage detected