Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---

# NOTE:
# The check is a multiline string here. Comment must not be moved into the string.
# Be sure to keep the disabled rules alphabetically sorted.
#
# Checks that are turned off:
#
# -cppcoreguidelines-macro-usage: There are a lot of false-positives like Function-like macro 'Foo' used; consider a 'constexpr' template function
# -cppcoreguidelines-pro-type-reinterpret-cast: Originally turned off.
# -google-readability-todo: Not enforced.
# -google-runtime-references: https://github.com/microsoft/onnxruntime/blob/main/docs/Coding_Conventions_and_Standards.md#c-code-style.
# -modernize-concat-nested-namespaces: We don't use it.
# -modernize-use-trailing-return-type: Stylistic preference we do not enforce.
# -readability-identifier-length: A lot of numerical code rely on short names to improve readability.
# -readability-uppercase-literal-suffix: We accept lowercase suffixes

Checks: >
-*,
cppcoreguidelines-*,
google-*,
readability-*,
modernize-*,
bugprone-*,
performance-*,
misc-*,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-pro-type-reinterpret-cast,
-google-readability-todo,
-google-runtime-references,
-modernize-concat-nested-namespaces,
-modernize-use-trailing-return-type,
-readability-identifier-length,
-readability-uppercase-literal-suffix,
WarningsAsErrors: ""
# HeaderFilterRegex: '.*onnxruntime\/core\/.*'
AnalyzeTemporaryDtors: false
FormatStyle: none
CheckOptions:
- key: google-readability-braces-around-statements.ShortStatementLines
value: "1"
- key: google-readability-function-size.StatementThreshold
value: "800"
- key: google-readability-namespace-comments.ShortNamespaceLines
value: "10"
- key: google-readability-namespace-comments.SpacesBeforeComments
value: "2"
- key: modernize-loop-convert.MaxCopySize
value: "16"
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: google
- key: modernize-replace-auto-ptr.IncludeStyle
value: google
- key: modernize-use-nullptr.NullMacros
value: "NULL"
---
100 changes: 100 additions & 0 deletions .lintrunner.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
merge_base_with = 'origin/main'

[[linter]]
code = 'RUFF'
include_patterns = [
'**/*.py',
'**/*.pyi',
]
exclude_patterns = [
'cmake/**',
'build/**',
'nuget/**',
]
command = [
'python',
'-m',
'lintrunner_adapters',
'run',
'ruff_linter',
'--config=pyproject.toml',
'@{{PATHSFILE}}'
]
init_command = [
'python',
'-m',
'lintrunner_adapters',
'run',
'pip_init',
'--dry-run={{DRYRUN}}',
'--requirement=requirements-lintrunner.txt',
]
is_formatter = true


[[linter]]
code = 'RUFF-FORMAT'
include_patterns = [
'**/*.py',
]
exclude_patterns = [
'cmake/**',
'build/**',
'nuget/**',
]
command = [
'python',
'-m',
'lintrunner_adapters',
'run',
'ruff_format_linter',
'--',
'@{{PATHSFILE}}'
]
init_command = [
'python',
'-m',
'lintrunner_adapters',
'run',
'pip_init',
'--dry-run={{DRYRUN}}',
'--requirement=requirements-lintrunner.txt',
]
is_formatter = true

[[linter]]
code = 'CLANGFORMAT'
include_patterns = [
'**/*.h',
'**/*.cc',
'**/*.hpp',
'**/*.cpp',
'**/*.cuh',
'**/*.cu',
'**/*.m',
'**/*.mm',
]
exclude_patterns = [
'cmake/**',
]
command = [
'python',
'-m',
'lintrunner_adapters',
'run',
'clangformat_linter',
'--binary=clang-format',
'--fallback',
'--',
'@{{PATHSFILE}}'
]
init_command = [
'python',
'-m',
'lintrunner_adapters',
'run',
'pip_init',
'--dry-run={{DRYRUN}}',
'--requirement=requirements-lintrunner.txt',
]
is_formatter = true
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,29 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

### Linting

This project enables [lintrunner](https://github.com/suo/lintrunner) for linting. You can install the dependencies and initialize with

```sh
pip install -r requirements-lintrunner.txt
lintrunner init
```

This will install lintrunner on your system and download all the necessary dependencies to run linters locally.

To format local changes:

```bash
lintrunner -a
```

To format all files:

```bash
lintrunner -a --all-files
```

## Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
Expand Down
Loading
Loading