xref: /aosp_15_r20/build/bazel/rules/java/errorprone/errorprone.bzl (revision 7594170e27e0732bc44b93d1440d87a54b6ffe7c)
1# Copyright (C) 2023 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http:#www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15load("@soong_injection//java_toolchain:constants.bzl", "constants")
16load(":errorprone_flags.bzl", "errorprone_soong_bazel_diffs")
17
18def _process_exported_list(lst):
19    # empty lists get exported from Soong to Bazel as an empty string ""
20    # this is a work around to prevent type errors
21    if type(lst) == type("str"):
22        return []
23    return lst
24
25def _soong_default_errorprone_checks():
26    res = []
27    res += _process_exported_list(constants.ErrorProneChecksError)
28    res += _process_exported_list(constants.ErrorProneChecksWarning)
29    res += _process_exported_list(constants.ErrorProneChecksDefaultDisabled)
30    res += _process_exported_list(constants.ErrorProneChecksOff)
31    return res
32
33errorprone_global_flags = errorprone_soong_bazel_diffs + _soong_default_errorprone_checks()
34