eclipse-score / eclipse-score/tools
[cr_checker]: Do not silently accept malformed copyright headers
- Dominant language
- Python
- Stars
- 1
- Forks
- 5
- Avg merge
- 13h 22m
- Merged PRs (30d)
- 23
Description
### Bug description
cr_checker does not consistently handle copyright headers that are present but do not match the configured template.
When a file contains a copyright header with different wording, for example `Apache License 2.0` or `Apache License, Version 2.0` instead of the configured `Apache License Version 2.0`, the checker detects that the exact template does not match. It then detects that some copyright header is present, prints a warning, and leaves the file unchanged. The result is still reported as successful.
This is especially confusing when using the pre-commit hook, whose entry point is `cr_checker/tool/cr_checker.py --fix`: the hook name says “Check and fix”, but existing malformed headers are not fixed.
### Expected behavior
A malformed existing header should either:
- be replaced with the configured canonical template when `--fix` is used, or
- cause a non-zero exit status with a clear error when it is not fixed.
The behavior should also be documented if normalization is intentionally not supported.
### Reproduction
1. Configure the standard copyright template.
2. Put a header containing `Apache License 2.0` in a BUILD file.
3. Run cr_checker with `--fix`.
4. Observe that the header is unchanged and the command succeeds.
The behavior was observed through the copyright pre-commit hook in [eclipse-score/docs-as-code#784](https://github.com/eclipse-score/docs-as-code/pull/784). The pinned hook configuration is [here](https://github.com/eclipse-score/docs-as-code/blob/a492b2004c1497e298d1591c69b2c424b66057f8/.pre-commit-config.yaml#L84-L89).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.