Skip to content

ament_copyright --add-missing does not work with empty files cpp files. #514

@kscottz

Description

@kscottz

I came across a small bug in ament_copyright. If you create an empty source file and then run ament_copyright --add-missing the program does not add any license information.

I am unsure if this behavior is intentional or if the behavior constitutes a bug. If it is the former we may want to document it.

Here is how to reproduce the bug

~/Code/src$ touch new_file.cpp
~/Code/src$ ament_copyright --verbose
new_file.cpp: file empty
test_position.cpp: copyright=Open Source Robotics Foundation, Inc. (2021), license=apache2
No problems found, checked 2 files
~/Code/src$ ament_copyright --add-missing KAT bsd2
~/Code/src$ ament_copyright --verbose
new_file.cpp: file empty
test_position.cpp: copyright=Open Source Robotics Foundation, Inc. (2021), license=apache2
No problems found, checked 2 files
~/Code/src$ emacs new_file.cpp < add void main{} >
~/Code/src$ ament_copyright --add-missing KAT bsd2
* new_file.cpp
~/Code/src$ ament_copyright --verbose
new_file.cpp: copyright=KAT (2024), license=bsd2
test_position.cpp: copyright=Open Source Robotics Foundation, Inc. (2021), license=apache2
No problems found, checked 2 files
~/Code/src$ 

Somewhat related the --list-licenses option is a bit vague. I read the help file information as "this option lists all licenses in the given directory." What the option does is provide a list of available licenses that can be added to unlicensed files. The help file should clarify what the option does a bit more clearly.

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