quick_checks.sh 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/env bash
  2. # The analysis tools that need no special build, one result file per tool in <out dir> (default
  3. # ${XDG_CACHE_HOME:-~/.cache}/lwe-analysis/<date>). Runs next to each other and never touches the repos' files; the semgrep, gitleaks,
  4. # osv-scanner and scorecard steps need network access.
  5. #
  6. # tools/analysis/quick_checks.sh [out dir]
  7. set -u
  8. ENGINE=$(cd "$(dirname "$0")/../.." && pwd)
  9. MANAGER=${WE_MANAGER_DIR:-$ENGINE/../we_manager}
  10. OUT=${1:-${XDG_CACHE_HOME:-$HOME/.cache}/lwe-analysis/$(date +%F)}
  11. GLOBAL_MODULES=$(npm root -g)
  12. mkdir -p "$OUT"
  13. run () {
  14. local name=$1
  15. shift
  16. echo "start $name"
  17. "$@" > "$OUT/$name.txt" 2>&1
  18. echo "$? $name" >> "$OUT/exit-codes.txt"
  19. }
  20. : > "$OUT/exit-codes.txt"
  21. cat > "$OUT/eslint.config.mjs" <<CONFIG
  22. import tseslint from '$GLOBAL_MODULES/typescript-eslint/dist/index.js';
  23. export default tseslint.config(...tseslint.configs.strictTypeChecked, {
  24. languageOptions: { parserOptions: { projectService: true, tsconfigRootDir: '$MANAGER' } }
  25. },
  26. { rules: { '@typescript-eslint/restrict-template-expressions': ['error', { allowNumber: true }], '@typescript-eslint/no-unused-vars': ['error', { varsIgnorePattern: '^_', argsIgnorePattern: '^_', ignoreRestSiblings: true }], '@typescript-eslint/no-dynamic-delete': 'off', '@typescript-eslint/no-invalid-void-type': 'off' } },
  27. { files: ['**/*.test.ts', '**/*.test.tsx'], rules: Object.fromEntries(['require-await', 'no-unsafe-return', 'no-unsafe-call', 'no-unsafe-argument', 'no-unsafe-assignment', 'no-unsafe-member-access', 'no-non-null-assertion', 'no-explicit-any', 'no-implied-eval', 'no-unnecessary-type-conversion'].map((r) => ['@typescript-eslint/' + r, 'off'])) });
  28. CONFIG
  29. (
  30. cd "$ENGINE" || exit
  31. run cppcheck cppcheck -j8 --std=c++20 --enable=warning,performance,portability --inconclusive --max-configs=2 \
  32. --suppress=missingIncludeSystem -isrc/External -Isrc src
  33. run gitleaks-engine gitleaks git --redact --no-banner .
  34. run semgrep-engine semgrep scan --metrics=off --config p/default --exclude src/External --exclude 'build*' src tools
  35. run osv-engine osv-scanner scan source -r .
  36. run scorecard-engine scorecard --repo=github.com/WallpaperEngineLover/linux-wallpaperengine-kde
  37. run checksec checksec --file=build/output/linux-wallpaperengine
  38. ) &
  39. (
  40. cd "$MANAGER" || exit
  41. run gitleaks-manager gitleaks git --redact --no-banner .
  42. run semgrep-manager semgrep scan --metrics=off --config p/default --config p/typescript --exclude node_modules --exclude dist --exclude out src
  43. run osv-manager osv-scanner scan source -r .
  44. run typecheck npm run typecheck
  45. run eslint-strict eslint -c "$OUT/eslint.config.mjs" 'src/**/*.{ts,tsx}'
  46. run knip knip --no-progress
  47. run madge-circular madge --circular --extensions ts,tsx --ts-config tsconfig.web.json src
  48. run electronegativity electronegativity -i src
  49. run npm-audit npm audit
  50. ) &
  51. wait
  52. echo done