Skip to content

Commit

Permalink
Merge pull request jsk-ros-pkg#566 from Li-Jinjie/only_add_pre-commit
Browse files Browse the repository at this point in the history
[Code Style] [merge after jsk-ros-pkg#565] add pre-commit tool
  • Loading branch information
tongtybj authored Oct 28, 2023
2 parents a46a459 + 9e15222 commit 6d28485
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 1 deletion.
63 changes: 63 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
BasedOnStyle: Google
AccessModifierOffset: -2
ConstructorInitializerIndentWidth: 2
AlignEscapedNewlinesLeft: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AlwaysBreakTemplateDeclarations: true
AlwaysBreakBeforeMultilineStrings: true
BreakBeforeBinaryOperators: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: true
BinPackParameters: true
ColumnLimit: 120
ConstructorInitializerAllOnOneLineOrOnePerLine: true
DerivePointerBinding: false
PointerBindsToType: true
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: true
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 60
PenaltyBreakString: 1
PenaltyBreakFirstLessLess: 1000
PenaltyExcessCharacter: 1000
PenaltyReturnTypeOnItsOwnLine: 90
SpacesBeforeTrailingComments: 2
Cpp11BracedListStyle: false
Standard: Auto
IndentWidth: 2
TabWidth: 2
UseTab: Never
IndentFunctionDeclarationAfterType: false
SpacesInParentheses: false
SpacesInAngles: false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpaceAfterControlStatementKeyword: true
SpaceBeforeAssignmentOperators: true
ContinuationIndentWidth: 4
SortIncludes: false
SpaceAfterCStyleCast: false

# Configure each individual brace in BraceWrapping
BreakBeforeBraces: Custom

# Control of individual brace wrapping cases
BraceWrapping:
AfterClass: true
AfterControlStatement: 'true'
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
32 changes: 32 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: check-xml
- id: check-json
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-added-large-files

# Python
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
language: python
args: [--line-length=120]

# C++
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.3
hooks:
- id: clang-format

# # YAML - still bad support for comments in YAML files
# - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
# rev: 0.2.1 # or other specific tag
# hooks:
# - id: yamlfmt
# args: [--mapping, '2', --sequence, '4', --offset, '2', --width, '120']
2 changes: 1 addition & 1 deletion docs/how_to_contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ Pre-commit, the format plugin, will run automatically before each commit. The sp
.pre-commit-config.yaml. To activate this plugin, please run the following command in terminal and root directory:

```bash
pip install pre-commit
pip3 install pre-commit
pre-commit install
```

0 comments on commit 6d28485

Please sign in to comment.