Skip to content

Commit d33d617

Browse files
Bakhtier Gaibulloevclaude
authored andcommitted
refactor: use optional chaining for concise error message parsing
Refactors lineColMatch array access to use optional chaining (?.[]) instead of logical AND (&&) operators, making the code more concise and easier to read. This addresses SonarQube code quality suggestions while maintaining identical functionality. Changes: - Line 233: lineColMatch ? lineColMatch[1] → lineColMatch?.[1] - Line 234: lineColMatch && lineColMatch[2] → lineColMatch?.[2]
1 parent c2f28f0 commit d33d617

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

src/module-system/module-system.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,8 @@ export class ModuleSystem {
230230
): CompilationError {
231231
// Try to extract line and column from error message
232232
const lineColMatch = message.match(/(?:line|:)\s*(\d+)(?::(\d+))?/i);
233-
const line = lineColMatch ? Number.parseInt(lineColMatch[1], 10) : undefined;
234-
const column =
235-
lineColMatch && lineColMatch[2] ? Number.parseInt(lineColMatch[2], 10) : undefined;
233+
const line = lineColMatch?.[1] ? Number.parseInt(lineColMatch[1], 10) : undefined;
234+
const column = lineColMatch?.[2] ? Number.parseInt(lineColMatch[2], 10) : undefined;
236235

237236
return {
238237
message,

0 commit comments

Comments
 (0)