* Check if two strings are similar (used for detecting changed lines) * @param a First string * @param b Second string * @returns True if the strings are similar
(a: string, b: string)
| 242 | * @returns True if the strings are similar |
| 243 | */ |
| 244 | function areSimilar(a: string, b: string): boolean { |
| 245 | // Simple similarity check: more than 60% of characters are the same |
| 246 | const maxLength = Math.max(a.length, b.length); |
| 247 | if (maxLength === 0) return true; |
| 248 | |
| 249 | let sameChars = 0; |
| 250 | const minLength = Math.min(a.length, b.length); |
| 251 | |
| 252 | for (let i = 0; i < minLength; i++) { |
| 253 | if (a[i] === b[i]) sameChars++; |
| 254 | } |
| 255 | |
| 256 | return sameChars / maxLength > 0.6; |
| 257 | } |
| 258 | |
| 259 | /** |
| 260 | * Compute a diff between two files, focusing on function-level changes |