Skip to content

Обновление зависимостей + null check#51

Merged
theshadowco merged 2 commits intomasterfrom
feature/bumpDeps260220
Feb 20, 2026
Merged

Обновление зависимостей + null check#51
theshadowco merged 2 commits intomasterfrom
feature/bumpDeps260220

Conversation

@theshadowco
Copy link
Copy Markdown
Member

No description provided.

@sonarqubecloud
Copy link
Copy Markdown

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 20, 2026

Walkthrough

Обновлён проект с переходом от Lombok и FindBugs на JSpecify для аннотаций нулевых ссылок, обновлены версии Gradle и зависимостей (JUnit, AssertJ), заменён лицензионный плагин и изменены правила включения/исключения файлов для лицензирования.

Changes

Cohort / File(s) Summary
Build and Gradle Configuration
build.gradle.kts, gradle/wrapper/gradle-wrapper.properties
Обновлена версия Gradle с 8.14.3 на 9.3.1; заменён лицензионный плагин и его конфигурация (переход от DSL к явному свойству, добавлены skipExistingHeaders, strictCheck, mapping); обновлены зависимости (добавлена JSpecify, обновлены JUnit и AssertJ); удалена зависимость SpotBugs annotations.
Gradle Wrapper Scripts
gradlew, gradlew.bat
Изменено выполнение wrapper: удалена переменная CLASSPATH и логика её обработки, добавлено прямое выполнение через -jar gradle-wrapper.jar вместо использования classpath с GradleWrapperMain.
Lombok Configuration Removal
lombok.config
Удалено свойство конфигурации lombok.extern.findbugs.addSuppressFBWarnings=true.
Null Annotation Migration
src/main/java/com/github/_1c_syntax/utils/Absolute.java, src/main/java/com/github/_1c_syntax/utils/CaseInsensitivePattern.java
Удалены аннотации @NonNull из Lombok в публичных методах и параметрах; удален импорт lombok.NonNull.
JSpecify Integration
src/main/java/com/github/_1c_syntax/utils/Lazy.java, src/main/java/com/github/_1c_syntax/utils/StringInterner.java
Заменены импорты Nullable: FindBugs на JSpecify; явно указаны типы локальных переменных (var → явный тип); добавлены @Nullable аннотации на поля; в maybeCompute() добавлен requireNonNull().
Type Inference Refactoring
src/main/java/com/github/_1c_syntax/utils/GenericInterner.java
Изменена локальная переменная с var на явный тип T для улучшения явности типов.
Package-Level Null Safety
src/main/java/com/github/_1c_syntax/utils/package-info.java
Добавлен новый файл package-info.java с аннотацией @NullMarked на уровне пакета для установки глобального контракта нулевой безопасности.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 С Lombok прощай, JSpecify привет!
Аннотации null-safe — вот здесь мой совет.
Gradle обновлён, зависимости в ряд,
Package-info файл нас теперь защитит от забот.
Wrapper гуляет быстрее по jar,
Код безопаснее стал — вот это да! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 52.94% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive Описание не было добавлено, но это не критично для данного типа изменений (обновление зависимостей и миграция аннотаций). Рекомендуется добавить описание, объясняющее миграцию с FindBugs на jspecify и обновление версий Gradle и зависимостей.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed Заголовок точно описывает основные изменения: обновление зависимостей и добавление проверок null через jspecify.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/bumpDeps260220

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
build.gradle.kts (1)

13-13: Закомментирован плагин validate-poms.

Плагин io.freefair.maven-central.validate-poms закомментирован. Если это временная мера (например, несовместимость с Gradle 9), рекомендуется оставить TODO-комментарий с пояснением причины и планом возврата.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@build.gradle.kts` at line 13, Плагин
"io.freefair.maven-central.validate-poms" сейчас закомментирован в
build.gradle.kts без объяснения причины; добавьте рядом с закомментированной
строкой TODO-комментарий, объясняющий причину (например, несовместимость с
Gradle 9 или временный баг), указав ожидаемое условие для восстановления и план
действий (например, цель версии плагина или тикет/дата), либо восстановите
плагин, если он уже совместим; ссылаться в комментарии на идентификатор плагина
"io.freefair.maven-central.validate-poms" для ясности.
src/main/java/com/github/_1c_syntax/utils/Lazy.java (1)

55-64: lock.unlock() не защищён try-finally — утечка блокировки при исключении.

Если maybeCompute выбросит исключение (включая новый requireNonNull(value) на строке 84 при конкурентном вызове clear()), lock.unlock() не будет вызван, и экземпляр Lazy окажется перманентно заблокирован.

Проблема существовала и раньше, но добавление requireNonNull(value) в maybeCompute создаёт дополнительную точку выброса исключения.

♻️ Предлагаемое исправление
   public T getOrCompute(Supplier<T> supplier) {
     final T result = value; // Just one volatile read
     if (result == null) {
       lock.lock();
-      var localResult = maybeCompute(supplier);
-      lock.unlock();
-      return localResult;
+      try {
+        return maybeCompute(supplier);
+      } finally {
+        lock.unlock();
+      }
     }
     return result;
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/com/github/_1c_syntax/utils/Lazy.java` around lines 55 - 64,
The getOrCompute method currently calls lock.lock(), then invokes
maybeCompute(supplier) and separately calls lock.unlock(), which can leak the
lock if maybeCompute throws (e.g., requireNonNull in maybeCompute when clear()
races). Change getOrCompute to acquire the lock and execute maybeCompute inside
a try block with a finally that always calls lock.unlock() so the lock is
released on success or exception; keep returning the computed value from the try
or rethrow the exception as-is. Ensure references to getOrCompute, maybeCompute
and lock.unlock are updated accordingly.
src/main/java/com/github/_1c_syntax/utils/Absolute.java (1)

48-48: Миграция с Lombok @NonNull на JSpecify @NullMarked меняет поведение при null-значениях в публичном API.

Удаление @NonNull означает отсутствие runtime-проверок вида if (param == null) throw new NullPointerException("param is null") в начале методов. Компиляция полагается на @NullMarked из package-info.java, что обеспечивает контроль на этапе компиляции (для JSpecify-совместимых инструментов). При передаче null в методы uri() и path() потребители без JSpecify-инструментов получат менее информативный NPE глубже в коде (например, на uri.replace(...) в строке 50) вместо ясного сообщения "uri is null".

Если это осознанное решение как часть миграции на JSpecify — всё в порядке. Если требуется fail-fast поведение для публичных методов, можно добавить явные Objects.requireNonNull(uri, "uri") вызовы.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/com/github/_1c_syntax/utils/Absolute.java` at line 48, The
public API lost runtime null checks when migrating from Lombok `@NonNull` to
JSpecify `@NullMarked`; add explicit fail-fast checks by calling
Objects.requireNonNull(...) at the start of the public methods (e.g.,
Absolute.uri(String uri) and Absolute.path(String path)) so a clear NPE with the
parameter name is thrown immediately rather than a later NPE inside operations
like uri.replace(...).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@build.gradle.kts`:
- Line 13: Плагин "io.freefair.maven-central.validate-poms" сейчас
закомментирован в build.gradle.kts без объяснения причины; добавьте рядом с
закомментированной строкой TODO-комментарий, объясняющий причину (например,
несовместимость с Gradle 9 или временный баг), указав ожидаемое условие для
восстановления и план действий (например, цель версии плагина или тикет/дата),
либо восстановите плагин, если он уже совместим; ссылаться в комментарии на
идентификатор плагина "io.freefair.maven-central.validate-poms" для ясности.

In `@src/main/java/com/github/_1c_syntax/utils/Absolute.java`:
- Line 48: The public API lost runtime null checks when migrating from Lombok
`@NonNull` to JSpecify `@NullMarked`; add explicit fail-fast checks by calling
Objects.requireNonNull(...) at the start of the public methods (e.g.,
Absolute.uri(String uri) and Absolute.path(String path)) so a clear NPE with the
parameter name is thrown immediately rather than a later NPE inside operations
like uri.replace(...).

In `@src/main/java/com/github/_1c_syntax/utils/Lazy.java`:
- Around line 55-64: The getOrCompute method currently calls lock.lock(), then
invokes maybeCompute(supplier) and separately calls lock.unlock(), which can
leak the lock if maybeCompute throws (e.g., requireNonNull in maybeCompute when
clear() races). Change getOrCompute to acquire the lock and execute maybeCompute
inside a try block with a finally that always calls lock.unlock() so the lock is
released on success or exception; keep returning the computed value from the try
or rethrow the exception as-is. Ensure references to getOrCompute, maybeCompute
and lock.unlock are updated accordingly.

@theshadowco theshadowco merged commit 263a95d into master Feb 20, 2026
15 checks passed
@theshadowco theshadowco deleted the feature/bumpDeps260220 branch February 20, 2026 08:05
value = requireNonNull(supplier.get());
}
return value;
return requireNonNull(value);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@theshadowco вот тут лишний вызов. Он точно обязателен? Может быть можно чуть переписать метод, чтобы по потоку кода тут не могло быть null?

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