-
Notifications
You must be signed in to change notification settings - Fork 122
Add useless ternary operator diagnostic #1820
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
Closed
EvgSychev
wants to merge
8
commits into
1c-syntax:develop
from
EvgSychev:feature/useless-ternary-operator
Closed
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
732b5ac
Add useless ternary operator diagnostic
EvgSychev f103c75
precommit done
EvgSychev cd8ba4d
suggested changes have been made
EvgSychev 541b137
Update UselessTernaryOperatorDiagnostic.java
EvgSychev 811023a
Update UselessTernaryOperatorDiagnostic.java
EvgSychev 0c78fb2
Apply suggestions from code review
nixel2007 bac62f7
Update src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnos…
nixel2007 44e3d16
Merge branch 'develop' into feature/useless-ternary-operator
EvgSychev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # Бесполезный тернарный оператор (UselessTernaryOperator) | ||
|
|
||
| | Тип | Поддерживаются<br>языки | Важность | Включена<br>по умолчанию | Время на<br>исправление (мин) | Теги | | ||
| |:-------------:|:-----------------------------:|:----------------:|:------------------------------:|:-----------------------------------:|:-----------------------------------:| | ||
| | `Дефект кода` | `BSL` | `Информационный` | `Да` | `1` | `badpractice`<br>`suspicious` | | ||
|
|
||
| <!-- Блоки выше заполняются автоматически, не трогать --> | ||
| ## Описание диагностики | ||
| Размещение в тернарном операторе булевых констант "Истина" или "Ложь" указывает на плохую продуманность кода. | ||
|
|
||
| ## Примеры | ||
| Бессмысленные операторы | ||
|
|
||
| ```Bsl | ||
| А = ?(Истина, 1, 0); | ||
| ``` | ||
| ```Bsl | ||
| А = ?(Б = 1, Истина, Ложь); | ||
| ``` | ||
| ```Bsl | ||
| А = ?(Б = 0, False, True); | ||
| ``` | ||
|
|
||
| Подозрительные операторы | ||
|
|
||
| ```Bsl | ||
| А = ?(Б = 1, True, Истина); | ||
| ``` | ||
| ```Bsl | ||
| А = ?(Б = 0, 0, False); | ||
| ``` | ||
|
|
||
| ## Сниппеты | ||
|
|
||
| <!-- Блоки ниже заполняются автоматически, не трогать --> | ||
| ### Экранирование кода | ||
|
|
||
| ```bsl | ||
| // BSLLS:UselessTernaryOperator-off | ||
| // BSLLS:UselessTernaryOperator-on | ||
| ``` | ||
|
|
||
| ### Параметр конфигурационного файла | ||
|
|
||
| ```json | ||
| "UselessTernaryOperator": false | ||
| ``` |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # Useless ternary operator (UselessTernaryOperator) | ||
|
|
||
| | Type | Scope | Severity | Activated<br>by default | Minutes<br>to fix | Tags | | ||
| |:------------:|:-----:|:--------:|:-----------------------------:|:-----------------------:|:-----------------------------------:| | ||
| | `Code smell` | `BSL` | `Info` | `Yes` | `1` | `badpractice`<br>`suspicious` | | ||
|
|
||
| <!-- Блоки выше заполняются автоматически, не трогать --> | ||
| ## Description | ||
| The placement of Boolean constants "True" or "False" in the ternary operator indicates poor code thoughtfulness. | ||
|
|
||
| ## Examples | ||
| Useless operators | ||
|
|
||
| ```Bsl | ||
| A = ?(True, 1, 0); | ||
| ``` | ||
| ```Bsl | ||
| A = ?(B = 1, True, False); | ||
| ``` | ||
| ```Bsl | ||
| A = ?(B = 0, False, True); | ||
| ``` | ||
|
|
||
| Suspicious operators | ||
|
|
||
| ```Bsl | ||
| A = ?(B = 1, True, True); | ||
| ``` | ||
| ```Bsl | ||
| A = ?(B = 0, 0, False); | ||
| ``` | ||
|
|
||
| ## Snippets | ||
|
|
||
| <!-- Блоки ниже заполняются автоматически, не трогать --> | ||
| ### Diagnostic ignorance in code | ||
|
|
||
| ```bsl | ||
| // BSLLS:UselessTernaryOperator-off | ||
| // BSLLS:UselessTernaryOperator-on | ||
| ``` | ||
|
|
||
| ### Parameter for config | ||
|
|
||
| ```json | ||
| "UselessTernaryOperator": false | ||
| ``` |
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.