已合并
clang-format、pre-commit与devkit仓一致 #58
哈喽Kiter创建于 7月30日
clang-format、pre-commit与devkit仓一致 #58
已合并
哈喽Kiter创建于 7月30日
共 4 个文件变更+1296-88
@@ -1,96 +1,71 @@
1-Language: Cpp1+# Usage:
2+# Using clang-format to reformat a file:
3+# clang-format -i -style=Google <file>
4+ 
5+BasedOnStyle: Google
6+ColumnLimit: 120
2AccessModifierOffset: -47AccessModifierOffset: -4
3-AlignConsecutiveAssignments: false8+SortIncludes: false
4-AlignConsecutiveDeclarations: false9+BreakBeforeBraces: Custom
5-AlignEscapedNewlines: DontAlign10+ 
11+# 大括号换行配置
12+BraceWrapping:
13+ AfterCaseLabel: false
14+ AfterClass: false
15+ AfterControlStatement: false
16+ # AfterEnum: false (紧凑模式,左大括号和enum同行, enum Color {...), AfterEnum: true (左大括号和enum换行).
17+ AfterEnum: false
18+ AfterFunction: true
19+ AfterNamespace: false
20+ AfterStruct: false
21+ AfterUnion: false
22+ AfterExternBlock: false
23+ BeforeCatch: false
24+ BeforeElse: false
25+ IndentBraces: false
26+ SplitEmptyFunction: false
27+ SplitEmptyRecord: true
28+ SplitEmptyNamespace: true
29+ 
30+# Align
31+AlignAfterOpenBracket: AlwaysBreak
32+AlignEscapedNewlines: Left
6AlignOperands: true33AlignOperands: true
7AlignTrailingComments: true34AlignTrailingComments: true
8AllowAllArgumentsOnNextLine: true35AllowAllArgumentsOnNextLine: true
9-AllowShortLambdasOnASingleLine: Empty36+AllowAllParametersOfDeclarationOnNextLine: true
10-AllowAllParametersOfDeclarationOnNextLine: false37+AlwaysBreakBeforeMultilineStrings: false
38+AlwaysBreakTemplateDeclarations: true
39+AttributeMacros:
40+ - __global__
41+ - __aicore__
42+ - __cube__
43+ - __vector__
44+ - __mix__
45+ - __host__
46+ - __aicpu__
47+ - __simd_vf__
48+ - __simt_vf__
49+ - __gm__
50+ - __ubuf__
51+ - __kfc_workspace__
52+ 
53+BinPackArguments: true
54+BreakBeforeTernaryOperators: false
55+SpacesBeforeTrailingComments: 1
56+ 
57+# poniter aligment
58+DerivePointerAlignment: false
59+PointerAlignment: Left
60+ 
61+# single line layout
11AllowShortBlocksOnASingleLine: false62AllowShortBlocksOnASingleLine: false
12AllowShortCaseLabelsOnASingleLine: false63AllowShortCaseLabelsOnASingleLine: false
13-AllowShortFunctionsOnASingleLine: false64+AllowShortFunctionsOnASingleLine: true
14AllowShortIfStatementsOnASingleLine: false65AllowShortIfStatementsOnASingleLine: false
15AllowShortLoopsOnASingleLine: false66AllowShortLoopsOnASingleLine: false
16-AlwaysBreakAfterDefinitionReturnType: None
17-AlwaysBreakBeforeMultilineStrings: false
18-AlwaysBreakTemplateDeclarations: MultiLine
19-BinPackArguments: true
20-BinPackParameters: true
21-AlignAfterOpenBracket: DontAlign
22 67 
23-BraceWrapping:68+# tab space
24- AfterCaseLabel: false
25- AfterClass: false
26- AfterControlStatement: Never
27- AfterEnum: false
28- AfterFunction: true
29- AfterNamespace: false
30- AfterStruct: false
31- AfterUnion: false
32- AfterExternBlock: false
33- BeforeCatch: false
34- BeforeElse: false
35- IndentBraces: false
36- SplitEmptyFunction: true
37- SplitEmptyRecord: true
38- SplitEmptyNamespace: true
39- 
40-BreakBeforeBinaryOperators: All
41-BreakBeforeBraces: Custom
42-BreakBeforeTernaryOperators: true
43-BreakConstructorInitializersBeforeComma: false
44-BreakInheritanceList: AfterColon
45-ColumnLimit: 120
46-CommentPragmas: '^ IWYU pragma:'
47-PackConstructorInitializers: CurrentLine
48-ConstructorInitializerIndentWidth: 4
49-ContinuationIndentWidth: 4
50-Cpp11BracedListStyle: true
51-DerivePointerAlignment: false
52-DisableFormat: false
53-ExperimentalAutoDetectBinPacking: false
54-ForEachMacros: [ foreach ]
55- 
56-IncludeCategories:
57- - Regex: '^<'
58- Priority: 3
59- - Regex: '^"hccl'
60- Priority: 2
61- - Regex: '.*'
62- Priority: 1
63- 
64-IndentCaseLabels: true
65-IndentWidth: 4
66-IndentWrappedFunctionNames: false
67-KeepEmptyLinesAtTheStartOfBlocks: false
68-MacroBlockBegin: ''
69-MacroBlockEnd: ''
70-MaxEmptyLinesToKeep: 1
71-NamespaceIndentation: Inner
72- 
73-PenaltyBreakBeforeFirstCallParameter: 19
74-PenaltyBreakComment: 300
75-PenaltyBreakFirstLessLess: 120
76-PenaltyBreakString: 1000
77-PenaltyExcessCharacter: 1000000
78-PenaltyReturnTypeOnItsOwnLine: 60
79- 
80-PointerAlignment: Right
81-ReflowComments: true
82-SortIncludes: false
83-SpaceAfterCStyleCast: false
84-SpaceBeforeAssignmentOperators: true
85-SpaceBeforeParens: ControlStatements
86-SpaceInEmptyParentheses: false
87-SpacesBeforeTrailingComments: 1
88-SpacesInAngles: false
89-SpacesInContainerLiterals: true
90-SpacesInCStyleCastParentheses: false
91-SpacesInParentheses: false
92-SpacesInSquareBrackets: false
93-Standard: Latest
94-TabWidth: 4
95UseTab: Never69UseTab: Never
96-UseCRLF: false70+IndentWidth: 4
71+TabWidth: 4
@@ -1,11 +1,68 @@
1+minimum_pre_commit_version: 4.0.0
2+exclude: ^LICENSES/|\.(html|csv|svg|tsv)$
3+ 
4+default_stages: [pre-commit]
5+ci:
6+ autofix_prs: false
7+ autoupdate_schedule: monthly
8+ 
1repos:9repos:
10+ # pre-commit 基础检查
11+ - repo: https://gitcode.com/pre-commit/pre-commit-hooks
12+ rev: v4.6.0
13+ hooks:
14+ - id: trailing-whitespace
15+ exclude: \.md$
16+ - id: end-of-file-fixer
17+ exclude: \.md$
18+ - id: check-yaml
19+ args: ["--allow-multiple-documents"]
20+ - id: check-added-large-files
21+ - id: check-merge-conflict
22+ - id: detect-private-key
23+ - id: check-json
24+ exclude: ^\.devcontainer/devcontainer\.json$
25+ 
26+ # C++ 代码格式化检查
2 - repo: https://gitcode.com/pre-commit-clang/mirrors-clang-format27 - repo: https://gitcode.com/pre-commit-clang/mirrors-clang-format
3 rev: v18.1.828 rev: v18.1.8
4 hooks:29 hooks:
5 - id: clang-format30 - id: clang-format
6- types_or: [c++, c]31+ types_or: [file]
P

devkit exclude这个修改不需要同步过来

likedislike
哈喽Kiter
哈喽Kiter
7月30日 评论:
32+ files: \.(c|h|cpp|hpp|cc|hh|cxx|hxx|asc)$
33+ args:
34+ - "--style=file"
35+ - "--verbose"
36+ - "-i"
7 37 
8- # OAT compliance check (Open Source Audit Tool)38+ # Python 代码检查
39+ - repo: https://gitcode.com/gh_mirrors/ru/ruff-pre-commit
40+ rev: v0.14.14
41+ hooks:
42+ - id: ruff-check
43+ args:
44+ - "--output-format"
45+ - "github"
46+ - "--fix"
47+ - "--extend-ignore"
48+ - "E402,E711,E712,E721,F401,F403,F405,F811,F821,F841,F523,E741,F601"
49+ types: [python]
50+ - id: ruff-format
51+ types: [python]
52+ 
53+ # 拼写检查
54+ - repo: https://gitcode.com/gh_mirrors/co/codespell
55+ rev: v2.4.1
56+ hooks:
57+ - id: codespell
58+ args: [
59+ "-L",
60+ "CANN,cann,NNAL,nnal,ASCEND,ascend,EnQue,CopyIn,ArchType,AND,ND,tbe,copyin,alog,Collet,Enque,Normale,OUTTER,OffsetT,REGIST,Te,ThirdParty,VOR,abl,ans,catched,commiter,devlop,dout,enque,ges,nIn,nd,outter,padd,parm,subtile",
61+ "--skip",
62+ "*.py,*.cpp,*.hpp,*.c,*.h,*.asc,*.cc",
63+ ]
64+ 
65+ # OAT 合规性检查 (Open Source Audit Tool)
9 - repo: local66 - repo: local
10 hooks:67 hooks:
11 - id: oat-check68 - id: oat-check
@@ -16,3 +73,17 @@ repos:
16 types: [file]73 types: [file]
17 stages: [pre-commit]74 stages: [pre-commit]
18 verbose: true75 verbose: true
76+ 
77+ # Markdown 链接有效性检查
78+ - repo: local
79+ hooks:
80+ - id: markdown-link-check
81+ name: Markdown link check
82+ entry: env LYCHEE_VERSION=0.23.0 bash scripts/markdown_link_check.sh
83+ language: system
84+ files: \.(md|markdown|mdx)$
85+ exclude: ^CHANGELOG(_en)?\.md$
86+ pass_filenames: true
87+ always_run: true
88+ stages: [pre-commit, manual]
89+ verbose: true