Skip to content

feat(diagnostics): параметры-списки принимают строку или массив (тип List)#4268

Open
nixel2007 wants to merge 5 commits into
developfrom
claude/diagnostic-params-string-list-28j3v4
Open

feat(diagnostics): параметры-списки принимают строку или массив (тип List)#4268
nixel2007 wants to merge 5 commits into
developfrom
claude/diagnostic-params-string-list-28j3v4

Conversation

@nixel2007

@nixel2007 nixel2007 commented Jul 14, 2026

Copy link
Copy Markdown
Member

Описание

Параметры-списки диагностик (значения через запятую) получили первоклассный тип List и теперь принимают два входных представления:

  • строку через запятую — как раньше, в т.ч. из SonarQube UI и «старых» конфигов;
  • JSON-массив строк в .bsl-language-server.json ("userWordsToIgnore": ["Слово1", "Слово2"]).

Реализация:

  • @DiagnosticParameter(type = List.class) + поле List<String> вместо строки.
  • DiagnosticHelper.castParameterValue приводит значение из конфигурации к List<String>: строка → split по запятой (с trim/отбросом пустых), JSON-массив (Jackson → ArrayList) → список.
  • DiagnosticHelper.asStringList(String) — разбор CSV, переиспользуется для инициализации полей значением по умолчанию.
  • DiagnosticParameterInfo и DiagnosticHelper.configureDiagnostic знают про List.class; внешнее представление значения по умолчанию остаётся строкой (для SonarQube UI и JSON-схемы).
  • Первая переведённая диагностика — Typo (userWordsToIgnore).

Обратная совместимость полная: старые CSV-строки в конфигах и любые значения из SonarQube продолжают работать; массив — новая опциональная возможность JSON-конфига.

Схема параметров

parameters-schema.json не правился руками — он генерируется gradlew precommit через плагин bslls-dev-tools. Поддержка "type": ["string","array"] добавлена в 1c-syntax/bslls-dev-tools#PR (см. связанные PR ниже). После релиза плагина и бампа его версии здесь схема перегенерится автоматически. В рантайме массив уже принимается независимо от схемы.

Связанные PR

  • 1c-syntax/bslls-dev-tools — генерация схемы для типа List (ветка claude/diagnostic-params-string-list-28j3v4)
  • 1c-syntax/sonar-bsl-plugin-community — проброс параметров-списков (ветка claude/diagnostic-params-string-list-28j3v4)

Связанные задачи

Closes

Чеклист

Общие

  • Ветка PR обновлена из develop
  • Отладочные, закомментированные и прочие, не имеющие смысла участки кода удалены
  • Изменения покрыты тестами (TypoDiagnosticTest, в т.ч. новый кейс с массивом)
  • Обязательные действия перед коммитом выполнены (gradlew precommit) — регенерация схемы зависит от релиза bslls-dev-tools, см. выше

Для диагностик

  • Описание диагностики заполнено для обоих языков (в этом PR меняется только тип параметра, тексты не затрагивались)

Дополнительно

Дальнейший план — раскатать тип List на остальные списочные параметры (LatinAndCyrillicSymbolInWord, MagicNumber/MagicDate, CommentedCode и др.; UsingServiceTag — отдельно, там |-разделитель/regex).

🤖 Generated with Claude Code


Generated by Claude Code

Summary by CodeRabbit

  • New Features

    • Diagnostic settings now support list-based parameters.
    • Comma-separated values are automatically parsed into trimmed lists, with empty entries ignored.
    • Typo checking now supports configuring multiple words to ignore.
  • Bug Fixes

    • Improved handling of ignored-word settings when provided as lists or text values.

claude added 3 commits July 14, 2026 11:28
Параметр `userWordsToIgnore` диагностики Typo получил тип
`Either<String, List<String>>`: значение принимается как строка через
запятую (в том числе из SonarQube UI — там параметр остаётся скаляром)
так и как JSON-массив слов в `.bsl-language-server.json`.

В `DiagnosticHelper` добавлены переиспользуемые помощники для остальных
списочных параметров:
- `castParameterValue` — оборачивает значение из конфигурации в `Either`
  по типу целевого поля (строка → left, список → right);
- `asStringList` — разворачивает `Either` в список строк.

Схема параметров (`parameters-schema.json`) намеренно не правится руками —
она генерируется задачей `precommit`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W86iNs3Sj9wTS6NFFHvVbv
…ring>>

`@DiagnosticParameter(type = Either.class)` объявляет параметр-список,
который принимает строку через запятую (в т.ч. из SonarQube UI) либо
JSON-массив в `.bsl-language-server.json`. `DiagnosticParameterInfo`
теперь понимает `Either.class` (внешнее представление по умолчанию —
строка), а `DiagnosticHelper` включает его в набор применяемых типов.

Тип аннотации у `Typo.userWordsToIgnore` переведён на `Either.class` —
это единая точка, из которой генератор JSON-схемы (bslls-dev-tools) и
sonar-плагин выводят своё представление параметра.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W86iNs3Sj9wTS6NFFHvVbv
Параметр-список объявляется как `@DiagnosticParameter(type = List.class)`
с полем `List<String>` (вместо `Either<String, List<String>>`): «строка
через запятую ИЛИ массив» — это про входное представление, а не про тип
параметра, поэтому Either избыточен. Значение из конфигурации приводится
к `List<String>` в `DiagnosticHelper.castParameterValue` (строка → split
по запятой, JSON-массив → список). `asStringList(String)` разбирает
строку и переиспользуется для инициализации полей значением по умолчанию.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W86iNs3Sj9wTS6NFFHvVbv
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@nixel2007, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 31 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: deff3f52-1b63-4549-a7d5-00cadc35e004

📥 Commits

Reviewing files that changed from the base of the PR and between 150fbd5 and e2d0e41.

📒 Files selected for processing (1)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DiagnosticHelper.java
📝 Walkthrough

Walkthrough

Diagnostic configuration now supports List parameters, converting list or comma-separated values into List<String>. TypoDiagnostic uses this representation for ignored user words and includes a list-based configuration test.

Changes

Diagnostic list parameter support

Layer / File(s) Summary
List parameter conversion
src/main/java/.../diagnostics/DiagnosticHelper.java, src/main/java/.../diagnostics/info/DiagnosticParameterInfo.java
List fields are accepted and configured values are converted from lists or comma-separated strings into trimmed List<String> values.
TypoDiagnostic integration
src/main/java/.../diagnostics/TypoDiagnostic.java, src/test/java/.../diagnostics/TypoDiagnosticTest.java
Ignored user words use a list configuration, are joined when constructing exceptions, and are covered by a list-based test.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: claude

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: diagnostic List parameters now accept either a string or an array.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/diagnostic-params-string-list-28j3v4

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DiagnosticHelper.java`:
- Around line 157-165: Update castParameterValue to return null immediately when
value is null, before the List-type handling and any String.valueOf conversion.
Preserve the existing list conversion behavior for non-null values and return
the original value for non-list fields.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 78a5d3c1-0152-47f6-b6fd-3eddd48d0bce

📥 Commits

Reviewing files that changed from the base of the PR and between 316ff75 and 150fbd5.

📒 Files selected for processing (4)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DiagnosticHelper.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TypoDiagnostic.java
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/info/DiagnosticParameterInfo.java
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TypoDiagnosticTest.java

claude added 2 commits July 14, 2026 13:27
…ll"]

Если в конфигурации параметр-список задан как `null`, прежний код доходил
до `String.valueOf(value)` и получал строку "null" → список из одного
элемента "null". Добавлен ранний возврат `null` до обработки типа List
(поведение для null-значения — как раньше: присваивается полю как есть).

Замечание из ревью CodeRabbit на PR #4268.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W86iNs3Sj9wTS6NFFHvVbv
@nullable

Пакет помечен @NullMarked (JSpecify), поэтому возврат null из
castParameterValue нарушал контракт non-null (SonarCloud java:S2637,
Reliability). Возвращаемый тип помечен @nullable — метод легально
возвращает null для null-значения параметра.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W86iNs3Sj9wTS6NFFHvVbv
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

 3 636 files  ±0   3 636 suites  ±0   1h 53m 35s ⏱️ + 13m 57s
 3 594 tests +1   3 576 ✅ +1   18 💤 ±0  0 ❌ ±0 
21 564 runs  +6  21 452 ✅ +6  112 💤 ±0  0 ❌ ±0 

Results for commit e2d0e41. ± Comparison against base commit 316ff75.

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