- Notifications
You must be signed in to change notification settings - Fork 117
Новая диагностика: Повторное использование строковых литералов #1854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Новая диагностика: Повторное использование строковых литералов #1854
Conversation
| .collect(Collectors.groupingBy(this::getLiteralText)) | ||
| .forEach((String name, List<BSLParserRuleContext> literals) -> { | ||
| if (literals.size() > allowedNumberCopies) { | ||
| List<DiagnosticRelatedInformation> relatedInformation = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
кажется, ты забыл добавить первым related information само срабатывание диагностики (которое судя по VSCode все же нужно, хотя я все еще не уверен). иначе не вижу причин не использовать обычный toList
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
нет, не забыл, пропуска элементов у меня нет
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toList - да, согласен
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лишь бы в всц и сонаре не поплыло позиционирование :) в остальных местах первым элементом мы добавляем само срабатывание, но я уже не помню, почему
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
на скрине vsc - вроде верно прицепился
...a/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicateStringLiteralDiagnostic.java Show resolved Hide resolved
...a/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicateStringLiteralDiagnostic.java Show resolved Hide resolved
745a6d2 to c1f0a80 Compare | ### Особенности реализации диагностики | ||
| | ||
| - Диагностика с настройками по умолчанию не учитывает регистр символов литерала, т.о. считаются одинаковыми строки `АААА` и `АааА`. | ||
| - Нельзя указать минимальное значение анализируемого литерала меньше, чем значение по умолчанию. Это обусловлено тем, что часто используются служебные литералы, которые будут сильно фонить. Например: пустая строка "", числа-селекторы "1", "0" и т.д. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
опечатка - не минимальное значение, а "минимальную длину строкового литерала (с кавычками)"
| | ||
| - Диагностика с настройками по умолчанию не учитывает регистр символов литерала, т.о. считаются одинаковыми строки `АААА` и `АааА`. | ||
| - Нельзя указать минимальное значение анализируемого литерала меньше, чем значение по умолчанию. Это обусловлено тем, что часто используются служебные литералы, которые будут сильно фонить. Например: пустая строка "", числа-селекторы "1", "0" и т.д. | ||
| - Нельзя уменьшить допустимое количество повторов использования меньше 1, т.к. это не имеет практического смысла. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
опечатка - не меньше 1, а меньше 2, т.к. и 1, и 0 бессмысленнны
| public void configure(Map<String, Object> configuration) { | ||
| super.configure(configuration); | ||
| // ноль использовать нельзя | ||
| if (allowedNumberCopies < 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
лучше поставить < 2 или <= 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Описание
Новая диагностика для многократного использования строковых литералов
Связанные задачи
Closes: #1224
Чеклист
Общие
gradlew precommit)Для диагностик
Дополнительно