coreos / license-bill-of-materials

Fork of https://github.com/pmezard/licenses
MIT License
19 stars 13 forks source link

license-bill-of-materials outputs "The Unlicense" due to reading license.go #16

Open fanminshi opened 6 years ago

fanminshi commented 6 years ago

license-bill-of-materials github.com/go-openapi/spec outputs unlicense:

$ license-bill-of-materials github.com/go-openapi/spec
...
{
  "project": "github.com/go-openapi/spec",
  "licenses": [
    {
      "type": "Apache License 2.0",
      "confidence": 1
    },
    {
      "type": "The Unlicense",
      "confidence": 0.3422459893048128
    }
  ]
}
...

From my understanding, the license-bill-of-materials tool iterates through all files of a given project and determine the license information from any files that has similar name as license.*. Because github.com/go-openapi/spec has a file license.go, license-bill-of-materials evaluates the license.go and determine the project is also unlicense.

The following steps reproduce the above issue.

$ tree $GOPATH/src/unlicense/
├── LICENSE
├── license.go
└── main.go

$ cat unlicense/LICENSE
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.
   ....

$ cat unlicense/license.go
// Copyright 2018 CoreOs Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

$ license-bill-of-materials unlicense
[
    {
        "project": "unlicense",
        "licenses": [
            {
                "type": "Apache License 2.0",
                "confidence": 1
            },
            {
                "type": "The Unlicense",
                "confidence": 0.3488372093023256
            }
        ]
    }
]
fanminshi commented 6 years ago

cc/ @philips