Skip to content
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

Наценка за сложность #3228

Merged
merged 2 commits into from
Jan 14, 2024
Merged

Conversation

theshadowco
Copy link
Member

@theshadowco theshadowco commented Jan 12, 2024

Описание

  • Реализована возможность указывать наценку за сложность в диагностиках
    • по умолчанию включил для конгнитивной и цикломатической сложностей
  • небольшие исправления

Связанные задачи

Closes #3227

Чеклист

Общие

  • Ветка PR обновлена из develop
  • Отладочные, закомментированные и прочие, не имеющие смысла участки кода удалены
  • Изменения покрыты тестами
  • Обязательные действия перед коммитом выполнены (запускал команду gradlew precommit)

Для диагностик

  • Описание диагностики заполнено для обоих языков (присутствуют файлы для обоих языков, для русского заполнено все подробно, перевод на английский можно опустить)

Дополнительно

Summary by CodeRabbit

  • Новые функции

    • Добавлена возможность увеличения времени на исправление диагностических замечаний в зависимости от сложности.
    • Введена настройка для ограничения диагностического анализа определёнными модулями.
    • Реализована функция указания возможности размещения замечаний на весь проект.
  • Рефакторинг

    • Улучшено использование шаблонов при проверке типов в методе addDiagnostic.
    • Оптимизированы сигнатуры методов для улучшения читаемости кода.
    • Заменён метод Collectors.toUnmodifiableList() на более современный toList().
  • Тесты

    • Добавлены новые утверждения для проверки значений времени на исправление в тестах диагностик.

-- по умолчанию включил для конгнитивной и цикломатической сложностей
- небольшие исправления
Copy link

coderabbitai bot commented Jan 12, 2024

Обзор изменений

Добавлены изменения, позволяющие указывать надбавку за сложность при расчете времени на исправление диагностики. Также произошла рефакторизация кода, включая использование современных возможностей языка, и обновление тестов для поддержки новых изменений.

Изменения

Файлы Сводка изменений
docs/contributing/DiagnosticStructure.md Добавлен новый параметр extraMinForComplexity, список modules и флаг canLocateOnProject.
src/main/java/.../diagnostics/CyclomaticComplexityDiagnostic.java В класс добавлено поле extraMinForComplexity со значением 1.
src/main/java/.../diagnostics/DiagnosticStorage.java Изменен метод addDiagnostic, использовано сопоставление с образцом через instanceof.
src/main/java/.../diagnostics/TransferringParametersBetweenClientAndServerDiagnostic.java Рефакторинг сигнатур методов и замена Collectors.toUnmodifiableList() на toList().
src/main/java/.../metadata/DiagnosticInfo.java Добавлен метод getExtraMinForComplexity().
src/main/java/.../metadata/DiagnosticMetadata.java Добавлена аннотация extraMinForComplexity.
src/test/java/.../CyclomaticComplexityDiagnosticTest.java Добавлена проверка значения extraMinForComplexity.
src/test/java/.../metadata/DiagnosticInfoTest.java Добавлена проверка метода getExtraMinForComplexity().

Оценка соответствия связанным задачам

Задача Учтено Объяснение
#3227: Прогрессивная шкала расчета времени исправления замечания

Стих

О, перемен в коде вихрь,
Рефакторинг в сердце впишем.
Рабочий день короче стал,
Зайчонок-кодер так решил. 🐇💻

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@ghost
Copy link

ghost commented Jan 12, 2024

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 8522790 and 15299b6.
Files selected for processing (9)
  • docs/contributing/DiagnosticStructure.md (2 hunks)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CognitiveComplexityDiagnostic.java (2 hunks)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CyclomaticComplexityDiagnostic.java (1 hunks)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DiagnosticStorage.java (2 hunks)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TransferringParametersBetweenClientAndServerDiagnostic.java (3 hunks)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticInfo.java (1 hunks)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticMetadata.java (1 hunks)
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CyclomaticComplexityDiagnosticTest.java (2 hunks)
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticInfoTest.java (1 hunks)
Additional comments: 12
src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CyclomaticComplexityDiagnosticTest.java (1)
  • 40-40: Добавлена новая проверка для extraMinForComplexity в diagnosticInstance.getInfo(). Это соответствует ожидаемому изменению, учитывая добавление нового параметра в диагностику.
src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticMetadata.java (1)
  • 86-90: Добавлен новый параметр аннотации extraMinForComplexity для указания дополнительного времени на исправление из-за сложности. Это изменение соответствует целям PR.
src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CyclomaticComplexityDiagnostic.java (1)
  • 49-50: Добавлено значение extraMinForComplexity равное 1 в класс CyclomaticComplexityDiagnostic. Это изменение соответствует описанию PR и добавленной аннотации в DiagnosticMetadata.
src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CognitiveComplexityDiagnostic.java (1)
  • 49-50: Добавлено значение extraMinForComplexity равное 1 в класс CognitiveComplexityDiagnostic. Это изменение соответствует добавленной аннотации в DiagnosticMetadata и логике PR.
src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DiagnosticStorage.java (1)
  • 212-215: Использование сопоставления с образцом с instanceof в методе addDiagnostic улучшает читаемость и соответствует современным практикам Java.
src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/TransferringParametersBetweenClientAndServerDiagnostic.java (2)
  • 109-113: Рефакторинг сигнатур методов для размещения параметров на нескольких строках улучшает читаемость кода.

  • 164-164: Замена Collectors.toUnmodifiableList() на toList() соответствует изменениям в Java 16 и улучшает читаемость.

src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticInfo.java (1)
  • 201-206: Добавлен новый метод getExtraMinForComplexity() для получения значения из diagnosticMetadata. Это изменение соответствует добавленной аннотации extraMinForComplexity и логике PR.
src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticInfoTest.java (1)
  • 158-158: Добавлена новая проверка для getExtraMinForComplexity(). Это соответствует изменениям в классе DiagnosticInfo.
docs/contributing/DiagnosticStructure.md (3)
  • 48-48: Добавлен новый параметр extraMinForComplexity в аннотацию @DiagnosticMetadata. Это изменение соответствует описанию PR и позволяет динамически увеличивать время на исправление замечания в зависимости от сложности. Убедитесь, что это изменение также отражено в документации и тестах.

  • 53-54: Добавлены новые свойства modules и canLocateOnProject в аннотацию @DiagnosticMetadata. Эти изменения позволяют ограничить анализ диагностики определенными модулями и указать возможность размещения замечаний на весь проект. Это соответствует описанию PR и предоставляет больше гибкости при определении области применения диагностики.

  • 74-74: Указано значение extraMinForComplexity равное 1 в примере аннотации. Это значение должно быть согласовано с реализацией классов CognitiveComplexityDiagnostic и CyclomaticComplexityDiagnostic, упомянутых в обзоре AI. Убедитесь, что это значение корректно и соответствует логике расчета времени на исправление замечаний.

Copy link

github-actions bot commented Jan 12, 2024

Qodana Community for JVM

17 new problems were found

Inspection name Severity Problems
Statement with empty body 🔶 Warning 5
'@Serial' annotation could be used 🔶 Warning 4
Constant values 🔶 Warning 3
Mismatched query and update of collection 🔶 Warning 2
Class is exposed outside of its visibility scope 🔶 Warning 1
Nullability and data flow problems 🔶 Warning 1
Mismatched read and write of array 🔶 Warning 1

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

@@ -99,28 +100,6 @@ public ParseTree visitSub(BSLParser.SubContext ctx) {
Integer methodComplexity = documentContext.getCognitiveComplexityData().getMethodsComplexity().get(methodSymbol);

if (methodComplexity > complexityThreshold) {

List<DiagnosticRelatedInformation> relatedInformation = new ArrayList<>();
Copy link
Member

Choose a reason for hiding this comment

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

Эээ?

Copy link
Member Author

Choose a reason for hiding this comment

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

если я не туплю, то этот код не работает. См аналогично в цикломатике

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 15299b6 and 9503336.
Files selected for processing (2)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticInfo.java (1 hunks)
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SmokyTest.java (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/metadata/DiagnosticInfo.java
Additional comments: 1
src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/SmokyTest.java (1)
  • 146-153: Добавлен новый тестовый метод testExtraMinForComplexity, который проверяет, что свойство extraMinForComplexity каждого diagnosticInfo не является отрицательным. Это соответствует описанию в PR, где упоминается добавление тестов для новой функциональности. Изменения выглядят корректными.

Copy link

sonarcloud bot commented Jan 13, 2024

@theshadowco theshadowco merged commit 98c2d8e into develop Jan 14, 2024
33 checks passed
@theshadowco theshadowco deleted the feature/extraEnffort branch January 14, 2024 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Прогрессивная шкала расчета времени исправления замечания
2 participants