Add cppcheck and clang-format arc linters
Reviewers: teon.banek Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2670
This commit is contained in:
parent
95c9755e13
commit
bd0fd2619c
12
.arclint
12
.arclint
@ -2,8 +2,20 @@
|
|||||||
"linters": {
|
"linters": {
|
||||||
"clang-tidy": {
|
"clang-tidy": {
|
||||||
"type": "script-and-regex",
|
"type": "script-and-regex",
|
||||||
|
"include": "(\\.(cpp|cc|cxx|c|h|hpp|lcp)$)",
|
||||||
"script-and-regex.script": "./tools/arc-clang-tidy",
|
"script-and-regex.script": "./tools/arc-clang-tidy",
|
||||||
"script-and-regex.regex": "/^(?P<file>.*):(?P<line>\\d+):(?P<char>\\d+): (?P<severity>warning|error): (?P<message>.*)$/m"
|
"script-and-regex.regex": "/^(?P<file>.*):(?P<line>\\d+):(?P<char>\\d+): (?P<severity>warning|error): (?P<message>.*)$/m"
|
||||||
|
},
|
||||||
|
"cppcheck": {
|
||||||
|
"type": "cppcheck",
|
||||||
|
"include": "(\\.(cpp|cc|cxx)$)",
|
||||||
|
"flags": ["--suppress=useStlAlgorithm"]
|
||||||
|
},
|
||||||
|
"clang-format": {
|
||||||
|
"type": "script-and-regex",
|
||||||
|
"include": "(\\.(cpp|cc|cxx|c|h|hpp)$)",
|
||||||
|
"script-and-regex.script": "./tools/arc-clang-format",
|
||||||
|
"script-and-regex.regex": "/^(?P<severity>warning):(?P<offset>\\d+):(?P<message>.*)$/m"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
init
1
init
@ -12,6 +12,7 @@ required_pkgs=(git arcanist # source code control
|
|||||||
uuid-dev # mg-utils
|
uuid-dev # mg-utils
|
||||||
libcurl4-openssl-dev # mg-requests
|
libcurl4-openssl-dev # mg-requests
|
||||||
sbcl # for custom Lisp C++ preprocessing
|
sbcl # for custom Lisp C++ preprocessing
|
||||||
|
php-xml # for arcanist linters
|
||||||
)
|
)
|
||||||
|
|
||||||
optional_pkgs=(doxygen graphviz # source documentation generators
|
optional_pkgs=(doxygen graphviz # source documentation generators
|
||||||
|
19
tools/arc-clang-format
Executable file
19
tools/arc-clang-format
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
# Run this script through arc lint
|
||||||
|
|
||||||
|
MESSAGE = "Wrong formatting!"
|
||||||
|
|
||||||
|
data = subprocess.run(
|
||||||
|
["clang-format", "--output-replacements-xml", sys.argv[1]],
|
||||||
|
stdout=subprocess.PIPE, check=True).stdout.decode(
|
||||||
|
"utf-8").strip().split("\n")
|
||||||
|
for row in data:
|
||||||
|
match = re.match(
|
||||||
|
r"^<replacement offset='([0-9]+)' length='([0-9]+)'>", row)
|
||||||
|
if match:
|
||||||
|
offset = int(match.group(1)) + int(match.group(2))
|
||||||
|
print("warning:{}:{}".format(offset, MESSAGE))
|
Loading…
Reference in New Issue
Block a user