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

Feature/protected module #3408

Merged
merged 7 commits into from
Feb 10, 2025
Merged

Feature/protected module #3408

merged 7 commits into from
Feb 10, 2025

Conversation

theshadowco
Copy link
Member

Описание

Реализация вместо реквеста #3081

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

Closes: #3076

Чеклист

Общие

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

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

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

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

Copy link
Contributor

coderabbitai bot commented Feb 10, 2025

Warning

Rate limit exceeded

@theshadowco has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 15 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 5448560 and 3c8401f.

📒 Files selected for processing (1)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ProtectedModuleDiagnostic.java (1 hunks)

Walkthrough

В этом пулл-реквесте добавлена документация и новый диагностический механизм для определения защищённых модулей, где отсутствует исходный код из-за паролей. Внесены изменения в документацию на русском и английском языках, создан класс диагностики для BSL Language Server с соответствующей логикой проверки, добавлены свойства локализации для английской и русской версий, а также тесты и тестовые ресурсы для проверки работы нового диагностического инструмента.

Changes

Файлы Изменения
docs/diagnostics/ProtectedModule.md
docs/en/diagnostics/ProtectedModule.md
Добавлены новые файлы и разделы документации с описанием диагностики защищённых модулей (описание, примеры, источники)
src/main/java/.../diagnostics/ProtectedModuleDiagnostic.java Добавлен новый класс ProtectedModuleDiagnostic для диагностики защищённых модулей с реализацией проверки
src/main/resources/.../ProtectedModuleDiagnostic_en.properties
src/main/resources/.../ProtectedModuleDiagnostic_ru.properties
Добавлены новые диагностические сообщения и названия для локализаций на английском и русском языках
src/test/java/.../ProtectedModuleDiagnosticTest.java
src/test/resources/diagnostics/ProtectedModuleDiagnostic.bsl
Добавлены тестовый класс и тестовый ресурс для проверки работы диагностики защищённых модулей

Sequence Diagram(s)

sequenceDiagram
    participant LS as Language Server
    participant PM as ProtectedModuleDiagnostic
    participant MO as ModuleOwner
    participant DS as Diagnostic Storage

    LS->>PM: Вызов метода check()
    alt Отсутствует конфигурация или диапазон модуля пуст
        PM-->>LS: Досрочный возврат
    else Диапазон модуля валиден
        PM->>MO: Итерация по владельцам модуля
        alt Найден защищённый модуль
            PM->>DS: Добавление диагностики (addDiagnostic)
        end
        PM-->>LS: Возврат списка диагностик
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Диагностика отсутствия исходного кода в защищённых модулях (#3076)

Suggested reviewers

  • nixel2007

Poem

Я кролик, с прыжком по строкам бегу,
В коде обнаружил укрытый секрет,
Защищён модуль — вот диагноз во славу,
Исправлю, проверю — всё работает, как свет.
Пусть баги исчезают, как в сказке мгновенно,
Код радует глаз, пусть будет он без будней!
🐰✨


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>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 testing code 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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.

Actionable comments posted: 3

🧹 Nitpick comments (2)
src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ProtectedModuleDiagnosticTest.java (1)

42-42: Рекомендуется использовать константы для путей к тестовым ресурсам

Путь к метаданным захардкожен. Лучше вынести его в общие константы тестового окружения.

src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ProtectedModuleDiagnostic.java (1)

73-83: Оптимизировать stream операции

Текущая реализация stream можно упростить:

-    configuration.getChildren().stream()
-      .filter(md -> md instanceof ModuleOwner)
-      .map(md -> (ModuleOwner) md)
-      .forEach((ModuleOwner moduleOwner) -> {
-        var hasProtected = moduleOwner.getModules().stream()
-          .filter(Module::isProtected)
-          .findAny();
-        if (hasProtected.isPresent()) {
-          addDiagnostic(moduleOwner);
-        }
-      });
+    configuration.getChildren().stream()
+      .filter(md -> md instanceof ModuleOwner)
+      .map(md -> (ModuleOwner) md)
+      .filter(moduleOwner -> moduleOwner.getModules().stream()
+        .anyMatch(Module::isProtected))
+      .forEach(this::addDiagnostic);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 10bc695 and e534232.

⛔ Files ignored due to path filters (3)
  • src/main/resources/com/github/_1c_syntax/bsl/languageserver/configuration/parameters-schema.json is excluded by !**/*.json
  • src/main/resources/com/github/_1c_syntax/bsl/languageserver/configuration/schema.json is excluded by !**/*.json
  • src/test/resources/metadata/subSystemFilter/CommonModules/ОбщийМодуль1/Ext/Module.bin is excluded by !**/*.bin, !**/*.bin
📒 Files selected for processing (7)
  • docs/diagnostics/ProtectedModule.md (1 hunks)
  • docs/en/diagnostics/ProtectedModule.md (1 hunks)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ProtectedModuleDiagnostic.java (1 hunks)
  • src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/ProtectedModuleDiagnostic_en.properties (1 hunks)
  • src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/ProtectedModuleDiagnostic_ru.properties (1 hunks)
  • src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/ProtectedModuleDiagnosticTest.java (1 hunks)
  • src/test/resources/diagnostics/ProtectedModuleDiagnostic.bsl (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • src/test/resources/diagnostics/ProtectedModuleDiagnostic.bsl
  • src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/ProtectedModuleDiagnostic_ru.properties
  • docs/en/diagnostics/ProtectedModule.md
🔇 Additional comments (3)
src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/ProtectedModuleDiagnostic_en.properties (1)

1-2: Перевод соответствует требованиям

Несмотря на то, что согласно целям PR английский перевод можно пропустить, предоставленный перевод корректен и понятен.

docs/diagnostics/ProtectedModule.md (2)

9-11: Необходимо добавить примеры

Раздел примеров пуст. Следует добавить:

  • Пример кода с защищенным модулем
  • Рекомендации по исправлению ситуации
  • Возможные альтернативные решения

12-18: Дополнить раздел источников

Необходимо указать источники информации, на основе которых была создана диагностика. Например:

  • Стандарты разработки 1С
  • Документация по безопасности
  • Лучшие практики по управлению исходным кодом

Copy link
Contributor

@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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/main/java/com/github/_1c_syntax/bsl/languageserver/context/ServerContext.java (1)

265-268: Улучшение контракта метода с помощью @nonnull

Добавление аннотации @nonnull явно указывает, что метод getConfiguration() никогда не вернет null. Это улучшает безопасность типов и помогает предотвратить NullPointerException.

Рекомендуется также добавить документацию JavaDoc для метода getConfiguration(), описывающую его контракт и гарантии возвращаемого значения.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e534232 and 5448560.

📒 Files selected for processing (1)
  • src/main/java/com/github/_1c_syntax/bsl/languageserver/context/ServerContext.java (2 hunks)
🔇 Additional comments (1)
src/main/java/com/github/_1c_syntax/bsl/languageserver/context/ServerContext.java (1)

36-36: LGTM!

Добавление импорта lombok.NonNull необходимо для поддержки аннотации @nonnull.

Copy link

github-actions bot commented Feb 10, 2025

Qodana for JVM

78 new problems were found

Inspection name Severity Problems
Field may be 'final' 🔶 Warning 55
Lombok @Getter may be used 🔶 Warning 11
@NotNull/@Nullable problems 🔶 Warning 5
Stream API call chain can be simplified 🔶 Warning 5
Non recommended 'field' injections ◽️ Notice 2

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

Detected 103 dependencies

Third-party software list

This page lists the third-party software dependencies used in bsl-language-server

Dependency Version Licenses
aho-corasick-double-array-trie 1.2.2 Apache-2.0
aspectjrt 1.9.22.1 Apache-2.0
checker-qual 3.43.0 MIT
classgraph 4.8.179 MIT
commons-beanutils 1.9.4 Apache-2.0
commons-collections 3.2.2 Apache-2.0
commons-collections4 4.4 Apache-2.0
commons-digester 2.1 Apache-2.0
commons-exec 1.4.0 Apache-2.0
commons-io 2.17.0 Apache-2.0
commons-lang3 3.17.0 Apache-2.0
commons-logging 1.2 Apache-2.0
commons-pool2 2.12.0 Apache-2.0
commons-text 1.10.0 Apache-2.0
commons-validator 1.7 Apache-2.0
error_prone_annotations 2.28.0 Apache-2.0
grpc-netty-shaded 1.66.0 Apache-2.0
gson 2.11.0 Apache-2.0
guava 33.3.1-jre Apache-2.0
hunspell 2.1.2 Apache-2.0
istack-commons-runtime 4.1.2 BSD-3-Clause
j2objc-annotations 3.0.0 Apache-2.0
jackson-annotations 2.18.2 Apache-2.0
jackson-core 2.18.2 Apache-2.0
jackson-databind 2.18.2 Apache-2.0
jackson-datatype-jdk8 2.18.2 Apache-2.0
jackson-datatype-jsr310 2.18.2 Apache-2.0
jackson-module-parameter-names 2.18.2 Apache-2.0
jakarta.activation-api 2.1.3 BSD-3-Clause
jakarta.annotation-api 2.1.1 Classpath-exception-2.0
EPL-2.0
GPL-2.0-only
jakarta.websocket-api 2.1.1 Classpath-exception-2.0
EPL-2.0
GPL-2.0-only
jakarta.xml.bind-api 4.0.2 BSD-3-Clause
java-diff-utils 4.12 Apache-2.0
java-sarif 2.0 MIT
javax.activation-api 1.2.0 CDDL-1.1
GPL-2.0-only
javax.annotation-api 1.3.2 CDDL-1.0
GPL-2.0-only
ORACLE-OPENJDK-EXCEPTION-2.0
jaxb-api 2.3.0 CDDL-1.1
GPL-2.0-only
ORACLE-OPENJDK-EXCEPTION-2.0
jaxb-core 4.0.5 BSD-3-Clause
jaxb-runtime 4.0.5 BSD-3-Clause
jgrapht-core 1.5.2 EPL-1.0
LGPL-2.0-or-later
jline-native 3.24.1 BSD-3-Clause
jline-terminal 3.24.1 BSD-3-Clause
jna-platform 5.12.1 Apache-2.0
jna 5.12.1 Apache-2.0
jsr305 3.0.2 Apache-2.0
jul-to-slf4j 2.0.16 MIT
language-detector 0.6 Apache-2.0
language-en 6.5 LGPL-2.0-or-later
language-ru 6.5 LGPL-2.0-or-later
languagetool-core 6.5 LGPL-2.0-or-later
log4j-api 2.24.3 Apache-2.0
log4j-to-slf4j 2.24.3 Apache-2.0
lombok 1.18.36 BSD-3-CLAUSE-NO-TRADEMARK
MIT
lucene-backward-codecs 5.5.5 Apache-2.0
lucene-core 5.5.5 Apache-2.0
micrometer-commons 1.14.3 Apache-2.0
micrometer-core 1.14.3 Apache-2.0
micrometer-observation 1.14.3 Apache-2.0
micrometer-registry-prometheus 1.14.3 Apache-2.0
mxparser 1.2.2 xpp
opennlp-chunk-models 1.5 Apache-2.0
opennlp-postag-models 1.5 Apache-2.0
opennlp-tokenize-models 1.5 Apache-2.0
opennlp-tools 1.9.4 Apache-2.0
openregex 1.1.1 LGPL-2.0-or-later
org.abego.treelayout.core 1.0.3 BSD-3-Clause
progressbar 0.10.1 MIT
proto-google-common-protos 2.41.0 Apache-2.0
segment 2.0.1 MIT
simpleclient 0.16.0 Apache-2.0
simpleclient_guava 0.16.0 Apache-2.0
simpleclient_tracer_common 0.16.0 Apache-2.0
simpleclient_tracer_otel 0.16.0 Apache-2.0
simpleclient_tracer_otel_agent 0.16.0 Apache-2.0
slf4j-api 2.0.16 MIT
snakeyaml 2.3 Apache-2.0
spring-aop 6.2.2 Apache-2.0
spring-beans 6.2.2 Apache-2.0
spring-boot-autoconfigure 3.4.2 Apache-2.0
spring-boot-starter-cache 3.4.2 Apache-2.0
spring-boot-starter-json 3.4.2 Apache-2.0
spring-boot-starter-logging 3.4.2 Apache-2.0
spring-boot-starter-tomcat 3.4.2 Apache-2.0
spring-boot-starter-web 3.4.2 Apache-2.0
spring-boot-starter-websocket 3.4.2 Apache-2.0
spring-boot-starter 3.4.2 Apache-2.0
spring-boot 3.4.2 Apache-2.0
spring-context-support 6.2.2 Apache-2.0
spring-context 6.2.2 Apache-2.0
spring-core 6.2.2 Apache-2.0
spring-expression 6.2.2 Apache-2.0
spring-jcl 6.2.2 Apache-2.0
spring-messaging 6.2.2 Apache-2.0
spring-web 6.2.2 Apache-2.0
spring-webmvc 6.2.2 Apache-2.0
spring-websocket 6.2.2 Apache-2.0
st4 4.3.4 BSD-3-Clause
tomcat-embed-core 10.1.34 Apache-2.0
CDDL-1.0
PROPRIETARY-LICENSE
tomcat-embed-el 10.1.34 Apache-2.0
tomcat-embed-websocket 10.1.34 Apache-2.0
txw2 4.0.5 BSD-3-Clause
vavr-match 0.10.2 Apache-2.0
vavr 0.10.2 Apache-2.0
Contact Qodana team

Contact us at [email protected]

@theshadowco theshadowco merged commit 432bbc7 into develop Feb 10, 2025
41 checks passed
@theshadowco theshadowco deleted the feature/ProtectedModule branch February 10, 2025 17:57
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.

[NEW] На модуль установлена защита через пароль
3 participants