Files
Gleb Chesnokov 74a2e4bac3 scripts: Add the SCST code style linter
Document SCS.1 and expose make scs_lint for the common C source/header
scope, including userspace and KUnit. Adapt engine's OCS.7.5 check to
SCST_KUNIT_VISIBLE, SCST_KUNIT_VISIBLE_INLINE and VISIBLE_IF_KUNIT.
Require each annotation to occupy its own line; leave other function
attributes and source warnings unchanged.

Use Tree-sitter to distinguish code from comments, literals and
preprocessor directive contents while checking every conditional
branch. Pin the parser dependencies and run them through uv.

Support whole-tree, DIFFBR and explicit-file selection without new
exclusions or diagnostic exceptions. Retain findings and checked-file
records even when a later input fails. Add isolated rule, diff-mode,
coverage and read-failure fixtures with a separate test target.
2026-10-20 14:16:08 +03:00

31 lines
1.2 KiB
Markdown

# SCST code style
SCST follows the Linux kernel coding style and [CONTRIBUTING.md](../CONTRIBUTING.md).
This document records additional project layout rules. Rule identifiers are
stable and appear in diagnostics from `make scs_lint`.
## SCS.1: KUnit visibility annotations
Place `SCST_KUNIT_VISIBLE`, `SCST_KUNIT_VISIBLE_INLINE`, or direct
`VISIBLE_IF_KUNIT` on a line of its own before a function declaration or
definition. Do not put a return type, function name or other attribute on that
line. Keep the existing signature and other attributes on the following lines.
```c
SCST_KUNIT_VISIBLE
void scst_example(struct scst_cmd *cmd)
{
}
```
This follows engine's OCS.7.5 layout rule. It does not change visibility,
inlining, linkage or the behavior of KUnit helpers.
`scs_lint` checks all preprocessor branches in the selected project C sources
and headers. Comments, string literals and preprocessor directives (including
macro definitions) are outside this rule. There are no per-file waivers.
Run `make scs_lint` for all tracked project sources,
`make scs_lint DIFFBR=<base>` for changed files, or
`scripts/scs_lint/run_scs_lint.sh path/to/file.c` for explicit files.