Skip to content

BUG: analyze_code_snippet silently returns 0 issues on .tsx/.jsx (no tsx/jsx in language enum) #396

@nathan-lampi-ag

Description

@nathan-lampi-ag

analyze_code_snippet silently returns 0 issues on .tsx/.jsx (no tsx/jsx in language enum)

Tool: analyze_code_snippet · Image: mcp/sonarqube:latest · CLI: v0.12.0

Bug

The language enum exposes ts and js but no tsx/jsx. Passing language: ["ts"] on JSX-containing content makes the TS analyzer bail without error and return {"issues":[],"issueCount":0}. CI (sonar-scanner) on the same project + same quality profile catches the issues correctly — so this is specific to the MCP snippet path.

Reproducer

Pure TS — works:

// language: ["ts"]
export const f = (a?: string, b?: boolean) => a ? (b ? 'x' : 'y') : 'z';
// → typescript:S3358 ✅

Same logic in TSX — silent zero:

// language: ["ts"]
import React from 'react';
const C = (p: { a?: string; b: boolean }) =>
  <div>{p.a ? (p.b ? 'x' : 'y') : 'z'}</div>;
export default C;
// → {"issues":[],"issueCount":0} ❌  (expected: typescript:S3358)

Workaround is unreliable

language: ["js"] parses JSX and surfaces javascript:S3358 correctly, but the JS parser misreads TS generics — e.g. React.useRef<HTMLDivElement | null>(null) triggers a false javascript:S1764 ("identical sub-expressions on both sides of >"). Also: language: ["ts","js"] returns 0 issues (possible separate bug).

Requested fix (any of)

  1. Add tsx/jsx to the language enum and route to the TS/JS analyzers with JSX parsing on.
  2. Have ["ts"] accept TSX (TypeScript parses TSX natively given the right flag).
  3. At minimum: return an error/diagnostic when the analyzer can't parse the snippet. The silent {"issues":[],"issueCount":0} is the dangerous part — agents trust it and report the file as clean.

Impact

Every .tsx/.jsx file in React/Next/etc. codebases gets a false-clean result. High blast radius for agentic use.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions