Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions docs/diagnostics/MetadataBorders.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Границы метаданных (MetadataBorders)

| Тип | Поддерживаются<br>языки | Важность | Включена<br>по умолчанию | Время на<br>исправление (мин) | Теги |
|:-------------:|:-----------------------------:|:----------------:|:------------------------------:|:-----------------------------------:|:--------:|
| `Дефект кода` | `BSL`<br>`OS` | `Информационный` | `Нет` | `1` | `design` |

## Параметры


| Имя | Тип | Описание | Значение<br>по умолчанию |
|:---------------------------:|:--------:|:---------------------------------------------------------------------------------------:|:------------------------------:|
| `metadataBordersParameters` | `Строка` | `{"регулярное выражение для операторов":"регулярное выражение для имени файла модуля"}` | `` |
<!-- Блоки выше заполняются автоматически, не трогать -->
## Описание диагностики
Диагностика обращения к метаданным за пределами разрешенных границ. Нужна, если в компании установлены,
например, правила обращения к каким-то метаданным только из определенного общего модуля.

## Примеры
Получение контактной информации по внутренним правилам должно происходить только через функции
общего модуля РаботаСКонтактами. Тогда заданные настройки вида

```json
{"Регистры?Сведений.КонтактнаяИнформация":"CommonModules/РаботаСКонтактами"}
```

вызовут срабатывание диагностики на запросе с текстом

```
"ВЫБРАТЬ
...
ИЗ
РегистрСведений.КонтактнаяИнформация КАК КИ"
```
Comment on lines +28 to +33
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add a language identifier to the fenced query example.

The fenced block is missing a language tag, which triggers MD040 and reduces readability.

🛠️ Suggested fix
-```
+```text
 "ВЫБРАТЬ
     ...
 ИЗ
     РегистрСведений.КонтактнаяИнформация КАК КИ"
-```
+```
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```
"ВЫБРАТЬ
...
ИЗ
РегистрСведений.КонтактнаяИнформация КАК КИ"
```
🧰 Tools
🪛 markdownlint-cli2 (0.21.0)

[warning] 28-28: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

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

In `@docs/diagnostics/MetadataBorders.md` around lines 28 - 33, The fenced code
block showing the query example lacks a language identifier and triggers MD040;
add a language tag (e.g., "text" or "sql") to the opening fence so the block
begins with ```text (or ```sql) before the query string ("ВЫБРАТЬ ...
РегистрСведений.КонтактнаяИнформация КАК КИ") to satisfy the linter and improve
readability.


если этот запрос будет НЕ в общем модуле РаботаСКонтактами.
Так же эта диагностика с такой настройкой сработает и на оператор

```НаборЗаписей = РегистрыСведений.КонтактнаяИнформация.СоздатьНаборЗаписей();```

В настройках обе части - это регулярные выражения java.
Вторая часть настройки сравнивается с путем к файлу выгрузки конфигурации.

Можно запретить использование нескольких метаданных:

```json
{"Регистры?Сведений.КонтактнаяИнформация|Справочники?.Контакты":"CommonModules/РаботаСКонтактами"}
```

Настройки задаются в виде json-строки:
```json
{
"Регистры?Сведений.КонтактнаяИнформация":"CommonModules/РаботаСКонтактами",
"Справочники?.СтрокиСоединения":"DataProcessors/ВнешниеСоединения|CommonModules/ПодключениеК.*"
}
```

## Источники

## Сниппеты

<!-- Блоки ниже заполняются автоматически, не трогать -->
### Экранирование кода

```bsl
// BSLLS:MetadataBorders-off
// BSLLS:MetadataBorders-on
```

### Параметр конфигурационного файла

```json
"MetadataBorders": {
"metadataBordersParameters": ""
}
```
44 changes: 44 additions & 0 deletions docs/en/diagnostics/MetadataBorders.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Metadata borders (MetadataBorders)

| Type | Scope | Severity | Activated<br>by default | Minutes<br>to fix | Tags |
|:------------:|:-------------------:|:--------:|:-----------------------------:|:-----------------------:|:--------:|
| `Code smell` | `BSL`<br>`OS` | `Info` | `No` | `1` | `design` |

## Parameters


| Name | Type | Description | Default value |
|:---------------------------:|:--------:|:---------------------------------------------------:|:-------------:|
| `metadataBordersParameters` | `String` | `{"regex for statements":"regex for module names"}` | `` |
<!-- Блоки выше заполняются автоматически, не трогать -->
## Description
<!-- Описание диагностики заполняется вручную. Необходимо понятным языком описать смысл и схему работу -->

## Examples
<!-- В данном разделе приводятся примеры, на которые диагностика срабатывает, а также можно привести пример, как можно исправить ситуацию -->

Comment on lines +14 to +19
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fill in the English Description/Examples sections (currently placeholders).

These sections must be real content (including a problematic snippet and fix) to match the RU doc and project guidelines.
As per coding guidelines: "Update diagnostic documentation in both Russian and English with examples of problematic code and fixes."

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

In `@docs/en/diagnostics/MetadataBorders.md` around lines 14 - 19, The English
"Description" and "Examples" sections in MetadataBorders.md are placeholder
text; replace them with a clear English description of the diagnostic (what it
detects and how it works) under the "## Description" heading and add concrete
Examples under "## Examples" that include a problematic code snippet that
triggers the diagnostic and a corrected snippet showing the fix; ensure the
content mirrors the Russian doc's intent and follows project guidelines by
providing both the failing sample and the corrected sample for the diagnostic.

## Sources
<!-- Необходимо указывать ссылки на все источники, из которых почерпнута информация для создания диагностики -->
<!-- Примеры источников
* Источник: [Стандарт: Тексты модулей](https://its.1c.ru/db/v8std#content:456:hdoc)
* Полезная информация: [Отказ от использования модальных окон](https://its.1c.ru/db/metod8dev#content:5272:hdoc)
* Источник: [Cognitive complexity, ver. 1.4](https://www.sonarsource.com/docs/CognitiveComplexity.pdf) -->

## Snippets

<!-- Блоки ниже заполняются автоматически, не трогать -->
### Diagnostic ignorance in code

```bsl
// BSLLS:MetadataBorders-off
// BSLLS:MetadataBorders-on
```

### Parameter for config

```json
"MetadataBorders": {
"metadataBordersParameters": ""
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* This file is a part of BSL Language Server.
*
* Copyright (c) 2018-2021
* Alexey Sosnoviy <labotamy@gmail.com>, Nikita Gryzlov <nixel2007@gmail.com> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* BSL Language Server is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* BSL Language Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with BSL Language Server.
*/
package com.github._1c_syntax.bsl.languageserver.diagnostics;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.MapType;
import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticMetadata;
import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticParameter;
import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity;
import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag;
import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType;
import com.github._1c_syntax.bsl.parser.BSLParser;
import com.github._1c_syntax.utils.CaseInsensitivePattern;
import org.antlr.v4.runtime.tree.ParseTree;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

@DiagnosticMetadata(
type = DiagnosticType.CODE_SMELL,
severity = DiagnosticSeverity.INFO,
minutesToFix = 1,
activatedByDefault = false,
tags = {
DiagnosticTag.DESIGN
}

)
public class MetadataBordersDiagnostic extends AbstractVisitorDiagnostic {

Comment on lines +44 to +55
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add class-level JavaDoc for the public diagnostic.
As per coding guidelines: "Write JavaDoc for public APIs and include comments for complex logic."

🤖 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/bsl/languageserver/diagnostics/MetadataBordersDiagnostic.java`
around lines 44 - 55, Add a class-level JavaDoc to the public
MetadataBordersDiagnostic class that succinctly describes the diagnostic's
purpose and behavior, documents its severity/activation (referencing the
`@DiagnosticMetadata` annotation values), explains what code pattern or metadata
border it detects, and notes any important usage/configuration details (e.g.,
activatedByDefault=false, DiagnosticTag.DESIGN) and expected fix guidance; place
the JavaDoc immediately above the class declaration (public class
MetadataBordersDiagnostic extends AbstractVisitorDiagnostic) and keep it concise
but informative for public API consumers.

private static final String METADATA_BORDERS_DEFAULT = "";

@DiagnosticParameter(
type = String.class,
defaultValue = ""
)
private Map<Pattern, Pattern> metadataBordersParameters = mapFromJSON(METADATA_BORDERS_DEFAULT);

private List<Pattern> statementPatterns = Collections.emptyList();

private static Map<Pattern, Pattern> mapFromJSON(String userSettings) {
ObjectMapper mapper = new ObjectMapper();
MapType mapType = mapper.getTypeFactory().constructMapType(HashMap.class, String.class, String.class);
try {
Map<String, String> stringMap = mapper.readValue(userSettings, mapType);
return stringMap.entrySet().stream()
.filter(entry -> !entry.getKey().isBlank() && !entry.getValue().isBlank())
.collect(Collectors.toMap(
entry -> CaseInsensitivePattern.compile(entry.getKey()),
entry -> CaseInsensitivePattern.compile(entry.getValue())));
} catch (JsonProcessingException e) {
Comment on lines +66 to +76
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify how other diagnostics handle invalid regex patterns and whether PatternSyntaxException
# is already handled centrally.
rg -n "CaseInsensitivePattern\.compile|Pattern\.compile" src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics
rg -n "PatternSyntaxException" src/main/java/com/github/_1c_syntax/bsl/languageserver

Repository: 1c-syntax/bsl-language-server

Length of output: 28434


🏁 Script executed:

# Find and examine the CaseInsensitivePattern class to understand its compile method
fd -t f "CaseInsensitivePattern.java" src/

Repository: 1c-syntax/bsl-language-server

Length of output: 55


🏁 Script executed:

# Examine the MetadataBordersDiagnostic.java file to understand the full context
cat -n src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MetadataBordersDiagnostic.java | head -100

Repository: 1c-syntax/bsl-language-server

Length of output: 4685


🏁 Script executed:

fd -t f "CaseInsensitivePattern.java" src/

Repository: 1c-syntax/bsl-language-server

Length of output: 55


🏁 Script executed:

# Also check if there are any tests for mapFromJSON or exception handling
fd -t f "MetadataBordersDiagnosticTest.java" .

Repository: 1c-syntax/bsl-language-server

Length of output: 176


🏁 Script executed:

# Find CaseInsensitivePattern - it might be in a different location
rg -l "class CaseInsensitivePattern" src/

Repository: 1c-syntax/bsl-language-server

Length of output: 55


🏁 Script executed:

# Examine the test file to see how mapFromJSON is tested
cat -n src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/MetadataBordersDiagnosticTest.java

Repository: 1c-syntax/bsl-language-server

Length of output: 3697


🏁 Script executed:

# Search more broadly for CaseInsensitivePattern
rg "class CaseInsensitivePattern|new CaseInsensitivePattern" --max-count 5

Repository: 1c-syntax/bsl-language-server

Length of output: 55


🏁 Script executed:

# Check if CaseInsensitivePattern is imported from an external library
rg "import.*CaseInsensitivePattern" src/

Repository: 1c-syntax/bsl-language-server

Length of output: 14028


🏁 Script executed:

# Let's also check if Pattern.compile is ever wrapped or if PatternSyntaxException is ever caught
rg "catch.*PatternSyntaxException" src/

Repository: 1c-syntax/bsl-language-server

Length of output: 198


🏁 Script executed:

# Check the broader context of error handling in diagnostics with user-supplied patterns
rg -A5 "\.compile\(" src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ | grep -A5 "catch"

Repository: 1c-syntax/bsl-language-server

Length of output: 655


🏁 Script executed:

# Check SymbolProvider.java to see how it handles PatternSyntaxException
sed -n '70,85p' src/main/java/com/github/_1c_syntax/bsl/languageserver/providers/SymbolProvider.java

Repository: 1c-syntax/bsl-language-server

Length of output: 713


🏁 Script executed:

# Check if there are any other diagnostics that accept user configuration for patterns
rg "@DiagnosticParameter.*String" src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ -A5 | grep -B5 "\.compile"

Repository: 1c-syntax/bsl-language-server

Length of output: 416


🏁 Script executed:

# Check ReservedParameterNamesDiagnostic to see if it handles PatternSyntaxException
sed -n '45,70p' src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ReservedParameterNamesDiagnostic.java

Repository: 1c-syntax/bsl-language-server

Length of output: 771


🏁 Script executed:

# Check BadWordsDiagnostic which also compiles user-supplied patterns
sed -n '50,75p' src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic.java

Repository: 1c-syntax/bsl-language-server

Length of output: 879


🏁 Script executed:

# Look for other DiagnosticParameter with String type that compile patterns
rg "@DiagnosticParameter" src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ -A3 | grep -B3 -A3 "String.class"

Repository: 1c-syntax/bsl-language-server

Length of output: 17642


Add exception handling for invalid regex patterns in user-supplied metadataBordersParameters.

The mapFromJSON method currently only catches JsonProcessingException, leaving PatternSyntaxException from CaseInsensitivePattern.compile unhandled. Invalid user-supplied regex patterns will crash configuration loading. Add a try-catch around the pattern compilation or filter out invalid entries to keep the server resilient, following the pattern used in SymbolProvider.java.

🤖 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/bsl/languageserver/diagnostics/MetadataBordersDiagnostic.java`
around lines 66 - 76, The mapFromJSON method currently only catches
JsonProcessingException but may throw PatternSyntaxException when
CaseInsensitivePattern.compile(entry.getKey()) or compile(entry.getValue())
receives invalid regex from metadataBordersParameters; update mapFromJSON to
handle invalid patterns the same way as SymbolProvider.java by wrapping the
compilation in a try-catch (catch PatternSyntaxException) or using a helper that
returns Optional, then filter out or skip entries with invalid regex and log a
warning (do not let the exception propagate) so configuration loading remains
resilient.

return Collections.emptyMap();
}
}

@Override
public void configure(Map<String, Object> configuration) {
metadataBordersParameters = mapFromJSON(
(String) configuration.getOrDefault("metadataBordersParameters", METADATA_BORDERS_DEFAULT));
}

@Override
public ParseTree visitFile(BSLParser.FileContext ctx) {
statementPatterns = metadataBordersParameters.entrySet().stream()
.filter(entry -> ! entry.getValue().matcher(documentContext.getUri().getPath()).find())
.map(Map.Entry::getKey)
.collect(Collectors.toList());

return super.visitFile(ctx);
}

@Override
public ParseTree visitStatement(BSLParser.StatementContext ctx){

statementPatterns.forEach(pattern -> {
Matcher matcher = pattern.matcher(ctx.getText());
while (matcher.find()) {
diagnosticStorage.addDiagnostic(ctx);
}
Comment on lines +100 to +104
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Avoid duplicate diagnostics per statement.

The loop adds a diagnostic for every regex hit in the same statement, which can produce duplicates. Consider short‑circuiting after the first match.

✅ Suggested fix
-    statementPatterns.forEach(pattern -> {
-      Matcher matcher = pattern.matcher(ctx.getText());
-      while (matcher.find()) {
-        diagnosticStorage.addDiagnostic(ctx);
-      }
-    });
+    for (Pattern pattern : statementPatterns) {
+      if (pattern.matcher(ctx.getText()).find()) {
+        diagnosticStorage.addDiagnostic(ctx);
+        break;
+      }
+    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
statementPatterns.forEach(pattern -> {
Matcher matcher = pattern.matcher(ctx.getText());
while (matcher.find()) {
diagnosticStorage.addDiagnostic(ctx);
}
for (Pattern pattern : statementPatterns) {
if (pattern.matcher(ctx.getText()).find()) {
diagnosticStorage.addDiagnostic(ctx);
break;
}
}
🤖 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/bsl/languageserver/diagnostics/MetadataBordersDiagnostic.java`
around lines 100 - 104, The current lambda over statementPatterns runs
diagnosticStorage.addDiagnostic(ctx) for every regex hit, creating duplicates;
change the logic in MetadataBordersDiagnostic so each statement only yields one
diagnostic by short‑circuiting after the first match (e.g., replace the forEach
with a loop or use a flag so that when matcher.find() triggers
diagnosticStorage.addDiagnostic(ctx) you break out of the pattern loop/stop
further matching for that ctx). Refer to statementPatterns, Matcher matcher, and
diagnosticStorage.addDiagnostic(ctx) to locate and modify the code.

});

return super.visitStatement(ctx);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,24 @@
},
"$id": "#/definitions/MagicNumber"
},
"MetadataBorders": {
"description": "Metadata borders",
"default": false,
"type": [
"boolean",
"object"
],
"title": "Metadata borders",
"properties": {
"metadataBordersParameters": {
"description": "{\"regex for statements\":\"regex for module names\"}",
"default": "",
"type": "string",
"title": "{\"regex for statements\":\"regex for module names\"}"
}
},
"$id": "#/definitions/MetadataBorders"
},
"MetadataObjectNameLength": {
"description": "Metadata object names must not exceed the allowed length",
"default": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
"AssignAliasFieldsInQuery": {
"$ref": "parameters-schema.json#/definitions/AssignAliasFieldsInQuery"
},
"BadWords": {
"$ref": "parameters-schema.json#/definitions/BadWords"
},
"BeginTransactionBeforeTryCatch": {
"$ref": "parameters-schema.json#/definitions/BeginTransactionBeforeTryCatch"
},
Expand Down Expand Up @@ -278,6 +275,9 @@
"MagicNumber": {
"$ref": "parameters-schema.json#/definitions/MagicNumber"
},
"MetadataBorders": {
"$ref": "parameters-schema.json#/definitions/MetadataBorders"
},
"MetadataObjectNameLength": {
"$ref": "parameters-schema.json#/definitions/MetadataObjectNameLength"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
diagnosticMessage=Use metadata outside the borders
diagnosticName=Metadata borders
metadataBordersParameters={"regex for statements":"regex for module names"}

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
diagnosticMessage=Обращение к метаданным за пределами разрешенных границ
diagnosticName=Границы метаданных
metadataBordersParameters={"регулярное выражение для операторов":"регулярное выражение для имени файла модуля"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* This file is a part of BSL Language Server.
*
* Copyright (c) 2018-2021
* Alexey Sosnoviy <labotamy@gmail.com>, Nikita Gryzlov <nixel2007@gmail.com> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* BSL Language Server is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* BSL Language Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with BSL Language Server.
*/
package com.github._1c_syntax.bsl.languageserver.diagnostics;

import org.eclipse.lsp4j.Diagnostic;
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.Map;

import static com.github._1c_syntax.bsl.languageserver.util.Assertions.assertThat;

class MetadataBordersDiagnosticTest extends AbstractDiagnosticTest<MetadataBordersDiagnostic> {
MetadataBordersDiagnosticTest() {
super(MetadataBordersDiagnostic.class);
}

@Test
void testWithoutSettings() {
List<Diagnostic> diagnostics = getDiagnostics();
assertThat(diagnostics).hasSize(0);
}

@Test
void testMatchesInProperModule() {

Map<String, Object> configuration = diagnosticInstance.info.getDefaultConfiguration();
configuration.put("metadataBordersParameters",
"{\"Регистры?Сведений.КонтактнаяИнформация|Справочники?.Контакты\":\"fake-uri\"}");
diagnosticInstance.configure(configuration);
List<Diagnostic> diagnostics = getDiagnostics();

assertThat(diagnostics).hasSize(0);
}

@Test
void testMatchesInWrongModule() {

Map<String, Object> configuration = diagnosticInstance.info.getDefaultConfiguration();
configuration.put("metadataBordersParameters",
"{\"Регистры?Сведений.КонтактнаяИнформация|Справочники?.Контакты\":\"MetadataBordersDiagnostic\"}");
diagnosticInstance.configure(configuration);
List<Diagnostic> diagnostics = getDiagnostics();

assertThat(diagnostics).hasSize(3);
assertThat(diagnostics, true)
.hasRange(3, 0, 6, 49)
.hasRange(8, 0, 8, 69)
.hasRange(10, 0, 10, 103);
}

@Test
void testSeveralSettings() {

Map<String, Object> configuration = diagnosticInstance.info.getDefaultConfiguration();
configuration.put("metadataBordersParameters",
"{\"Регистры?Сведений.КонтактнаяИнформация\":\"fake-uri\"," +
"\"Справочники?.Контакты\":\"MetadataBordersDiagnostic\"}");
diagnosticInstance.configure(configuration);

List<Diagnostic> diagnostics = getDiagnostics();

assertThat(diagnostics).hasSize(1);
assertThat(diagnostics, true)
.hasRange(10, 0, 10, 103);
}
}
11 changes: 11 additions & 0 deletions src/test/resources/diagnostics/MetadataBordersDiagnostic.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// в комментарии срабатываний быть не должно РегистрыСведений.КонтактнаяИнформация

Запрос = Новый Запрос;
Запрос.Текст = "ВЫБРАТЬ
| КИ.ЗначениеКонтакта КАК Адрес
|ИЗ
| РегистрСведений.КонтактнаяИнформация КАК КИ"; //срабатывание

Адреса = РегистрыСведений.КонтактнаяИнформация.СоздатьНаборЗаписей(); //срабатывание

АдресИзСправочника = ЗначениеРеквизитаОбъекта(Справочники.Контакты.НайтиПоКоду(1), "ЗначениеКонтакта"); // срабатывание