gobject-linter
A fast tree-sitter-based linter for GObject/C code.
Previously known as goblint.
Usage
# Lint current directory with default config
# Lint specific directory
# Use custom config file
# Verbose output
# List all available rules with their enabled/disabled status
# Run only specific rules (overrides config)
# Add custom ignore patterns
Available Rules
Browse all available rules at https://bilelmoussaoui.github.io/gobject-linter/ with descriptions, examples, and configuration options.
Run gobject-linter --list-rules to see the current status of all rules in your terminal.
Configuration
Create a gobject-linter.toml file in your project root to configure rules, set minimum GLib version, and define per-rule ignore patterns.
You can also use inline comments to suppress specific violations:
/* gobject-linter-ignore-next-line: use_g_strlcpy */
;
See CONFIG.md for complete configuration documentation.
CI/CD Integration
Container Image
gobject-linter is available as a container image for easy CI/CD integration:
GitHub Actions
Using the container image with GitHub Code Scanning:
name: GObject Lint
on:
push:
branches:
pull_request:
branches:
jobs:
lint:
runs-on: ubuntu-latest
container:
image: ghcr.io/bilelmoussaoui/gobject-linter:latest
permissions:
security-events: write # Required for uploading SARIF results
steps:
- uses: actions/checkout@v4
- name: Run gobject-linter
run: gobject-linter --format sarif > gobject-linter.sarif
- name: Upload SARIF results
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: gobject-linter.sarif
category: gobject-linter
The results will appear in the "Security" tab under "Code scanning alerts" for your repository, and as inline comments on pull requests.
GitLab CI
Using the container image with GitLab's SARIF ingestion or CodeQuality report:
gobject-linter:
stage: lint
image:
name: "ghcr.io/bilelmoussaoui/gobject-linter:latest"
entrypoint:
script:
# Only available in Enterprise Edition
- gobject-linter --format sarif > gobject-linter.sarif
# Available in the Community Edition
- gobject-linter --format gitlab-codequality > gobject-linter-codequality.json
artifacts:
expire_in: "1 week"
reports:
# Only available in Enterprise Edition
sarif: gobject-linter.sarif
# Available in the Community Edition
codequality: gobject-linter-codequality.json
The results will appear in the merge request's security report and as inline comments.
Diff-scoped reporting
Pass --diff - to restrict violations to lines changed in the current pull request.
This is useful for incremental adoption: existing violations in untouched code are silenced,
and only new or modified lines are checked.
GitHub Actions:
- name: Run gobject-linter (PR changes only)
if: github.event_name == 'pull_request'
run: |
git diff origin/${{ github.base_ref }}...HEAD | gobject-linter --diff -
GitLab CI:
- git diff origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME...HEAD | gobject-linter --diff -
Installation Alternative
If you prefer installing locally instead of using containers:
LSP Server
For real-time linting in your editor:
Neovim (nvim-lspconfig):
require. =
require..
VS Code: Use a generic LSP client extension pointing to gobject-linter-lsp
Helix (~/.config/helix/languages.toml):
[[]]
= "c"
= ["clangd", "gobject-linter-lsp"]
[]
= "gobject-linter-lsp"
Projects using gobject-linter
- fwupd - A system daemon to allow session software to update firmware (workflow)
- xdg-desktop-portal - Desktop integration portal (workflow)
- Crosswords - A Crossword player and editor for GNOME (workflow)
Co-Authored by Claude Code.