Problem
Currently, license header detection is tied to the configured comment style.
For example, a repository may configure Rust files (.rs) to use a line-by-line header style:
[mapping.DOUBLESLASH_STYLE]
extensions = ["rs"]
while existing files still contain a block-style header:
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.
*/
In this case:
- hawkeye check reports the file as missing a license header because the existing header does not match the configured style.
- hawkeye format inserts a new //-style header at the beginning of the file.
- The original block-style header remains in place.
As a result, the file ends up containing two license headers.
Expected Behavior
Before inserting a new header during auto-fix, Hawkeye could attempt to detect and remove an existing license header that is semantically valid but does not match the configured comment style.
Example:
Before:
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.
*/
fn main() {}
After:
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.
fn main() {}
instead of:
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.
*/
fn main() {}
Benefits
- Avoids duplicate license headers.
- Makes style migrations easier.
- Produces cleaner auto-fix results.
- Reduces manual cleanup after running hawkeye format.
Problem
Currently, license header detection is tied to the configured comment style.
For example, a repository may configure Rust files (.rs) to use a line-by-line header style:
while existing files still contain a block-style header:
In this case:
As a result, the file ends up containing two license headers.
Expected Behavior
Before inserting a new header during auto-fix, Hawkeye could attempt to detect and remove an existing license header that is semantically valid but does not match the configured comment style.
Example:
Before:
After:
instead of:
Benefits