已关闭
[Feature]: 社区代码静态检查能力增强 #52
hejianping创建于  2月2日关闭于  3月26日
hejianping成员
2月2日 创建

提交提案之前,请先检索仓库内是否已有相同的提案,如已有请在同一提案中进行讨论。

💻 需求背景、当前现状、期望实现的功能内容、具体的设计方案、以及测试方案

目前MindIE系列社区中,缺乏个人级静态检查,需增加pre-commit系列工具,进行静态检查能力增强,工具分析部署如下
image.png

替代方案

补充说明

首期计划部署工具信息如下,后续随着社区能力提升,逐步增强:
` md
repos:

pre-commit 基础检查
repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
id: trailing-whitespace
id: end-of-file-fixer
id: check-yaml
id: check-added-large-files # 拦截>50MB文件(默认阈值)
id: check-merge-conflict # 检测未解决的合并冲突(<<<<<<< HEAD)
id: detect-private-key # 检测硬编码的私钥/密钥
id: check-json
id: no-commit-to-branch # 禁止直接提交到main/master分支
-------------------------- Python 核心检查 --------------------------
Ruff:Python 代码检查+格式化
repo: https://gitcode.com/gh_mirrors/ru/ruff-pre-commit
rev: v0.14.14
hooks:
id: ruff-check
args: [--output-format, github, --fix]
types: [python]
id: ruff-format
types: [python]
codespell:注释/文档拼写检查(忽略项目专有名词)
repo: https://gitcode.com/gh_mirrors/co/codespell
rev: v2.4.1
hooks:
id: codespell
args: [
"-L",
"CANN,cann,NNAL,nnal,ASCEND,ascend,EnQue,CopyIn,ArchType,AND,ND,tbe,copyin,alog",
"--skip",
".py,.cpp,.hpp,.c,*.h", # 仅查文档/注释,跳过代码文件
]
typos:代码标识符拼写检查
repo: https://gitcode.com/gh_mirrors/ty/typos
rev: v1.32.0
hooks:
id: typos
args: ["--force-exclude", "--config", "ci/pre-commit/typos.toml"]
#--------------- C++ 核心检查 ---------------------------------------------

clang-format:C/C++ 代码格式化
repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.8
hooks:
id: clang-format
files: .(c|h|cpp|hpp|cc|hh|cxx|hxx)$
types_or: [c, c++]
args: [--style=google, --verbose, -i]
exclude: ^build/|^tests/third_party/
markdownlint:Markdown 格式检查(仅CI手动执行)
repo: https://gitcode.com/gh_mirrors/ma/markdownlint-cli
rev: v0.46.0
hooks:
id: markdownlint
exclude: '.*.inc.md|.*report_template.md|.*contributors.md|.*PULL_REQUEST_TEMPLATE.md'
stages: [manual]
description: "Markdown format check (run in CI: pre-commit run markdownlint --all-files)"
`

欢迎加入社区,感谢您对社区的贡献 🎉!

likedislike
Hhejianping成员
2月2日 关联了pull request:社区代码静态检查能力增强
ascend-robotascend-robot成员
2月2日 添加了label:feature
Hhejianping成员
2月10日 关联了pull request:[CI]社区代码静态检查能力增强
Hhejianping成员
2月10日 关联了pull request:[CI]社区代码静态检查能力增强
RRobell
3月4日 关联了pull request:[Feature] ????????????(Issue #52)
吴铭泾
吴铭泾成员
3月26日 评论:

收到反馈,感谢!我会尽快查看并回复进展。

likedislike
lijinxilijinxi成员
3月26日 issue状态由 TODO 改变为 DONE
lijinxilijinxi成员
3月26日 关闭了 issue
lijinxilijinxi成员
8月31日 关联了看板:MindIE-SD