3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/sql_query_analyzer/sql_level_rules.rb', line 3
def self.evaluate(sql)
return [] unless sql
warnings = []
if sql.match?(/select\s+\*/i)
warnings << {
line_number: 'N/A',
line_text: 'SELECT *',
suggestion: Suggestion.new(:warning, "🚨 Query uses SELECT *. Specify only needed columns for performance.")
}
end
if sql.match?(/join/i) && !sql.match?(/on/i)
warnings << {
line_number: 'N/A',
line_text: 'JOIN without ON',
suggestion: Suggestion.new(:critical, "⚡ JOIN without ON detected. May cause massive row combinations (CROSS JOIN).")
}
end
warnings
end
|