go-enry / go-license-detector

Reliable project licenses detector.
Other
127 stars 36 forks source link

[Question] Can you scan arbitrary files for licenses in code comments? #35

Open mjz48 opened 9 months ago

mjz48 commented 9 months ago

Hello, I've been experimenting with the v4.3.0 release to scan files in my C++ repository for licenses. I've found many in the readme or license files, but sometimes there are licenses in "header-only" libraries that are at the top of the header file in comments, like so:

#ifndef DATE_H
#define DATE_H

// The MIT License (MIT)
//
// Copyright (c) 2015, 2016, 2017 Howard Hinnant
// Copyright (c) 2016 Adrian Colomitchi
// Copyright (c) 2017 Florian Dang
// Copyright (c) 2017 Paul Thompson
// Copyright (c) 2018, 2019 Tomasz Kamiński
// Copyright (c) 2019 Jiangang Zhuang
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.

Since this is in a file ...external/date/date.h in a separate subdirectory from the README, it doesn't show up in the results.

Is there anything I can do to detect these?

EDIT: I noticed there was one pull request to expose an interface for scanning arbitrary files, but that's a go interface. Is there anything that's already existing for someone using the precompiled executable from a bash script, for instance?

Thanks!