Skip to content

Fix output handling - #3

Open
DMarinhoCodacy wants to merge 1 commit into
masterfrom
fix-output-handling
Open

Fix output handling#3
DMarinhoCodacy wants to merge 1 commit into
masterfrom
fix-output-handling

Conversation

@DMarinhoCodacy

Copy link
Copy Markdown
Contributor

No description provided.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 duplication

Metric Results
Duplication 0

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

The PR improves the reliability of oxlint output processing by introducing better error handling for JSON parsing and validating diagnostic properties. While the code is functional and Codacy reports it is 'up to standards', there are significant gaps in documentation and verification.

Specifically, the PR description is empty, providing no context for the reduction in stderr truncation or the logic changes. More importantly, no unit tests have been provided to verify the new error-handling paths or the diagnostic validation logic. Addressing these gaps is recommended to ensure long-term maintainability.

About this PR

  • The PR description is empty, which obscures the intent behind specific changes (such as reducing stderr truncation from 500 to 200 characters). Additionally, no unit tests were added to verify the new error-handling paths or the diagnostic validation logic.

Test suggestions

  • Verify that runOxlint returns a descriptive error message including truncated stderr when stdout contains invalid JSON.
  • Verify that diagnostics missing the 'code' field are skipped during processing and a warning is written to stderr.
  • Verify that when stdout parsing fails and stderr is empty, the error message correctly incorporates the process exit status.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify that runOxlint returns a descriptive error message including truncated stderr when stdout contains invalid JSON.
2. Verify that diagnostics missing the 'code' field are skipped during processing and a warning is written to stderr.
3. Verify that when stdout parsing fails and stderr is empty, the error message correctly incorporates the process exit status.

TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback

Comment thread src/engineImpl.ts
return { diagnostics: [], error: `Failed to parse oxlint output: ${errorMsg.slice(0, 500)}` };
} catch (parseErr) {
// Failed to parse JSON output
const stderr = result.stderr?.slice(0, 200) || "";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ LOW RISK

Suggestion: Trimming 'result.stderr' ensures that the fallback message containing the exit code is used if the stderr output is empty or only contains whitespace.

Suggested change
const stderr = result.stderr?.slice(0, 200) || "";
const stderr = result.stderr?.trim().slice(0, 200) || "";

Comment thread src/engineImpl.ts
// Failed to parse: this is a real error
const errorMsg = result.stderr || `Exit code ${result.status}`;
return { diagnostics: [], error: `Failed to parse oxlint output: ${errorMsg.slice(0, 500)}` };
} catch (parseErr) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ LOW RISK

Suggestion: The 'parseErr' variable is declared but never used in the catch block. You can simplify this by using an optional catch binding.

Suggested change
} catch (parseErr) {
} catch {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants