summaryrefslogtreecommitdiff
path: root/archived/projt-launcher/ci/code-quality.nix
blob: b5706dc83f7431bfe8e702f3444d5fd59ed6c7ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{
  lib,
  runCommand,
  clang-tools,
  cmake,
  cmake-format,
}:
{
  src ? ../.,
}:

let
  sourceFiles = lib.fileset.toSource {
    root = src;
    fileset = lib.fileset.unions [
      (src + /launcher)
      (src + /tests)
      (src + /buildconfig)
    ];
  };
in
runCommand "projt-code-check"
  {
    nativeBuildInputs = [
      clang-tools
      cmake
      cmake-format
    ];
  }
  ''
    echo "Running ProjT Launcher code quality checks..."

    echo "Checking C++ code formatting..."
    find ${sourceFiles} -type f \( -name "*.cpp" -o -name "*.h" \) | while read file; do
      if ! clang-format --dry-run --Werror "$file" 2>/dev/null; then
        echo "Format error in: $file"
      fi
    done

    echo "Checking for common code issues..."

    todoCount=$(grep -r "TODO\\|FIXME" ${sourceFiles} --include="*.cpp" --include="*.h" 2>/dev/null | wc -l)
    echo "Found $todoCount TODO/FIXME comments"

    if grep -r "qDebug\\|std::cout" ${sourceFiles} --include="*.cpp" 2>/dev/null | grep -v "// DEBUG" > /dev/null; then
      echo "Warning: Debug statements found in code"
    fi

    echo "Code quality check completed!"
    touch $out
  ''