MCPcopy Create free account
hub / github.com/deepnote/deepnote / generateSuggestions

Function generateSuggestions

packages/cli/src/commands/analyze.ts:223–280  ·  view source on GitHub ↗
(analysis: AnalysisResult)

Source from the content-addressed store, hash-verified

221}
222
223function generateSuggestions(analysis: AnalysisResult): string[] {
224 const { stats, lint } = analysis
225 const suggestions: string[] = []
226
227 // Check for undefined variables
228 const undefinedVars = lint.issues.filter(i => i.code === 'undefined-variable')
229 if (undefinedVars.length > 0) {
230 suggestions.push(
231 `Fix ${undefinedVars.length} undefined variable${undefinedVars.length > 1 ? 's' : ''} to prevent runtime errors`
232 )
233 }
234
235 // Check for circular dependencies
236 const circularDeps = lint.issues.filter(i => i.code === 'circular-dependency')
237 if (circularDeps.length > 0) {
238 suggestions.push('Resolve circular dependencies to ensure correct execution order')
239 }
240
241 // Check for missing integrations
242 if (lint.integrations?.missing && lint.integrations.missing.length > 0) {
243 suggestions.push(
244 `Configure ${lint.integrations.missing.length} missing database integration${lint.integrations.missing.length > 1 ? 's' : ''}`
245 )
246 }
247
248 // Check for inputs needing values
249 if (lint.inputs?.needingValues && lint.inputs.needingValues.length > 0) {
250 suggestions.push(
251 `Set default values for ${lint.inputs.needingValues.length} input${lint.inputs.needingValues.length > 1 ? 's' : ''} or use --input flags when running`
252 )
253 }
254
255 // Check for unused variables (many indicates potential dead code)
256 const unusedVars = lint.issues.filter(i => i.code === 'unused-variable')
257 if (unusedVars.length >= 3) {
258 suggestions.push('Consider removing unused variables to improve code clarity')
259 }
260
261 // Large blocks suggestion
262 if (stats.totalLinesOfCode > 0 && stats.totalBlocks > 0) {
263 const avgLoc = stats.totalLinesOfCode / stats.totalBlocks
264 if (avgLoc > 50) {
265 suggestions.push('Consider breaking large blocks into smaller, more focused pieces')
266 }
267 }
268
269 // Single notebook with many blocks
270 if (stats.notebookCount === 1 && stats.totalBlocks > 20) {
271 suggestions.push('Consider splitting into multiple notebooks for better organization')
272 }
273
274 // No issues - good job!
275 if (suggestions.length === 0 && lint.issueCount.total === 0) {
276 suggestions.push('No issues found. Project looks well-structured!')
277 }
278
279 return suggestions
280}

Callers 1

buildAnalyzeResultFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected