summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2019-10-22 10:40:54 -0600
committermo khan <mo.khan@gmail.com>2019-10-22 12:20:37 -0600
commite265eb6a6c99499254ee959e41ca80c99a8f67ea (patch)
tree93c1f96a9b83154074dcefa74636e8b9ab6f03d3 /lib
parent7f175952a5a047d785b5ea72c15a10642523c62a (diff)
Remove feature flags and temporary mappings
Diffstat (limited to 'lib')
-rw-r--r--lib/license/management/report/v1.rb8
-rw-r--r--lib/license/management/report/v2.rb2
-rw-r--r--lib/license/management/repository.rb20
3 files changed, 9 insertions, 21 deletions
diff --git a/lib/license/management/report/v1.rb b/lib/license/management/report/v1.rb
index 02fd9bd..1cc8728 100644
--- a/lib/license/management/report/v1.rb
+++ b/lib/license/management/report/v1.rb
@@ -14,7 +14,7 @@ module License
private
# when a dependency has multiple licenses, this will join the licenses into a single name
- # this defect was backported from the html2json version of this script.
+ # this defect was backported from the [html2json](https://gitlab.com/gitlab-org/security-products/license-management/blob/7f175952a5a047d785b5ea72c15a10642523c62a/html2json.js) version of this script.
def license_summary
dependencies
.map { |dependency| join_license_names(dependency.licenses) }
@@ -67,17 +67,11 @@ module License
end
def license_data(license)
- return repository.item_for(license, spdx: false) if canonicalize?
-
{
'name' => license.name.split(/[\r\n]+/)[0],
'url' => license.url || ''
}
end
-
- def canonicalize?
- ENV.fetch('LM_V1_CANONICALIZE', 'false') == 'true'
- end
end
end
end
diff --git a/lib/license/management/report/v2.rb b/lib/license/management/report/v2.rb
index 5df6af7..810d191 100644
--- a/lib/license/management/report/v2.rb
+++ b/lib/license/management/report/v2.rb
@@ -26,7 +26,7 @@ module License
end
def data_for(license)
- repository.item_for(license, spdx: true)
+ repository.item_for(license)
end
def map_from(dependency)
diff --git a/lib/license/management/repository.rb b/lib/license/management/repository.rb
index 164653c..0c428dd 100644
--- a/lib/license/management/repository.rb
+++ b/lib/license/management/repository.rb
@@ -14,24 +14,18 @@ module License
@spdx_data = load_spdx_data_from(spdx_path)
end
- def item_for(license, spdx: true)
- if spdx
- item = spdx_data_for(license)
- return item if item
- end
-
- id = id_for(license)
- item = id ? compatibility_data['licenses'][id] : nil
- item ? { 'id' => id }.merge(item) : generate_item_for(license)
+ def item_for(license)
+ spdx_data_for(id_for(license)) ||
+ spdx_data_for(license.send(:short_name)) ||
+ generate_item_for(license)
end
private
attr_reader :spdx_data, :compatibility_data
- def spdx_data_for(license)
- id = id_for(license)
- data = id ? spdx_data[id] : spdx_data[license.send(:short_name)]
+ def spdx_data_for(id)
+ data = spdx_data[id]
if data
{
'id' => data['licenseId'],
@@ -39,7 +33,7 @@ module License
'url' => data['seeAlso'][-1]
}
else
- log_info("could not find license named `#{license.send(:short_name)}` in SPDX index")
+ log_info("Could not find license `#{id}` in SPDX")
nil
end
end