Skip to content

Commit b598813

Browse files
committed
refactor with pre-commit
1 parent 2c5da87 commit b598813

13 files changed

+62
-26
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ cpp_linter_hooks.egg-info
44
cpp_linter_hooks/__pycache__/
55
tests/.coverage
66
tests/__pycache__
7-
.coverage
7+
.coverage

.pre-commit-config.yaml

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,39 @@
11
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.3.0
4+
hooks:
5+
- id: trailing-whitespace
6+
exclude: \.output
7+
- id: end-of-file-fixer
8+
exclude: \.(cp?p?$|output)
9+
- id: check-docstring-first
10+
- id: check-added-large-files
11+
- id: check-yaml
12+
- id: debug-statements
13+
- id: requirements-txt-fixer
14+
- repo: https://github.com/asottile/reorder_python_imports
15+
rev: v3.7.0
16+
hooks:
17+
- id: reorder-python-imports
18+
language_version: python3
19+
- repo: https://github.com/asottile/pyupgrade
20+
rev: v1.16.1
21+
hooks:
22+
- id: pyupgrade
23+
- repo: https://github.com/pycqa/flake8
24+
rev: '4.0.1'
25+
hooks:
26+
- id: flake8
27+
args: [--max-line-length=120]
28+
- repo: local
29+
hooks:
30+
- id: tests
31+
name: tests
32+
entry: bash -c "pip install . && pytest -v tests"
33+
description: Run all tests
34+
language: system
35+
types: [python]
36+
237
# Start: for development testing
338
- repo: https://github.com/shenxianpeng/cpp-linter-hooks
439
rev: latest
@@ -12,16 +47,3 @@ repos:
1247
# or specify the path of .clang-tidy
1348
# args: [--config-file=."]
1449
# End: for development testing
15-
- repo: https://github.com/pycqa/flake8
16-
rev: '4.0.1'
17-
hooks:
18-
- id: flake8
19-
args: [--max-line-length=120]
20-
- repo: local
21-
hooks:
22-
- id: tests
23-
name: tests
24-
entry: bash -c "pip install . && pytest -v tests"
25-
description: Run all tests
26-
language: system
27-
types: [python]

.pre-commit-hooks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$
2626
# entry: clang-format -i
2727
# args: ["-style=Google"]
28-
28+
2929
# - id: docker-clang-tidy
3030
# name: clang-tidy
3131
# description: Run `clang-tidy` against C/C++ code to find warnings/errors in Docker container

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repos:
1616
rev: v0.1.0 # Use the ref you want to point at
1717
hooks:
1818
- id: clang-format
19-
args: [--style=Google]
19+
args: [--style=Google]
2020
# - id: clang-tidy ## Work in progress
2121
# args: [--config-file=file]
2222
```

cpp_linter_hooks/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import sys
2-
from cpp_linter_hooks.util import get_expect_version, check_installed
2+
3+
from cpp_linter_hooks.util import check_installed
4+
from cpp_linter_hooks.util import get_expect_version
35

46

57
clang_tools = ['clang-format', 'clang-tidy']

cpp_linter_hooks/clang_format.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import subprocess
2-
from cpp_linter_hooks import args, expect_version
2+
3+
from cpp_linter_hooks import args
4+
from cpp_linter_hooks import expect_version
35

46

57
def run_clang_format(args) -> int:

cpp_linter_hooks/clang_tidy.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import subprocess
2-
from cpp_linter_hooks import args, expect_version
2+
3+
from cpp_linter_hooks import args
4+
from cpp_linter_hooks import expect_version
35

46

57
def run_clang_tidy(args) -> int:

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1+
coverage
12
pytest
2-
coverage

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from setuptools import setup, find_packages
1+
from setuptools import find_packages
2+
from setuptools import setup
23

34
setup(
45
name='cpp_linter_hooks',

testing/compile_flags.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
-Wall
2-
-Werror
2+
-Werror

tests/test_clang_format.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import pytest
21
from unittest.mock import patch
2+
3+
import pytest
4+
35
from cpp_linter_hooks.clang_format import run_clang_format
46

57

tests/test_clang_tidy.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import pytest
21
from unittest.mock import patch
2+
3+
import pytest
4+
35
from cpp_linter_hooks.clang_tidy import run_clang_tidy
46

57

tests/test_util.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
import pytest
21
from unittest.mock import patch
3-
from cpp_linter_hooks.util import check_installed, get_expect_version
2+
3+
import pytest
4+
5+
from cpp_linter_hooks.util import check_installed
6+
from cpp_linter_hooks.util import get_expect_version
47

58

69
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)