- Notifications
You must be signed in to change notification settings - Fork585
Qual: Add pre-commit configuration & ci#4494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Draft
mdeweerd wants to merge23 commits intouncrustify:masterChoose a base branch frommdeweerd:flow/pre-commit
base:master
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Draft
Changes from1 commit
Commits
Show all changes
23 commits Select commitHold shift + click to select a range
2127062
Qual: Setup pre-commit flow
mdeweerd7ec1c60
Qual: Include-what-you-use (add missing includes only)
mdeweerdfa5a635
Qual: remove whitespace after if condition
mdeweerdbce7445
Qual: Include-what-you-use + *_cast<>() + const qualifiers
mdeweerd9a16e7e
Qual: Include-what-you-use + static_cast<>()
mdeweerd5ba5409
Qual: Include-what-you-use + static_cast<>()
mdeweerd95e5df1
build: add missing cstdio include, remove unneeded virtual
mdeweerd14073ed
refactor(language_names): use snprintf for string formatting
mdeweerd6b0d31e
refactor(log_rules): use snprintf for safe string copying
mdeweerd2c9c0bb
refactor: use snprintf instead of strcpy
mdeweerd184250c
refactor(tokenizer): include deque, replace tabs with \t, static_cast
mdeweerdea80534
Qual: output.cpp - include-what-you-use
mdeweerd06ba65f
Qual: output.cpp - static_cast<>()
mdeweerd70c8068
Qual: output.cpp -static_cast<size_t|char>()
mdeweerde0d9438
refactor(uncrustify): use strncpy for buffer copying
mdeweerd3003b2a
ci: update cpplint hook in pre-commit configuration
mdeweerd7ab389d
Qual: output.cpp - static_cast<int>()
mdeweerd925eaeb
Qual: Remove empty line after if for cpplint
mdeweerd43c619a
Qual: Add includes (include-what-you-use)
mdeweerd46c4190
Qual: include-what-you-use, const qualifiers, sizeof()
mdeweerda1263f3
refactor(uncrustify): improve buffer size handling in main function
mdeweerde36b212
refactor(option): update assignment operator to use const reference
mdeweerd7c824d1
refactor(enum_flags): simplify flags constructor and operators
mdeweerdFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
NextNext commit
Qual: Setup pre-commit flow
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commit2127062b83575c0c89ea6413946c93821c33823d
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
name: pre-commit | ||
on: | ||
pull_request: | ||
push: | ||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
env: | ||
RAW_LOG: pre-commit.log | ||
CS_XML: pre-commit.xml | ||
steps: | ||
- run: sudo apt-get update && sudo apt-get install cppcheck uncrustify | ||
- uses: actions/checkout@v4 | ||
- run: python -m pip install pre-commit | ||
- uses: actions/cache/restore@v4 | ||
with: | ||
path: ~/.cache/pre-commit/ | ||
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} | ||
- name: Run pre-commit hooks | ||
env: | ||
SKIP: no-commit-to-branch | ||
run: | | ||
set -o pipefail | ||
pre-commit gc | ||
pre-commit run --show-diff-on-failure --color=always --all-files | tee ${RAW_LOG} | ||
- name: Convert Raw Log to Checkstyle format (launch action) | ||
uses: mdeweerd/logToCheckStyle@v2025.1.1 | ||
if: ${{ failure() }} | ||
with: | ||
in: ${{ env.RAW_LOG }} | ||
# out: ${{ env.CS_XML }} | ||
- uses: actions/cache/save@v4 | ||
if: ${{ ! cancelled() }} | ||
with: | ||
path: ~/.cache/pre-commit/ | ||
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} | ||
- name: Provide log as artifact | ||
uses: actions/upload-artifact@v4 | ||
if: ${{ ! cancelled() }} | ||
with: | ||
name: precommit-logs | ||
path: | | ||
${{ env.RAW_LOG }} | ||
${{ env.CS_XML }} | ||
retention-days: 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
--- | ||
exclude: | ||
(?x)^( | ||
__NONE__)$ | ||
repos: | ||
- repo: https://github.com/executablebooks/mdformat | ||
# Do this before other tools "fixing" the line endings | ||
rev: 0.7.22 | ||
hooks: | ||
- id: mdformat | ||
name: Format Markdown | ||
stages: [manual] | ||
entry: mdformat # Executable to run, with fixed options | ||
language: python | ||
types: [markdown] | ||
args: [--wrap, '75', --number] | ||
additional_dependencies: | ||
- mdformat-toc | ||
- mdformat-gfm | ||
- mdformat-beautysh | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v5.0.0 | ||
hooks: | ||
# - id: no-commit-to-branch | ||
# args: [--branch, main] | ||
- id: debug-statements | ||
- id: end-of-file-fixer | ||
exclude: ^(tests/.*)$ | ||
- id: trailing-whitespace | ||
exclude: ^(tests/.*|.*\.md)$ | ||
- id: check-json | ||
- id: mixed-line-ending | ||
exclude: ^(tests/.*)$ | ||
- id: check-builtin-literals | ||
args: [--ignore=dict] | ||
- id: check-ast | ||
- id: check-merge-conflict | ||
- id: check-executables-have-shebangs | ||
- id: check-shebang-scripts-are-executable | ||
exclude: ^(test/.*)$ | ||
- id: check-docstring-first | ||
- id: fix-byte-order-marker | ||
exclude: ^(tests/.*)$ | ||
- id: check-case-conflict | ||
- id: check-toml | ||
- repo: https://github.com/lovesegfault/beautysh.git | ||
rev: v6.2.1 | ||
hooks: | ||
- id: beautysh | ||
args: [--indent-size=2] | ||
exclude: (?x)^(test/test\..*|config/missing|configure|autogen\.sh)$ | ||
additional_dependencies: | ||
- setuptools | ||
- repo: https://github.com/codespell-project/codespell | ||
rev: v2.4.1 | ||
hooks: | ||
- id: codespell | ||
# scripts/updateCodespellIgnoreFile.sh updates the ignore file. | ||
exclude: (?x)^(emscripten/build\.sh)$ | ||
args: | ||
- --builtin=clear,informal,names | ||
- -xscripts/codespell-lines-ignore.txt | ||
# - --toml | ||
# - pyproject.toml | ||
additional_dependencies: | ||
- tomli | ||
- repo: https://github.com/pocc/pre-commit-hooks | ||
rev: v1.3.5 | ||
# Install dependencies on windows: | ||
# choco install llvm uncrustify cppcheck | ||
hooks: | ||
- id: uncrustify | ||
exclude: ^(tests/.*|documentation/.*)$ | ||
args: [--replace, --no-backup, -c, forUncrustifySources.cfg, -l, CPP] | ||
- id: cppcheck | ||
exclude: ^(tests/.*|documentation/.*)$ | ||
args: | ||
- --force | ||
- --language=c++ | ||
- -Isrc | ||
- '--template={file}({line}): {severity} ({id}): {message}' | ||
- --inline-suppr | ||
- --check-level=exhaustive | ||
- --suppress=constParameterPointer | ||
- --suppress=constVariablePointer | ||
- --suppress=missingInclude:*.h | ||
- --suppress=missingIncludeSystem | ||
- --suppress=noCopyConstructor | ||
- --suppress=noExplicitConstructor | ||
- --suppress=noOperatorEq | ||
- --suppress=unmatchedSuppression | ||
- --suppress=unusedFunction | ||
- --suppress=variableScope | ||
- id: cpplint | ||
exclude: ^(tests/.*|documentation/.*)$ | ||
args: ["--filter=-build/header_guard,-legal/copyright,-whitespace/indent,-whitespace/newline,-whitespace/braces,-whitespace/comments,-whitespace/line_length,-whitespace/parens,-build/include_order,-readability/todo,-readability/fn_size,-build/include_subdir,-runtime/int,-readability/multiline_comment,-build/namespaces,-runtime/references,-runtime/explicit,-runtime/threadsafe_fn"] | ||
additional_dependencies: | ||
- cpplint>=1.6.1 | ||
- repo: https://github.com/shellcheck-py/shellcheck-py | ||
rev: v0.10.0.1 | ||
hooks: | ||
- id: shellcheck | ||
# exclude: (?x)^(__NONE__)$ | ||
# args: [-x,-e1007,-e1009,-e1072,-e1073] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
const UINT aNumber, | ||
// ment is confusing without them. Remember that other people may confuse | ||
: CSuperFoo(something, positionRect, aNumber, | ||
Token* peek( inout Token ct ) | ||
ontext.cend())); | ||
__func__, __LINE__, ontext.c_str(), pc.GetOrigLine()); | ||
__func__, __LINE__, pc->GetOrigLine(), pc->GetOrigCol(), nam->Text(), get_token_name(nam->GetType())); | ||
idx += static_cast<int>(ontext.size()); | ||
nam->SetType(CT_FUNC_TYPE); | ||
nam->SetType(CT_FUNC_VAR); | ||
nam->SetType(CT_PTR_TYPE); | ||
const auto &ontext = options::enable_processing_cmt(); | ||
found_enable_pattern = (pc.GetStr().find(ontext.c_str()) >= 0); | ||
idx = text.find(ontext.c_str(), | ||
if (nam->IsString("^")) | ||
mark_function_return_type(nam, tpo->GetPrevNcNnlNi(), pt); // Issue #2279 | ||
std::wregex criteria(std::wstring(ontext.cbegin(), | ||
// ment is confusing without them. Remember that other people may confuse | ||
Serial.print ( F ( "-- Erreur dans le fonction Centrer_Nombre_Int_dans_Zone : la valeur calculée de X est négative ou nulle, elle vaut :" ) ); | ||
float val_num_prec; // La valeur précédente pour la comparaison | ||
int opApply (int delegate(inout char[]) dg) | ||
int opApply (int delegate(inout char[], inout Object) dg) | ||
* If this is a block literal instead of a block type, 'nam' | ||
"somemore", | ||
Chunk *nam = tpc->GetPrevNcNnlNi(); // name (if any) or '^' Issue #2279 | ||
NOO = 1 | ||
if ( ontext != UNCRUSTIFY_ON_TEXT | ||
if (nam->IsBraceClose()) | ||
Spelling fix: preceeded -> preceded | ||
Token *peek(inout Token ct) | ||
Token* peek(inout Token ct) { | ||
float temp_num_prec; // La valeur précédente pour la comparaison | ||
float val_num_prec; // La valeur précédente pour la comparaison | ||
int humidite_prec; // La valeur précédente pour la comparaison | ||
int opApply(int delegate(inout Type [, ...]) dg); | ||
int opApply(int delegate(inout char[]) dg) | ||
int opApply(int delegate(inout char[], inout Object) dg) | ||
const auto &ontext = options::enable_processing_cmt(); | ||
enum hoo { NOO = 1 }; | ||
if ( !ontext.empty() | ||
if (!ontext.empty()) | ||
{ "inout", CT_QUALIFIER, e_LANG_D }, | ||
"${COMMENT# initialy increase memory for big input files }" \ | ||
* "afile" => "afile" | ||
"4".Clamp(2, 10).ShouldBe(5); | ||
# GNU format (sorta) | ||
(-5).Clamp(2, 10).ShouldBe(5); | ||
5.Clamp("a", 10).ShouldBe(5); | ||
5.Clamp(-5, 10).ShouldBe(5); | ||
5.Clamp(2, 10).ShouldBe(5); | ||
Author: Tim Hütz <tim@huetz.biz> | ||
CFoo::CFoo(const DWORD something, const RECT& positionRect, const UINT aNumber, bool thisIsReadOnly, const CString& windowTitle, CInfo *pStructInfo, int widthOfSomething) : CSuperFoo(something, positionRect, aNumber, | ||
Tim Hütz | ||
UTFT myGLCD ( SSD1963_800 = 1, 38, 39, 40, 41 ); // (byte model, int RS, int WR, int CS, int RST, int SER) | ||
[Donot Add Nl Before Cpp Comment] | ||
[Donot Indent Func Def Close Paren] | ||
enum class option_type_e // <OT> | ||
float _Temp_Ext_Precedente = -99.9; // La valeur précédente pour la comparaison | ||
fonction ( ( &zeze ), ( ss ) ); | ||
fonction (); | ||
int fonction ( ( int *zeze ), ( ss ) ) { ksjbshjdbshjdb = 1;} | ||
int opApply(int delegate(inout Type[, ...]) dg); | ||
jodi.the.tigger@gmail.com | ||
namespace BA | ||
namespace Namepsace |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
# This script updates the codespell ignore file. | ||
# Run it from within the root directory | ||
codespell_ignore_file=$(dirname "$0")/codespell-lines-ignore.txt | ||
echo > "${codespell_ignore_file}" | ||
# When '--git-only' will be available in codespell, use it instead of 'git ls-files' | ||
# shellcheck disable=2046 | ||
codespell --builtin "clear,informal,names" $(git ls-files) \ | ||
| sed -n -E 's@^([^:]+):[[:digit:]]+:[[:space:]](\S+)[[:space:]].*@git grep -hP '\''\\b\2\\b'\'' -- "\1" >> '"${codespell_ignore_file}"'@p' \ | ||
| while read -r line ; do eval "$line" ; done | ||
sort -u "${codespell_ignore_file}" > _tmp.txt ; mv _tmp.txt "${codespell_ignore_file}" |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.