ANDR-103: добавила правило detekt#152
Open
Nuriua wants to merge 1 commit into
Open
Conversation
Yrun00
requested changes
Jun 8, 2026
| override val issue = Issue( | ||
| "NoNotNullAssertionRule", | ||
| Severity.Style, | ||
| "Оператор !! запрещён. Используйте безопасные вызовы (.?) или элвис-оператор (?:).", |
Collaborator
There was a problem hiding this comment.
Предлагаю расширить формулировку - замена !! на ?. или ?: не всегда корректна, потому что в местах с обязательным контрактом это может скрыть ошибку дефолтным значением или невыполнением кода. Лучше явно разрешить fail-fast варианты: requireNotNull для проверки входных аргументов и checkNotNull для проверки внутренних инвариантов/состояния. Тогда мы не теряем понятное падение там, где null означает баг в коде.
(понятно, что текущая подсказка их не запрещает - но может сложиться впечатление что разрешены только ?: и .?)
Или добавить подсказку, что для явных fail-fast вариантов можно использовать ?: error("error text") - мне было не очевидно что ?: возможно применять и таким образом.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🧩 Что сделано:
• Добавила правило NoNotNullAssertionRule (запрет на !!) для detekt
🗂 Затронутые модули:
• detekt-rules
На данный момент проект не собирается!