Skip to content

Go-powered C code style checker — Detects and reports formatting, naming, and brace style issues in C/C++ code using regex-based parsing and tokenization. Supports K&R and Allman styles, JSON export, and CI integration.

License

Notifications You must be signed in to change notification settings

RafaelVVolkmer/CodeStyleChecker

Repository files navigation

Contributors Forks Stargazers Issues ULicense LinkedIn

libmemalloc logo

by: Rafael V. Volkmer - @RafaelVVolkmer - rafael.v.volkmer@gmail.com

- Project Description

CodeStyleChecker is a lightweight, Go-powered style checker focused on C source files and headers. It parses files and flags spacing, brace style, naming, and other formatting violations against K&R and Allman conventions, emitting machine-readable reports for automated pipelines. The repo includes a simple checker.sh CLI wrapper with verbose and JSON-report modes so you can either print human-friendly findings or dump pretty, per-error JSON artifacts (saved under ./out/ with timestamped filenames). The core checker lives in src/ (Go ~96%) with a small shell glue layer, and the tree ships with a GitHub Actions workflow so the checks can run on every push/PR. In short: point it at a file or directory, select your style, and get consistent, automatable feedback you can wire into CI without external dependencies.

(back to top)


- CLI UI View

libmemalloc logo


The command-line interface presents style analysis results in a structured, readable format. Each reported issue begins with an incremental number and a severity label — either ERROR or WARNING — shown in uppercase and color-coded, with errors underlined in red and warnings in yellow.

Directly below, the tool displays the file name, followed by its line and column in file.c:line:column format. The surrounding code is shown with line numbers on the left, a vertical separator, and the relevant token or symbol highlighted for quick identification.

Messages describe the specific rule violation, such as missing newlines, uninitialized variables, or incorrect indentation, with details about the expected format (e.g., “found 2 spaces, expected 4”).

At the end of the run, a summary line reports the total number of errors and warnings found, using consistent color cues to match the severities above. This approach makes it possible to quickly locate and address each issue without having to parse large amounts of plain text output.

(Back to Top)


- Repository tree

/libmemalloc
├── /src
│   └── check_style.go
├── /readme
│    └── c_style_checker.svg
├── Dockerfile
├── .dockerignore
├── checker.sh
├── .gitattributes
├── .gitignore
├── LICENSE
└── README.md

(Back to Top)


- Build and Use

Clone the repository

git clone https://github.com/RafaelVVolkmer/CodeStyleChecker.git CodeStyleChecker
cd CodeStyleChecker

Local build

# Make the checker script executable
chmod +x checker.sh

# Build the Go binary (done automatically when running checker.sh)
./checker.sh -r allman main.c

# Or rebuild only without running checks
./checker.sh --rebuild-only

Local Use

# Show help message and exit
./checker.sh -h
./checker.sh --help

# Enable verbose output for more build/check details
./checker.sh -v allman main.c
./checker.sh --verbose kr src/

# Run the checker and output results as pretty JSON
./checker.sh -j allman main.c
./checker.sh --json kr src/

Docker Use

# The script will automatically build the Docker image and mount the necessary volumes
./checker.sh --docker allman main.c          # normal output
./checker.sh --docker -j kr src/             # writes JSON to ./out

(Back to Top)


- Tech Stack and Environment Settings

Category Technologies and Tools
Programming Languages Go
Build System CMake
Version Control Git GitHub
Documentation Markdown
Support Tools Docker
Operating System Ubuntu
IDE Neovim

(Back to Top)


Title Author / Year
Introducing Go: Build Reliable, Scalable Programs by: Caleb Doxsey, 2016
Mastering Regular Expressions by: Jeffrey E. F. Friedl, 2006
Lex & Yacc by: John R. Levine, Tony Mason, Doug Brown, 1992
The Go Programming Language by: Alan A. A. Donovan, Brian W. Kernighan, 2015
Building Tools with Go: Writing linters, formatters, and code analysis tools by: John Arundel, 2021
Compilers: Principles, Techniques, and Tools (2nd Edition) by: Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey D. Ullman, 2006
Writing An Interpreter In Go by: Thorsten Ball, 2017
Go AST Package Documentation (golang.org/pkg/go/ast) Go Authors, ongoing

(back to top)

About

Go-powered C code style checker — Detects and reports formatting, naming, and brace style issues in C/C++ code using regex-based parsing and tokenization. Supports K&R and Allman styles, JSON export, and CI integration.

Resources

License

Stars

Watchers

Forks

Releases

No releases published