diff options
author | Tony Aiuto <aiuto@google.com> | 2023-02-14 00:15:25 -0500 |
---|---|---|
committer | Tony Aiuto <aiuto@google.com> | 2023-02-14 00:15:25 -0500 |
commit | 7fab43b4a46ec75fff051d5cd2726898273aad83 (patch) | |
tree | eb08c10c7edccb9b2821413cde4fb29db53d5a0a | |
parent | 524ead2676e3144d9bfa05d5c971f189a42d2dd4 (diff) | |
download | bazelbuild-rules_license-7fab43b4a46ec75fff051d5cd2726898273aad83.tar.gz |
fix buildifier warnings
-rw-r--r-- | rules/gather_metadata.bzl | 6 | ||||
-rw-r--r-- | rules/sbom.bzl | 25 |
2 files changed, 3 insertions, 28 deletions
diff --git a/rules/gather_metadata.bzl b/rules/gather_metadata.bzl index 9e96cba..4b86403 100644 --- a/rules/gather_metadata.bzl +++ b/rules/gather_metadata.bzl @@ -43,8 +43,8 @@ def _strip_null_repo(label): return s def _bazel_package(label): - l = _strip_null_repo(label) - return l[0:-(len(label.name) + 1)] + clean_label = _strip_null_repo(label) + return clean_label[0:-(len(label.name) + 1)] def _gather_metadata_info_impl(target, ctx): return gather_metadata_info_common(target, ctx, TransitiveMetadataInfo, NAMESPACES, [MetadataInfo, PackageInfo], should_traverse) @@ -251,8 +251,6 @@ def metadata_info_to_json(metadata_info): all_deps = [] for dep in sorted(metadata_info.deps.to_list(), key = lambda x: x.target_under_license): - metadata_used = [] - # Undo the concatenation applied when stored in the provider. dep_licenses = dep.licenses.split(",") all_deps.append(dep_template.format( diff --git a/rules/sbom.bzl b/rules/sbom.bzl index fb17adc..a4af726 100644 --- a/rules/sbom.bzl +++ b/rules/sbom.bzl @@ -32,10 +32,6 @@ def _generate_sbom_impl(ctx): licenses_file = ctx.actions.declare_file("_%s_licenses_info.json" % ctx.label.name) write_metadata_info(ctx, ctx.attr.deps, licenses_file) - license_files = [] - # if ctx.outputs.license_texts: - # license_files = get_licenses_mapping(ctx.attr.deps).keys() - # Now turn the big blob of data into something consumable. inputs = [licenses_file] outputs = [ctx.outputs.out] @@ -106,26 +102,6 @@ def manifest(name, deps, out = None, **kwargs): _manifest(name = name, deps = deps, out = out, **kwargs) -def _licenses_used_impl(ctx): - # Gather all licenses and make it available as JSON - write_metadata_info(ctx, ctx.attr.deps, ctx.outputs.out) - return [DefaultInfo(files = depset([ctx.outputs.out]))] - -_licenses_used = rule( - implementation = _licenses_used_impl, - doc = """Internal tmplementation method for licenses_used().""", - attrs = { - "deps": attr.label_list( - doc = """List of targets to collect LicenseInfo for.""", - aspects = [gather_metadata_info_and_write], - ), - "out": attr.output( - doc = """Output file.""", - mandatory = True, - ), - }, -) - def get_licenses_mapping(deps, warn = False): """Creates list of entries representing all licenses for the deps. @@ -154,6 +130,7 @@ def get_licenses_mapping(deps, warn = False): if type(lic.license_text) == "File": mappings[lic.license_text] = lic.package_name elif warn: + # buildifier: disable=print print("Legacy license %s not included, rule needs updating" % lic.license_text) return mappings |