lintSQLInternal runs the full linter rule set against a SQL string.
(sql string)
| 190 | |
| 191 | // lintSQLInternal runs the full linter rule set against a SQL string. |
| 192 | func 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 |