Back to all reviewers

robust algorithm implementation

nrwl/nx
Based on 4 comments
TypeScript

Implement algorithms that handle edge cases and avoid brittle assumptions about input data or structure formats. Instead of relying on simple string manipulation or assuming data structure behavior, use comprehensive approaches that account for various scenarios.

Algorithms TypeScript

Reviewer Prompt

Implement algorithms that handle edge cases and avoid brittle assumptions about input data or structure formats. Instead of relying on simple string manipulation or assuming data structure behavior, use comprehensive approaches that account for various scenarios.

For parsing operations, handle multiple input formats:

// Brittle approach
const target = task.target.target.split('--')[0];
const lines = content.split('\n');

// Robust approach  
const target = getTargetFromMetadata(task, projectGraph);
const lines = content.split(/\r\n|\r|\n/);

For data structure access, verify assumptions and implement proper traversal:

// Assumption-based approach
const children = reflection.children;

// Verified approach
const childReflections = reflections.filter(
  (r) => r.parent && r.parent.id === reflection.id
);

This approach prevents bugs caused by incomplete parsing, platform differences, or incorrect assumptions about data structure behavior, leading to more reliable and maintainable code.

4
Comments Analyzed
TypeScript
Primary Language
Algorithms
Category

Source Discussions