Skip to content

[cr_checker]: Do not silently accept malformed copyright headers #25

Description

@AlexanderLanin

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. The pinned hook configuration is here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions