Skip to content

fix: codecheck simplify column and token validation checks - #329

Merged
chilingling merged 4 commits into
opentiny:developfrom
msslulu:fix/codeql-scanning-codecheck
Sep 24, 2026
Merged

chilingling merged 4 commits into
opentiny:developfrom
msslulu:fix/codeql-scanning-codecheck

Conversation

@msslulu

@msslulu msslulu commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

English | 简体中文

PR

修改DynamicModelService.java 和AiChatServiceImpl.java 的复杂条件判断

主要变更:

  • DynamicModelService
    • 移除 PMD.LongVariable 抑制项。
    • 重命名列类型校验常量。
    • 简化 isValidColumnType 条件判断。
    • isValidColumnType方法上增加空行。
  • AiChatServiceImpl
    • 修复安全字符判断表达式的缩进格式

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Built its own designer, fully self-validated

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Background and solution

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • Refactor
    • Validation checks have been reorganized while preserving the existing rules for accepted column types and safe token characters. No user-visible behavior changes are included in this update.

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 4072230f-d5aa-4d55-9094-cdf19774fffd

📥 Commits

Reviewing files that changed from the base of the PR and between 9d582b1 and 4efc41c.

📒 Files selected for processing (1)
  • base/src/main/java/com/tinyengine/it/dynamic/service/DynamicModelService.java
💤 Files with no reviewable changes (1)
  • base/src/main/java/com/tinyengine/it/dynamic/service/DynamicModelService.java

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


Walkthrough

DynamicModelService moves SQL column type validation into a private helper and defines constants for allowed types. AiChatServiceImpl moves token character validation into a private helper and removes a cyclomatic complexity suppression.

Changes

Dynamic Model Column Validation

Layer / File(s) Summary
Column type validation
base/src/main/java/com/tinyengine/it/dynamic/service/DynamicModelService.java
The service defines constants for allowed SQL column types and the VARCHAR(n) pattern. requireColumnType delegates validation to isValidColumnType, preserving the existing validation rules.

Chat Token Validation

Layer / File(s) Summary
Token character validation
base/src/main/java/com/tinyengine/it/service/app/impl/AiChatServiceImpl.java
isSafeToken delegates character checks to isSafeTokenCharacter, which preserves the existing allowed-character rule. The class-level suppression no longer includes PMD.CyclomaticComplexity.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Suggested reviewers: chilingling

Merge Risk: ⚪ Minimal · up to 4efc4

Merge readiness remains unverified because the changed validation behavior has not been checked against the PR base.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main changes: simplifying column and token validation checks.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks each token’s trail,
And sorts the column types with care.
The helper keeps the old rules true,
While cleaner checks pass through.
Then hops away beneath the moon.

Comment @coderabbitai help to get the list of available commands.

@msslulu msslulu changed the title fix:code check fix: codecheck (simplify column and token validation checks) Sep 23, 2026
@msslulu msslulu changed the title fix: codecheck (simplify column and token validation checks) fix: codecheck -simplify column and token validation checks Sep 23, 2026
@msslulu msslulu changed the title fix: codecheck -simplify column and token validation checks fix: codecheck simplify column and token validation checks Sep 23, 2026

@chilingling chilingling left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

整体没有行为问题,下面的意见都不阻塞合并。

行为等价性:两处拆分后的判断逻辑与原实现一致。

  • isValidColumnType 先判断 null,不会调用到 Set.of(...).contains(null) 而抛出 NPE。
  • String.matches 和 Matcher.matches() 都要求整串匹配,去掉 ^、$ 不改变语义。
  • 正则内容、7 个列类型、token 允许的字符范围都没有变化。

PMD 结果:本地用 PMD 6.55.0 和 pom.xml 中的 rulesets,对比了去掉类级 @SuppressWarnings 之后的扫描结果。

  • isSafeToken 和 requireColumnType 各一条 CyclomaticComplexity(均为 11)已经消除。
  • AiChatServiceImpl 删除 PMD.CyclomaticComplexity 抑制后,没有其他方法触发该规则,这条删除是安全的。
  • DynamicModelService 还有 8 个方法超过圈复杂度阈值,所以它的复杂度类抑制目前还不能删。

Commit:两个 commit 的标题都是 fix:code check,看不出具体改动。建议 squash 合并,并以 PR 标题作为提交信息。

Comment thread base/src/main/java/com/tinyengine/it/dynamic/service/DynamicModelService.java Outdated
Comment thread base/src/main/java/com/tinyengine/it/dynamic/service/DynamicModelService.java Outdated
Comment thread base/src/main/java/com/tinyengine/it/dynamic/service/DynamicModelService.java Outdated
Comment thread base/src/main/java/com/tinyengine/it/service/app/impl/AiChatServiceImpl.java Outdated
@chilingling
chilingling merged commit b06d169 into opentiny:develop Sep 24, 2026
5 checks passed
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