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

Function lintSQLInternal

pkg/mcp/tools.go:192–216  ·  view source on GitHub ↗

lintSQLInternal runs the full linter rule set against a SQL string.

(sql string)

Source from the content-addressed store, hash-verified

190
191// lintSQLInternal runs the full linter rule set against a SQL string.
192func lintSQLInternal(sql string) (map[string]any, error) {
193 if sql == "" {
194 return nil, fmt.Errorf("parameter 'sql' is required and must not be empty")
195 }
196
197 result := newFullLinter().LintString(sql, "<mcp>")
198
199 violations := make([]map[string]any, 0, len(result.Violations))
200 for _, v := range result.Violations {
201 violations = append(violations, map[string]any{
202 "rule": v.Rule,
203 "rule_name": v.RuleName,
204 "severity": string(v.Severity),
205 "message": v.Message,
206 "line": v.Location.Line,
207 "column": v.Location.Column,
208 "suggestion": v.Suggestion,
209 })
210 }
211
212 return map[string]any{
213 "violation_count": len(result.Violations),
214 "violations": violations,
215 }, nil
216}
217
218// ---------------------------------------------------------------------------
219// Private helpers

Callers 5

handleLintSQLFunction · 0.85
handleAnalyzeSQLFunction · 0.85

Calls 3

newFullLinterFunction · 0.85
LintStringMethod · 0.80
ErrorfMethod · 0.65