Skip to content

Commit f7ec65c

Browse files
nixel2007otymko
andauthored
New Crowdin updates (#1639)
Co-authored-by: Oleg Tymko <olegtymko@yandex.ru>
1 parent 06b9e00 commit f7ec65c

File tree

150 files changed

+681
-382
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+681
-382
lines changed

docs/en/contributing/DiagnosticStructure.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ This article contains rules of diagnostics usage, creation and information about
1111
- [Diagnostics class, inherits from AbstractListenerDiagnostic **(Work in Progress)**](#%d0%9a%d0%bb%d0%b0%d1%81%d1%81-%d0%b4%d0%b8%d0%b0%d0%b3%d0%bd%d0%be%d1%81%d1%82%d0%b8%d0%ba%d0%b8-%d1%83%d0%bd%d0%b0%d1%81%d0%bb%d0%b5%d0%b4%d0%be%d0%b2%d0%b0%d0%bd%d0%bd%d1%8b%d0%b9-%d0%be%d1%82-abstractlistenerdiagnostic-%d0%92-%d0%a0%d0%90%d0%97%d0%a0%d0%90%d0%91%d0%9e%d0%a2%d0%9a%d0%95)
1212
- [Diagnostics test class](#%d0%9a%d0%bb%d0%b0%d1%81%d1%81-%d1%82%d0%b5%d1%81%d1%82%d0%b0-%d0%b4%d0%b8%d0%b0%d0%b3%d0%bd%d0%be%d1%81%d1%82%d0%b8%d0%ba%d0%b8)
1313
- [Diagnostics test](#%d0%a2%d0%b5%d1%81%d1%82-%d0%b4%d0%b8%d0%b0%d0%b3%d0%bd%d0%be%d1%81%d1%82%d0%b8%d0%ba%d0%b8)
14-
- [Test of configuration method for parametrized diagnostics](#%d0%a2%d0%b5%d1%81%d1%82-%d0%bc%d0%b5%d1%82%d0%be%d0%b4%d0%b0-%d0%ba%d0%be%d0%bd%d1%84%d0%b8%d0%b3%d1%83%d1%80%d0%b8%d1%80%d0%be%d0%b2%d0%b0%d0%bd%d0%b8%d1%8f-%d0%b4%d0%bb%d1%8f-%d0%bf%d0%b0%d1%80%d0%b0%d0%bc%d0%b5%d1%82%d1%80%d0%b8%d0%b7%d0%be%d0%b2%d0%b0%d0%bd%d0%bd%d1%8b%d1%85-%d0%b4%d0%b8%d0%b0%d0%b3%d0%bd%d0%be%d1%81%d1%82%d0%b8%d0%ba)
14+
- [Test of configuration method for parameterized diagnostics](#%d0%a2%d0%b5%d1%81%d1%82-%d0%bc%d0%b5%d1%82%d0%be%d0%b4%d0%b0-%d0%ba%d0%be%d0%bd%d1%84%d0%b8%d0%b3%d1%83%d1%80%d0%b8%d1%80%d0%be%d0%b2%d0%b0%d0%bd%d0%b8%d1%8f-%d0%b4%d0%bb%d1%8f-%d0%bf%d0%b0%d1%80%d0%b0%d0%bc%d0%b5%d1%82%d1%80%d0%b8%d0%b7%d0%be%d0%b2%d0%b0%d0%bd%d0%bd%d1%8b%d1%85-%d0%b4%d0%b8%d0%b0%d0%b3%d0%bd%d0%be%d1%81%d1%82%d0%b8%d0%ba)
1515
- [Quick fixes test **(Work in progress)**](#%d0%a2%d0%b5%d1%81%d1%82-%22%d0%b1%d1%8b%d1%81%d1%82%d1%80%d1%8b%d1%85-%d0%b7%d0%b0%d0%bc%d0%b5%d0%bd%22-%d0%92-%d0%a0%d0%90%d0%97%d0%a0%d0%90%d0%91%d0%9e%d0%a2%d0%9a%d0%95)
1616
- [Diagnostics resources](#%d0%a0%d0%b5%d1%81%d1%83%d1%80%d1%81%d1%8b-%d0%b4%d0%b8%d0%b0%d0%b3%d0%bd%d0%be%d1%81%d1%82%d0%b8%d0%ba%d0%b8)
1717
- [Diagnostics test resources](#%d0%a0%d0%b5%d1%81%d1%83%d1%80%d1%81%d1%8b-%d1%82%d0%b5%d1%81%d1%82%d0%b0-%d0%b4%d0%b8%d0%b0%d0%b3%d0%bd%d0%be%d1%81%d1%82%d0%b8%d0%ba%d0%b8)
1818
- [Diagnostics description](#%d0%9e%d0%bf%d0%b8%d1%81%d0%b0%d0%bd%d0%b8%d0%b5-%d0%b4%d0%b8%d0%b0%d0%b3%d0%bd%d0%be%d1%81%d1%82%d0%b8%d0%ba%d0%b8)
1919

2020
## Diagnostics structure
2121

22-
Diagnostics consists of a set of files, which are described in detail in the sections below.
22+
Diagnostics consists of a set of files, which are described in detail in the sections below.
2323
The required set of files as part of the diagnostics at the time of this writing and the rules for their naming
2424

25-
- Diagnostic implementation class. The file name is formed according to the principle `% Diagnostic Key% ` + ` Diagnosctic.java `
26-
- Diagnostics test class. The file name is generated according to the principle `% Diagnostic Key% ` + ` DiagnoscticTest.java `
27-
- Diagnostic resource file in Russian. The file name is formed according to the principle `% Diagnostic Key% ` + ` Diagnosctic_en.properties `
28-
- Diagnostic resource file in English. The file name is formed according to the principle `% Diagnostic Key% ` + ` Diagnosctic_en.properties `
25+
- Diagnostic implementation class. The file name is formed according to the principle `% Diagnostic Key%` + `Diagnosctic.java`
26+
- Diagnostics test class. The file name is generated according to the principle `%DiagnosticKey%` + `DiagnoscticTest.java`
27+
- Diagnostic resource file in Russian. The file name is formed according to the principle `%DiagnosticKey%` + `Diagnosctic_en.properties`
28+
- Diagnostic resource file in English. The file name is formed according to the principle `%DiagnosticKey%` + `Diagnosctic_en.properties`
2929
- Resource file (fixture) test. The file name is formed according to the principle `%DiagnosticKey%` + `Diagnosctic.bsl`
3030
- Diagnostic description file in Russian. The file name is formed according to the principle `%DiagnosticKey%` + `.md`
3131
- Diagnostic resource file in English. The file name is formed according to the principle `%DiagnosticKey%` + `.md`
@@ -37,20 +37,20 @@ To create necessary files in right places, should run command `gradlew newDiagno
3737

3838
Diagnostics is implemented by adding a java class to the `com.github._1c_syntax.bsl.languageserver.diagnostics` package in the `src/main/java` directory.
3939

40-
In the body of the file, you need to specify the package to which the class and the import block_ are added (when using ide, the import list is updated automatically)_. It is necessary to ensure that **only** is imported that is necessary for implementation, everything unused should be **removed** _ (if [settings](EnvironmentSetting.md) are correct, then ide will do everything automatically)_.
40+
In the body of the file, you need to specify the package to which the class and the import block are added _(when using ide, the import list is updated automatically)_. It is necessary to ensure that **only** is imported that is necessary for implementation, everything unused should be **removed** _(if [settings](EnvironmentSetting.md) are correct, then ide will do everything automatically)_.
4141

4242
Each diagnostic must have a `@DiagnosticMetadata`, class annotation containing diagnostic metadata. The actual content can always be obtained by examining the [file](https://github.com/1c-syntax/bsl-language-server/blob/develop/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticMetadata.java).
4343

44-
На момент написания статьи имеются следующие свойства:
44+
At the time of this writing, the following properties are available:
4545

46-
- The type of diagnostics is `type` and its importance is `severity`, for each diagnostics it is necessary to define them. Для того, чтобы правильно выбрать тип и важность диагностики, можно обратиться к [статье](DiagnosticTypeAndSeverity.md).
47-
- Время на исправление замечания `minutesToFix` (по умолчанию 0). Данное значение используется при расчете общего техдолга проекта в трудозатрах на исправление всех замечаний (сумма времени на исправление по всем обнаруженным замечаниям). Стоит указывать время, максимально реалистичное, которое разработчик должен потратить на исправление.
48-
- Набор тэгов `tag` диагностики, указывающих группы, к котором она относится. Read more about tags in the [article](DiagnosticTag.md).
49-
- Границы применимости `scope` (по умолчанию `ALL`, т.е. без ограничения). BSL LS поддерживает несколько языков (oscript и bsl) и диагностики могут применяться как к одному конкретному языку, так и ко всем сразу.
50-
- Default diagnostic active `activatedByDefault` (default `True`). При разработке экспериментальных, спорных либо не применимых в большинстве проектов, стоит по умолчанию отключать диагностику, активацию выполнит конечный пользователь решения.
51-
- Режим совместимости `compatibilityMode`, по которому фильтруются диагностики при использовании метаданных. The default is `UNDEFINED`.
46+
- The type of diagnostics is `type` and its importance is `severity`, for each diagnostics it is necessary to define them. In order to choose the correct type and importance of diagnostics, you can refer to [article](DiagnosticTypeAndSeverity.md).
47+
- Time to fix issue `minutesToFix` (default 0). This value is used when calculating the total technical debt of the project in labor costs to correct all comments (the sum of time to correct for all detected comments). It is worth indicating the time, as realistic as possible, that the developer should spend on fixing.
48+
- A set of diagnostics tags `tag` that indicate the group to which it belongs. Read more about tags in the [article](DiagnosticTag.md).
49+
- Applicability limit `scope` (by default `ALL`, i.e. no limit). BSL LS supports multiple languages (oscript and bsl) and diagnostics can be applied to one specific language or to all at once.
50+
- Default diagnostic active `activatedByDefault` (default `True`). When developing experimental, controversial, or not applicable in most projects, it is worth turning off diagnostics by default, the activation will be performed by the end user of the solution.
51+
- Compatibility mode `compatibilityMode`, by which diagnostics are filtered when using metadata. The default is `UNDEFINED`.
5252

53-
Последние два могут быть опущены.
53+
The last two can be omitted.
5454

5555
Annotation example
5656

@@ -68,11 +68,11 @@ Annotation example
6868
)
6969
```
7070

71-
Класс должен реализовывать интерфейс `BSLDiagnostic`. Если диагностика основывается на AST дереве, то класс реализации должен быть унаследован от одного из классов ниже, реализующих `BSLDiagnostic`:
71+
Class should implement the interface `BSLDiagnostic`. If diagnostic bases on AST, that class should extends at one of classes, that implement `BSLDiagnostic` below:
7272

73-
- для простых диагностик (проверка контекста модуля) стоит использовать наследование `AbstractVisitor` с реализацией единственного метода `check`
74-
- при необходимости анализа посещения узла / последовательности узлов, использовать стратегию `слушателя` нужно наследовать класс от `AbstractListenerDiagnostic`
75-
- в остальных случаях нужно использовать стратегию `визитера` и
73+
- for simple diagnostics (module context checking) it is worth using inheritance `AbstractVisitor` with the implementation of a single `check` method
74+
- if you need to analyze a visit to a node / sequence of nodes, use the `listener` strategy, you need to inherit the class from `AbstractListenerDiagnostic`
75+
- in other cases, you need to use the strategy `visitor` and
7676
- `AbstractVisitorDiagnostic` for diagnostics of 1C code
7777
- `AbstractSDBLVisitorDiagnostic` for diagnostics of 1C query
7878

@@ -98,7 +98,7 @@ public class TemplateDiagnostic extends AbstractListenerDiagnostic
9898
public class TemplateDiagnostic extends AbstractSDBLVisitorDiagnostic
9999
```
100100

101-
Диагностика может предоставлять т.н. `быстрые исправления`, для чего класс диагностики должен реализовывать интерфейс `QuickFixProvider`. Подробно о добавлении `быстрых исправлений` в диагностику написано [статье](DiagnosticQuickFix.md).
101+
Diagnostic may provide so-called `quick fixes`. In order to provide quick fixes the diagnostic class must implement `QuickFixProvider` interface. See this [article](DiagnosticQuickFix.md) on adding a `quick fix` to diagnostic.
102102

103103
Examples
104104

@@ -122,9 +122,9 @@ public class TemplateDiagnostic extends AbstractListenerDiagnostic implements Qu
122122
public class TemplateDiagnostic extends AbstractSDBLVisitorDiagnostic implements QuickFixProvider
123123
```
124124

125-
После объявления класса, для параметризуемых диагностик располагается блок с их параметрами. Подробно о параметрах диагностик написано в [статье](DiagnostcAddSettings.md).
125+
After the declaration of the class, a block with their parameters is located for parameterizable diagnostics. For details on the diagnostic parameters, see the [article](DiagnostcAddSettings.md).
126126

127-
Ниже приведены отличия в реализации классов диагностик.
127+
Below are the differences in the implementation of diagnostic classes.
128128

129129
### Diagnostics class, implements BSLDiagnostic interface
130130

@@ -300,7 +300,7 @@ Test method example
300300
}
301301
```
302302

303-
### Test of configuration method for parametrized diagnostics
303+
### Test of configuration method for parameterized diagnostics
304304

305305
Тесты для метода конфигурирования должны покрывать все возможные варианты настроек и их комбинаций. Тест имеет практически ту же структуру, что и тест диагностики, за исключение установки параметров диагностики перед получением спсика замечаний.
306306
Перед установкой новых значений параметров диагностики, необходимо получить настройки диагностики по умолчанию методом `getDefaultDiagnosticConfiguration()`, используя информацию текущего объекта диагностики `diagnosticInstance.getInfo()`. Полученный результат представляет собой соответствие, в котором, методом `put`, необходимо изменить значения нужных параметров. Применение измененных настроек выполняется методом `configure()` текущего объекта диагностики `diagnosticInstance`.

docs/en/contributing/EventsApi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class LanguageServerConfigurationChangedEvent extends ApplicationEvent {
4747

4848
Для публикации событий используется аспект `EventPublisherAspect` пакета `com.github._1c_syntax.bsl.languageserver.aop`
4949

50-
> Brief information about acpect-oriented orogramming you can find in page https://www.baeldung.com/aspectj.
50+
> Brief information about aspect-oriented programming you can find in page https://www.baeldung.com/aspectj.
5151
5252
Для перехвата событий в аспекте может быть объявлен advice с перехватом вызовов методов и/или обращений к свойствам объекта. В теле advice должен быть создан объект события и опубликован через [`ApplicationEventPublisher`](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/ApplicationEventPublisher.html).
5353

docs/en/diagnostics/AllFunctionPathMustHaveReturn.md

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,71 @@
11
# All execution paths of a function must have a Return statement (AllFunctionPathMustHaveReturn)
22

3-
| Type | Scope | Severity | Activated<br>by default | Minutes<br>to fix | Tags |
3+
| Type | Scope | Severity | Activated<br>by default | Minutes<br>to fix | Tags |
44
|:------------:|:-------------------:|:--------:|:-----------------------------:|:-----------------------:|:------------------------------------------------------------:|
5-
| `Code smell` | `BSL`<br>`OS` | `Major` | `Yes` | `1` | `unpredictable`<br>`badpractice`<br>`suspicious` |
5+
| `Code smell` | `BSL`<br>`OS` | `Major` | `Yes` | `1` | `unpredictable`<br>`badpractice`<br>`suspicious` |
66

77
## Parameters
88

99

10-
| Name | Type | Description | Default value |
11-
|:--------------------------:|:---------:|:------------------------------------------------------------------------------------------------------------------:|:-------------:|
12-
| `loopsExecutedAtLeastOnce` | `Boolean` | `Assume loops are executed at least once` | `true` |
13-
| `ignoreMissingElseOnExit` | `Boolean` | `Ignore ElIf clauses which has no Else branch. Disable to detect exits from ElIf condition which results to False` | `false` |
10+
| Name | Type | Description | Default value |
11+
|:--------------------------:|:---------:|:-------------------------------------------------------------------------------------------------------------------:|:-------------:|
12+
| `loopsExecutedAtLeastOnce` | `Boolean` | `Assume loops are executed at least once` | `true` |
13+
| `ignoreMissingElseOnExit` | `Boolean` | `Ignore ElIf clauses which has no Else branch. Disable to detect exits from ElIf condition which results to False.` | `false` |
1414
<!-- Блоки выше заполняются автоматически, не трогать -->
1515
## Description
16-
Functions should not have an implicit return. All returned values must be shown excplicitly.
16+
Functions should not have an implicit return. If control reaches the EndFunction line function returns an Undefined value.
17+
18+
As a rule, this is not a normal operation; the programmer must explicitly describe all return values of the function. However, it is quite easy to overlook a situation in which control reaches the EndFunction line and returns an unexpected Undefined value.
19+
20+
This diagnostics checks that all possible paths of the function execution have an explicit Return statement and the function does not return unexpected values.
1721

1822
## Examples
23+
24+
### Incorrect
25+
26+
```bsl
27+
// if the rate is full, but not Tax10 not Tax10 - returns Undefined
28+
// this could be error or planned behavior.
29+
Function DefineTaxRate(Val Rate)
30+
If Rate = Enums.TaxRates.Tax20 Then
31+
Return 20;
32+
ElsIf Rate = Enums.TaxRates.Tax10 Then
33+
Return 10;
34+
ElsIf Not ValueIsFilled(Rate) Then
35+
Return Constants.DefaultTaxRate.Get();
36+
EndIf;
37+
38+
// implicit return Undefined
39+
EndFunction
40+
```
41+
42+
### Correct
43+
44+
```
45+
// explicitly specify the intention to return the result in the end of the function.
46+
Function DefineTaxRate(Val Rate)
47+
If Rate = Enums.TaxRates.Tax20 Then
48+
Return 20;
49+
ElsIf Rate = Enums.TaxRates.Tax10 Then
50+
Return 10;
51+
ElsIf Not ValueIsFilled(Rate) Then
52+
Return Constants.DefaultTaxRate.Get();
53+
EndIf;
54+
55+
// explicit return
56+
Return Undefined;
57+
EndFunction
58+
```
59+
60+
### Another example of incorrect code:
61+
1962
```bsl
20-
Function CalculadeDiscount(ShoppingCart)
21-
If ShoppingCart.Rows.Count() > 10 Then
22-
Return Discounts.DiscountForABigCart(ShoppingCart);
23-
ElIf ShoppingCart.HasLoyaltyCard Then
24-
// Return is missed unintentionally
25-
// causing unexpected return of Undefined
26-
Discounts.DiscountByLoyaltyCard(ShoppingCart);
63+
Function DiscountAmount(Val OrderBasket)
64+
If OrderBasket.Rows.Count() > 10 Then
65+
Return Discounts.DiscountOnBigBasket(OrderBasket);
66+
ElsIf OrderBasket.IsCustomerCard Then
67+
// function returns an unintended value is Undefined
68+
Discounts.DiscountByCustomerCard(OrderBasket);
2769
Else
2870
Return 0;
2971
EndIf;

0 commit comments

Comments
 (0)