summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-12-08 21:18:17 +0100
committerDavid Robillard <d@drobilla.net>2019-12-08 21:18:17 +0100
commit681d42a8a8b2fede618bb1073c851d0539fe5c48 (patch)
tree57b0a3faa929ae2a77dc23f03ac875dd5434a68a
parent7859da2568147cc06ea70992a1baed2ceaae619a (diff)
downloadingen-681d42a8a8b2fede618bb1073c851d0539fe5c48.tar.gz
ingen-681d42a8a8b2fede618bb1073c851d0539fe5c48.tar.bz2
ingen-681d42a8a8b2fede618bb1073c851d0539fe5c48.zip
Improve lint target
-rw-r--r--.clang-tidy46
-rw-r--r--wscript51
2 files changed, 81 insertions, 16 deletions
diff --git a/.clang-tidy b/.clang-tidy
new file mode 100644
index 00000000..1580361b
--- /dev/null
+++ b/.clang-tidy
@@ -0,0 +1,46 @@
+Checks: >
+ *,
+ -*avoid-c-arrays,
+ -*magic-numbers,
+ -*non-private-member-variables-in-classes,
+ -*uppercase-literal-suffix,
+ -android-cloexec-fopen,
+ -bugprone-parent-virtual-call,
+ -bugprone-suspicious-string-compare,
+ -cert-dcl50-cpp,
+ -cert-err34-c,
+ -clang-analyzer-alpha.*,
+ -clang-analyzer-valist.Uninitialized,
+ -cppcoreguidelines-macro-usage,
+ -cppcoreguidelines-no-malloc,
+ -cppcoreguidelines-owning-memory,
+ -cppcoreguidelines-pro-bounds-array-to-pointer-decay,
+ -cppcoreguidelines-pro-bounds-constant-array-index,
+ -cppcoreguidelines-pro-bounds-pointer-arithmetic,
+ -cppcoreguidelines-pro-type-const-cast,
+ -cppcoreguidelines-pro-type-cstyle-cast,
+ -cppcoreguidelines-pro-type-member-init,
+ -cppcoreguidelines-pro-type-reinterpret-cast,
+ -cppcoreguidelines-pro-type-static-cast-downcast,
+ -cppcoreguidelines-pro-type-union-access,
+ -cppcoreguidelines-pro-type-vararg,
+ -fuchsia-*,
+ -google-build-using-namespace,
+ -google-default-arguments,
+ -google-readability-casting,
+ -google-readability-todo,
+ -google-runtime-references,
+ -hicpp-multiway-paths-covered,
+ -hicpp-no-array-decay,
+ -hicpp-no-malloc,
+ -hicpp-signed-bitwise,
+ -hicpp-vararg,
+ -llvm-header-guard,
+ -modernize-use-trailing-return-type,
+ -portability-simd-intrinsics,
+ -readability-else-after-return,
+ -readability-implicit-bool-conversion,
+ -readability-named-parameter,
+WarningsAsErrors: ''
+HeaderFilterRegex: 'pugl/.*|test/.*'
+FormatStyle: file
diff --git a/wscript b/wscript
index b27424c6..c23f9316 100644
--- a/wscript
+++ b/wscript
@@ -296,22 +296,41 @@ def lint(ctx):
except Exception:
Logs.warn('warning: Failed to call flake8')
- cmd = ("clang-tidy -p=. -header-filter=ingen/ -checks=\"*," +
- "-clang-analyzer-alpha.*," +
- "-cppcoreguidelines-*," +
- "-cppcoreguidelines-pro-type-union-access," +
- "-google-build-using-namespace," +
- "-google-readability-casting," +
- "-google-readability-todo," +
- "-llvm-header-guard," +
- "-llvm-include-order," +
- "-llvm-namespace-comment," +
- "-misc-unused-parameters," +
- "-readability-else-after-return," +
- "-readability-implicit-bool-cast," +
- "-readability-named-parameter\" " +
- "$(find .. -name '*.cpp')")
- subprocess.call(cmd, cwd='build', shell=True)
+ # Check for C/C++ issues with clang-tidy
+ try:
+ import json
+ import sys
+
+ with open('build/compile_commands.json', 'r') as db:
+ commands = json.load(db)
+ files = [c['file'] for c in commands]
+
+ for step_files in zip(*(iter(files),) * Options.options.jobs):
+ procs = []
+ for f in step_files:
+ out_filename = f.replace('../', '').replace('/', '_') + '.tidy'
+ out_file = open(os.path.join('build', out_filename), 'w+')
+ procs += [(subprocess.Popen(['clang-tidy', '--quiet', f],
+ cwd='build',
+ stdout=out_file,
+ stderr=subprocess.STDOUT),
+ out_file)]
+
+ for proc in procs:
+ proc[0].wait()
+ proc[1].seek(0)
+ for line in proc[1]:
+ sys.stdout.write(line)
+ proc[1].close()
+
+ except Exception as e:
+ Logs.warn('warning: Failed to call clang-tidy (%s)' % e)
+
+ # Check includes with include-what-you-use
+ try:
+ subprocess.call(['iwyu_tool.py', '-o', 'clang', '-p', 'build'])
+ except Exception:
+ Logs.warn('warning: Failed to call iwyu_tool.py')
if status != 0:
ctx.fatal("Lint checks failed")