Skip to content

JS-937 Support grpc in Node process#6049

Merged
vdiez merged 59 commits intotypescript-program-cachingfrom
grpc-analyze-file
Dec 12, 2025
Merged

JS-937 Support grpc in Node process#6049
vdiez merged 59 commits intotypescript-program-cachingfrom
grpc-analyze-file

Conversation

@vdiez
Copy link
Copy Markdown
Contributor

@vdiez vdiez commented Dec 9, 2025

No description provided.

saberduck and others added 30 commits December 5, 2025 17:02
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…it5 to v6.0.2.3904 (#6027)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…it5 to v6.0.3.3907 (#6032)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…#6036)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
# Conflicts:
#	package-lock.json
@vdiez
Copy link
Copy Markdown
Contributor Author

vdiez commented Dec 10, 2025

Note on rule parameter type parsing in gRPC vs HTTP bridge

The parseParamValue function in transformers.ts handles type conversion from strings, which may seem redundant if you're familiar with the HTTP bridge workflow. Here's why it's needed:

HTTP Bridge (existing analyze-project workflow)

  • Java's configurations() method returns typed objects: Map.of("max", 7) where 7 is an int
  • Gson serializes to JSON with proper types: {"max": 7}
  • Node receives already-typed values via JSON parsing

gRPC (new workflow)

  • Proto3 sends rule params as string key-value pairs: [{key: "maximumFunctionParameters", value: "7"}]
  • The transformer must parse "7"7 based on the field's default type from config.ts

This is by design - the gRPC endpoint receives raw @RuleProperty string values, while the HTTP bridge receives the output of the Java configurations() method which already contains properly typed values.

@vdiez
Copy link
Copy Markdown
Contributor Author

vdiez commented Dec 10, 2025

Summary of rule options transformation work

What was implemented

The gRPC endpoint now properly transforms rule parameters from SonarQube format to ESLint format:

  1. Key mapping: SonarQube param keys (e.g., maximumFunctionParameters) are mapped to ESLint field names (e.g., max) using the displayNamefield mapping from config.ts

  2. Type parsing: String values from proto3 are parsed to proper types based on the field's default value:

    • "5"5 (number)
    • "true"true (boolean)
    • "a,b,c"["a", "b", "c"] (string array)
    • "1,2,3"[1, 2, 3] (number array)
  3. Language filtering: Rules are only created for languages they support (from languages in generated-meta.ts)

  4. Scope handling: fileTypeTargets is set based on rule scope - ['TEST'] for test-only rules, ['MAIN', 'TEST'] for main rules

  5. Unknown rules/params: Gracefully skipped without errors

Other changes

  • Removed findCommonBaseDir: Since canAccessFileSystem: false, the baseDir is irrelevant - simplified to '/'
  • Refactored esbuild: Common build logic extracted to esbuild-common.mjs
  • Documentation: Added comprehensive "Rule Options Architecture" section to docs/DEV.md explaining how fields, schema, defaultOptions, and Java @RuleProperty all fit together

Test coverage

12 unit tests in packages/grpc/tests/transformers.test.ts covering:

  • Key mapping with displayName
  • Numeric/boolean/string/array param parsing
  • Language filtering (JS-only, TS-only, both)
  • Scope-based fileTypeTargets
  • Unknown rules and params handling

vdiez and others added 14 commits December 10, 2025 22:41
- SonarQube workflow: HTTP/WebSocket with typed values from Java configurations()
- gRPC workflow: External clients with string params that need type parsing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Decorated rules may optionally define a schema, not required
- Show two examples: S109 (no schema) and S107 (explicit schema)
- Update JSON Schema vs fields table to clarify schema is optional for decorated rules
- Clarify that decorated/external rules inherit schema from external rule at runtime

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Original rules only need schema if they accept options
- External rules CAN have user-configurable options (S103, S139, S1441)
- Updated table to say "original rules with options" not "required for original"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vdiez vdiez force-pushed the typescript-program-caching branch from 3d797a0 to fb63831 Compare December 12, 2025 10:42
@vdiez vdiez merged commit a2cb6be into typescript-program-caching Dec 12, 2025
9 checks passed
@vdiez vdiez deleted the grpc-analyze-file branch December 12, 2025 10:46
@sonarqube-next
Copy link
Copy Markdown

vdiez added a commit that referenced this pull request Dec 12, 2025
Co-authored-by: zglicz <michal.zgliczynski@sonarsource.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
vdiez added a commit that referenced this pull request Dec 15, 2025
Co-authored-by: zglicz <michal.zgliczynski@sonarsource.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
zglicz added a commit that referenced this pull request Dec 19, 2025
Co-authored-by: zglicz <michal.zgliczynski@sonarsource.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
zglicz added a commit that referenced this pull request Dec 22, 2025
Co-authored-by: zglicz <michal.zgliczynski@sonarsource.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
zglicz added a commit that referenced this pull request Dec 22, 2025
Co-authored-by: zglicz <michal.zgliczynski@sonarsource.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
henryju pushed a commit that referenced this pull request Jan 8, 2026
Co-authored-by: zglicz <michal.zgliczynski@sonarsource.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
zglicz pushed a commit that referenced this pull request Jan 8, 2026
Co-authored-by: zglicz <michal.zgliczynski@sonarsource.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

# Conflicts:
#	package.json
vdiez added a commit that referenced this pull request Jan 21, 2026
Co-authored-by: zglicz <michal.zgliczynski@sonarsource.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

# Conflicts:
#	package.json
vdiez added a commit that referenced this pull request Jan 21, 2026
Co-authored-by: zglicz <michal.zgliczynski@sonarsource.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

# Conflicts:
#	package.json
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.

3 participants