From 1cdf802d8ed524bb4d71c60e8654a9825c89ee75 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Thu, 17 Oct 2024 15:32:15 -0700 Subject: [PATCH] Enable native-* rules With bazel 8.x these should now be loaded externally. It's currently only a soft requirement, but at this point all users should start migrating to this. --- WARNINGS.md | 5 ----- buildifier/config/config_test.go | 24 ++++++++++++------------ warn/warn.go | 5 ----- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/WARNINGS.md b/WARNINGS.md index 5ee0af111..bb0593e5e 100644 --- a/WARNINGS.md +++ b/WARNINGS.md @@ -657,7 +657,6 @@ UPPER_SNAKE_CASE, and providers should be UpperCamelCase ending with `Info`. * Category name: `native-android` * Flag in Bazel: [`--incompatible_disable_native_android_rules`](https://github.com/bazelbuild/bazel/issues/8391) * Automatic fix: yes - * [Disabled by default](buildifier/README.md#linter) * [Suppress the warning](#suppress): `# buildifier: disable=native-android` The Android build rules should be loaded from Starlark. @@ -684,7 +683,6 @@ as global symbols there. * Category name: `native-cc` * Flag in Bazel: [`--incompatible_load_cc_rules_from_bzl`](https://github.com/bazelbuild/bazel/issues/8743) * Automatic fix: yes - * [Disabled by default](buildifier/README.md#linter) * [Suppress the warning](#suppress): `# buildifier: disable=native-cc` The CC build rules should be loaded from Starlark. @@ -700,7 +698,6 @@ at the moment it's not required to load Starlark rules. * Category name: `native-java` * Flag in Bazel: [`--incompatible_load_java_rules_from_bzl`](https://github.com/bazelbuild/bazel/issues/8746) * Automatic fix: yes - * [Disabled by default](buildifier/README.md#linter) * [Suppress the warning](#suppress): `# buildifier: disable=native-java` The Java build rules should be loaded from Starlark. @@ -727,7 +724,6 @@ It can silently modify the semantics of a BUILD file and makes it hard to mainta * Category name: `native-proto` * Flag in Bazel: [`--incompatible_load_proto_rules_from_bzl`](https://github.com/bazelbuild/bazel/issues/8922) * Automatic fix: yes - * [Disabled by default](buildifier/README.md#linter) * [Suppress the warning](#suppress): `# buildifier: disable=native-proto` The Proto build rules should be loaded from Starlark. @@ -743,7 +739,6 @@ at the moment it's not required to load Starlark rules. * Category name: `native-py` * Flag in Bazel: [`--incompatible_load_python_rules_from_bzl`](https://github.com/bazelbuild/bazel/issues/9006) * Automatic fix: yes - * [Disabled by default](buildifier/README.md#linter) * [Suppress the warning](#suppress): `# buildifier: disable=native-py` The Python build rules should be loaded from Starlark. diff --git a/buildifier/config/config_test.go b/buildifier/config/config_test.go index ff120d393..d71769bc4 100644 --- a/buildifier/config/config_test.go +++ b/buildifier/config/config_test.go @@ -319,13 +319,13 @@ func TestValidate(t *testing.T) { "load", "module-docstring", "name-conventions", - // "native-android", + "native-android", "native-build", - // "native-cc", - // "native-java", + "native-cc", + "native-java", "native-package", - // "native-proto", - // "native-py", + "native-proto", + "native-py", "no-effect", "output-group", "overly-nested-depset", @@ -347,7 +347,7 @@ func TestValidate(t *testing.T) { // "unsorted-dict-items", "unused-variable", }}, - "warnings plus/minus": {options: "--warnings=+native-cc,-print,-deprecated-function", wantWarnings: []string{ + "warnings plus/minus": {options: "--warnings=+unsorted-dict-items,-print,-deprecated-function", wantWarnings: []string{ "attr-applicable_licenses", "attr-cfg", "attr-license", @@ -381,12 +381,13 @@ func TestValidate(t *testing.T) { "load", "module-docstring", "name-conventions", - // "native-android", + "native-android", "native-build", - // "native-java", + "native-cc", + "native-java", "native-package", - // "native-proto", - // "native-py", + "native-proto", + "native-py", "no-effect", "output-group", "overly-nested-depset", @@ -406,9 +407,8 @@ func TestValidate(t *testing.T) { "uninitialized", "unnamed-macro", "unreachable", - // "unsorted-dict-items", "unused-variable", - "native-cc", + "unsorted-dict-items", }}, "warnings error": {options: "--warnings=native-cc,-print,-deprecated-function", wantErr: fmt.Errorf(`warning categories with modifiers ("+" or "-") can't be mixed with raw warning categories`)}, } { diff --git a/warn/warn.go b/warn/warn.go index 6f7c24e51..70672c6b0 100644 --- a/warn/warn.go +++ b/warn/warn.go @@ -187,11 +187,6 @@ var MultiFileWarningMap = map[string]func(f *build.File, fileReader *FileReader) // for all files and cause too much diff noise when applied. var nonDefaultWarnings = map[string]bool{ "unsorted-dict-items": true, // dict items should be sorted - "native-android": true, // disables native android rules - "native-cc": true, // disables native cc rules - "native-java": true, // disables native java rules - "native-proto": true, // disables native proto rules - "native-py": true, // disables native python rules } // fileWarningWrapper is a wrapper that converts a file warning function to a generic function.