mirror of
https://github.com/kuhyx/testsAndMisc-archive.git
synced 2026-07-04 17:03:08 +02:00
- Move slow hooks (mypy, pylint, bandit, pytest, prettier) to pre-push stage - Remove redundant autoflake (ruff covers F401/F841) - Fix shellcheck OOM by batching files with xargs -n 40 - Remove tracked .o, .wav, .pyc binaries from git - Move pomodoro wav files to ../testsAndMisc_binaries/ with symlinks - Add *.o, *.so, *.a to .gitignore - Refactor hltb._pick_best_hltb_entry to fix C901/PLR0911/SIM102 - Fix SC2034 warnings in gif_to_square.sh and upgrade.sh - Add disk_cleanup_check.sh script - Various test and code improvements across screen_locker, steam_backlog_enforcer, word_frequency, moviepy_showcase
3.0 KiB
3.0 KiB
C Language Linter Setup for imageViewer Project
This directory contains a comprehensive linting setup for the imageViewer C project.
Tools Included
1. clang-tidy - Static Analysis
- Configuration:
.clang-tidy - Checks for bugs, performance issues, and style violations
- Enforces modern C coding standards
2. clang-format - Code Formatting
- Configuration:
.clang-format - Automatically formats code to consistent style
- 100-character line limit, 4-space indentation
3. cppcheck - Additional Static Analysis
- Detects memory leaks, null pointer dereferences
- Checks for undefined behavior
4. gcc with warnings - Compiler Analysis
- Comprehensive warning flags
- Standards compliance checking
Usage
Quick Start
# Install dependencies (Arch Linux)
make deps-arch
# Run all lint checks
make lint
# Format code
make format
# Run all checks
make check
# Check for memory leaks
make memcheck
Individual Commands
# Manual linting
./lint.sh
# Format specific file
clang-format -i main.c
# Run clang-tidy
clang-tidy main.c -- -I/usr/include/SDL2 -D_REENTRANT
# Run cppcheck
cppcheck --enable=all main.c
VS Code Integration
The .vscode/settings.json file provides:
- Automatic formatting on save
- C99 standard compliance
- IntelliSense configuration for SDL2
- Integrated linting with clang-tidy and cppcheck
Recommended Extensions for VS Code
- C/C++ (Microsoft)
- clang-tidy (mine-cetinkaya-fianso)
- cppcheck (unixwrapped)
Linting Rules
Enabled Checks
- clang-diagnostic-*: Compiler diagnostics
- clang-analyzer-*: Static analysis
- bugprone-*: Bug-prone patterns
- cert-*: CERT secure coding standards
- misc-*: Miscellaneous checks
- performance-*: Performance improvements
- portability-*: Cross-platform issues
- readability-*: Code readability
Disabled Checks
readability-magic-numbers: Allows constants like window dimensionscert-err33-c: Allows ignoring some function return valuesmisc-unused-parameters: Common in callback functions
Code Quality Workflow
- Write Code: Develop features in
main.c - Lint: Run
make lintto check for issues - Format: Run
make formatto fix formatting - Build: Run
maketo compile - Test: Run
make testwith sample images - Memory Check: Run
make memcheckfor leak detection
Configuration Files
.clang-tidy: Static analysis rules.clang-format: Code formatting style.vscode/settings.json: VS Code integrationlint.sh: Comprehensive linting scriptMakefile: Build and quality targets
Installation on Different Systems
Arch Linux
sudo pacman -S clang cppcheck valgrind
Ubuntu/Debian
sudo apt install clang-tidy cppcheck clang-format valgrind
Fedora/RHEL
sudo dnf install clang-tools-extra cppcheck clang valgrind
This setup ensures high code quality, consistency, and helps catch potential issues early in development.