Disable --all_incompatible_changes.
Step 1 of https://github.com/bazelbuild/bazel/issues/13892
RELNOTES:
Disable --all_incompatible_changes flag.
PiperOrigin-RevId: 392476629
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/AllIncompatibleChangesExpansion.java b/src/main/java/com/google/devtools/build/lib/runtime/AllIncompatibleChangesExpansion.java
deleted file mode 100644
index 9dff3d9..0000000
--- a/src/main/java/com/google/devtools/build/lib/runtime/AllIncompatibleChangesExpansion.java
+++ /dev/null
@@ -1,181 +0,0 @@
-// Copyright 2017 The Bazel Authors. All rights reserved.
-//
-// 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 com.google.devtools.build.lib.runtime;
-
-import com.google.common.collect.ImmutableList;
-import com.google.devtools.common.options.Converter;
-import com.google.devtools.common.options.ExpansionFunction;
-import com.google.devtools.common.options.IsolatedOptionsData;
-import com.google.devtools.common.options.OptionDefinition;
-import com.google.devtools.common.options.OptionMetadataTag;
-import java.util.ArrayList;
-import java.util.Map;
-
-/**
- * Expansion function for {@code --all_incompatible_changes}. Expands to all options of form {@code
- * --incompatible_*} that are declared in the {@link com.google.devtools.common.options.OptionsBase}
- * subclasses that are passed to the parser.
- *
- * <p>The incompatible changes system provides users with a uniform way of opting into backwards-
- * incompatible changes, in order to test whether their builds will be broken by an upcoming
- * release. When adding a new breaking change to Bazel, prefer to use this mechanism for guarding
- * the behavior.
- *
- * <p>An {@link com.google.devtools.common.options.Option}-annotated field that is considered an
- * incompatible change must satisfy the following requirements.
- *
- * <ul>
- * <li>the {@link com.google.devtools.common.options.Option#name} must be prefixed with
- * "incompatible_"
- * <li>the {@link com.google.devtools.common.options.Option#metadataTags()} must include {@link
- * OptionMetadataTag#INCOMPATIBLE_CHANGE} and {@link
- * OptionMetadataTag#TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES}
- * <li>the {@link com.google.devtools.common.options.Option#help} field must be set, and must
- * refer the user to information about what the change does and how to migrate their code
- * <li>the following fields may not be used: {@link
- * com.google.devtools.common.options.Option#abbrev}, {@link
- * com.google.devtools.common.options.Option#valueHelp}, {@link
- * com.google.devtools.common.options.Option#converter}, {@link
- * com.google.devtools.common.options.Option#allowMultiple}, and {@link
- * com.google.devtools.common.options.Option#oldName}
- * </ul>
- *
- * Example:
- *
- * <pre>{@code
- * @Option(
- * name = "incompatible_foo",
- * metadataTags = {
- * OptionMetadataTag.INCOMPATIBLE_CHANGE,
- * OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
- * },
- * defaultValue = "false",
- * help = "Deprecates bar and changes the semantics of baz. To migrate your code see [...].")
- * public boolean incompatibleFoo;
- * }</pre>
- *
- * All options that have either the "incompatible_" prefix or the tag {@link
- * OptionMetadataTag#TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES} will be validated using the above
- * criteria. Any failure will cause {@link IllegalArgumentException} to be thrown, which will cause
- * the construction of the {@link com.google.devtools.common.options.OptionsParser} to fail with the
- * <i>unchecked</i> exception {@link
- * com.google.devtools.common.options.OptionsParser.ConstructionException}. Therefore, when adding a
- * new incompatible change, be aware that an error in the specification of the {@code @Option} will
- * exercise failure code paths in the early part of the Bazel server execution.
- *
- * <p>After the breaking change has been enabled by default, it is recommended (required?) that the
- * flag stick around for a few releases, to provide users the flexibility to opt out. Even after
- * enabling the behavior unconditionally, it can still be useful to keep the flag around as a valid
- * no-op so that Bazel invocations are not immediately broken.
- *
- * <p>Generally speaking, we should never reuse names for multiple options. Therefore, when choosing
- * a name for a new incompatible change, try to describe not just the affected feature, but what the
- * change to that feature is. This avoids conflicts in case the feature changes multiple times. For
- * example, {@code "--incompatible_depset_constructor"} is ambiguous because it only communicates
- * that there is a change to how depsets are constructed, but {@code
- * "--incompatible_disallow_set_constructor"} uniquely says that the {@code set} alias for the
- * depset constructor is being disallowed.
- */
-// Javadoc can't resolve inner classes.
-@SuppressWarnings("javadoc")
-public class AllIncompatibleChangesExpansion implements ExpansionFunction {
-
- // The reserved prefix for all incompatible change option names.
- public static final String INCOMPATIBLE_NAME_PREFIX = "incompatible_";
-
- /**
- * Ensures that the given option satisfies all the requirements on incompatible change options
- * enumerated above.
- *
- * <p>If any of these requirements are not satisfied, {@link IllegalArgumentException} is thrown,
- * as this constitutes an internal error in the declaration of the option.
- */
- private static void validateIncompatibleChange(OptionDefinition optionDefinition) {
- String prefix = String.format("Incompatible change %s ", optionDefinition);
-
- // To avoid ambiguity, and the suggestion of using .isEmpty().
- String defaultString = "";
-
- // Validate that disallowed fields aren't used. These will need updating if the default values
- // in Option ever change, and perhaps if new fields are added.
- if (optionDefinition.getAbbreviation() != '\0') {
- throw new IllegalArgumentException(prefix + "must not use the abbrev field");
- }
- if (!optionDefinition.getValueTypeHelpText().equals(defaultString)) {
- throw new IllegalArgumentException(prefix + "must not use the valueHelp field");
- }
- if (optionDefinition.getProvidedConverter() != Converter.class) {
- throw new IllegalArgumentException(prefix + "must not use the converter field");
- }
- if (optionDefinition.allowsMultiple()) {
- throw new IllegalArgumentException(prefix + "must not use the allowMultiple field");
- }
- if (optionDefinition.hasImplicitRequirements()) {
- throw new IllegalArgumentException(prefix + "must not use the implicitRequirements field");
- }
- if (!optionDefinition.getOldOptionName().equals(defaultString)
- && !optionDefinition.getOldOptionName().startsWith("experimental_")) {
- throw new IllegalArgumentException(prefix + "must not use the oldName field");
- }
-
- // Validate the fields that are actually allowed.
- if (!optionDefinition.getOptionName().startsWith(INCOMPATIBLE_NAME_PREFIX)) {
- throw new IllegalArgumentException(prefix + "must have name starting with \"incompatible_\"");
- }
- if (!ImmutableList.copyOf(optionDefinition.getOptionMetadataTags())
- .contains(OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES)) {
- throw new IllegalArgumentException(
- prefix
- + "must have metadata tag OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES");
- }
- if (!ImmutableList.copyOf(optionDefinition.getOptionMetadataTags())
- .contains(OptionMetadataTag.INCOMPATIBLE_CHANGE)) {
- throw new IllegalArgumentException(
- prefix + "must have metadata tag OptionMetadataTag.INCOMPATIBLE_CHANGE");
- }
- if (!optionDefinition.isExpansionOption()) {
- if (!optionDefinition.getType().equals(Boolean.TYPE)) {
- throw new IllegalArgumentException(
- prefix + "must have boolean type (unless it's an expansion option)");
- }
- }
- if (optionDefinition.getHelpText().equals(defaultString)) {
- throw new IllegalArgumentException(
- prefix
- + "must have a \"help\" string that refers the user to "
- + "information about this change and how to migrate their code");
- }
- }
-
- @Override
- public ImmutableList<String> getExpansion(IsolatedOptionsData optionsData) {
- // Grab all registered options that are identified as incompatible changes by either name or
- // by OptionMetadataTag. Ensure they satisfy our requirements.
- ArrayList<String> incompatibleChanges = new ArrayList<>();
- for (Map.Entry<String, OptionDefinition> entry : optionsData.getAllOptionDefinitions()) {
- OptionDefinition optionDefinition = entry.getValue();
- if (optionDefinition.getOptionName().startsWith(INCOMPATIBLE_NAME_PREFIX)
- || ImmutableList.copyOf(optionDefinition.getOptionMetadataTags())
- .contains(OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES)) {
- validateIncompatibleChange(optionDefinition);
- incompatibleChanges.add("--" + optionDefinition.getOptionName());
- }
- }
- // Sort to get a deterministic canonical order. This probably isn't necessary because the
- // options parser will do its own sorting when canonicalizing, but it seems like it can't hurt.
- incompatibleChanges.sort(null);
- return ImmutableList.copyOf(incompatibleChanges);
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java b/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java
index 29077ad..21a5b72 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java
@@ -47,12 +47,9 @@
name = "all_incompatible_changes",
defaultValue = "null",
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.UNKNOWN},
+ effectTags = {OptionEffectTag.NO_OP},
metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
- expansionFunction = AllIncompatibleChangesExpansion.class,
- help =
- "Enables all options of the form --incompatible_*. Use this option to find places where "
- + "your build may break in the future due to deprecations or other changes.")
+ help = "No-op, being removed. See https://github.com/bazelbuild/bazel/issues/13892")
public Void allIncompatibleChanges;
@Option(
diff --git a/src/test/java/com/google/devtools/build/lib/runtime/AllIncompatibleChangesExpansionTest.java b/src/test/java/com/google/devtools/build/lib/runtime/AllIncompatibleChangesExpansionTest.java
deleted file mode 100644
index 1906f60..0000000
--- a/src/test/java/com/google/devtools/build/lib/runtime/AllIncompatibleChangesExpansionTest.java
+++ /dev/null
@@ -1,515 +0,0 @@
-// Copyright 2017 The Bazel Authors. All rights reserved.
-//
-// 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 com.google.devtools.build.lib.runtime;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.fail;
-
-import com.google.common.collect.ImmutableList;
-import com.google.devtools.build.lib.runtime.proto.InvocationPolicyOuterClass.InvocationPolicy;
-import com.google.devtools.build.lib.runtime.proto.InvocationPolicyOuterClass.UseDefault;
-import com.google.devtools.common.options.Converters;
-import com.google.devtools.common.options.ExpansionFunction;
-import com.google.devtools.common.options.InvocationPolicyEnforcer;
-import com.google.devtools.common.options.IsolatedOptionsData;
-import com.google.devtools.common.options.Option;
-import com.google.devtools.common.options.OptionDocumentationCategory;
-import com.google.devtools.common.options.OptionEffectTag;
-import com.google.devtools.common.options.OptionMetadataTag;
-import com.google.devtools.common.options.OptionsBase;
-import com.google.devtools.common.options.OptionsParser;
-import com.google.devtools.common.options.OptionsParsingException;
-import java.util.List;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-/**
- * Tests for the Incompatible Changes system (--incompatible_* flags). These go in their own suite
- * because the options parser doesn't know the business logic for incompatible changes.
- */
-@RunWith(JUnit4.class)
-public class AllIncompatibleChangesExpansionTest {
-
- /** Dummy comment (linter suppression) */
- public static class ExampleOptions extends OptionsBase {
- @Option(
- name = "all",
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.NO_OP},
- defaultValue = "null",
- expansionFunction = AllIncompatibleChangesExpansion.class
- )
- public Void all;
-
- @Option(
- name = "X",
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.NO_OP},
- defaultValue = "false"
- )
- public boolean x;
-
- @Option(
- name = "Y",
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.NO_OP},
- defaultValue = "true"
- )
- public boolean y;
-
- @Option(
- name = "incompatible_A",
- metadataTags = {
- OptionMetadataTag.INCOMPATIBLE_CHANGE,
- OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
- },
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.NO_OP},
- defaultValue = "false",
- help = "Migrate to A"
- )
- public boolean incompatibleA;
-
- @Option(
- name = "incompatible_B",
- metadataTags = {
- OptionMetadataTag.INCOMPATIBLE_CHANGE,
- OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
- },
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.NO_OP},
- defaultValue = "false",
- help = "Migrate to B"
- )
- public boolean incompatibleB;
-
- @Option(
- name = "incompatible_C",
- oldName = "experimental_C",
- metadataTags = {
- OptionMetadataTag.INCOMPATIBLE_CHANGE,
- OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
- },
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.NO_OP},
- defaultValue = "true",
- help = "Migrate to C"
- )
- public boolean incompatibleC;
- }
-
- /** Dummy comment (linter suppression) */
- public static class ExampleExpansionOptions extends OptionsBase {
- @Option(
- name = "incompatible_expX",
- metadataTags = {
- OptionMetadataTag.INCOMPATIBLE_CHANGE,
- OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
- },
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.NO_OP},
- defaultValue = "null",
- expansion = {"--X"},
- help = "Start using X"
- )
- public Void incompatibleExpX;
-
- /** Dummy comment (linter suppression) */
- public static class NoYExpansion implements ExpansionFunction {
- @Override
- public ImmutableList<String> getExpansion(IsolatedOptionsData optionsData) {
- return ImmutableList.of("--noY");
- }
- }
-
- @Option(
- name = "incompatible_expY",
- metadataTags = {
- OptionMetadataTag.INCOMPATIBLE_CHANGE,
- OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
- },
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.NO_OP},
- defaultValue = "null",
- expansionFunction = NoYExpansion.class,
- help = "Stop using Y"
- )
- public Void incompatibleExpY;
- }
-
- @Test
- public void noChangesSelected() throws OptionsParsingException {
- OptionsParser parser = OptionsParser.builder().optionsClasses(ExampleOptions.class).build();
- parser.parse("");
- ExampleOptions opts = parser.getOptions(ExampleOptions.class);
- assertThat(opts.x).isFalse();
- assertThat(opts.y).isTrue();
- assertThat(opts.incompatibleA).isFalse();
- assertThat(opts.incompatibleB).isFalse();
- assertThat(opts.incompatibleC).isTrue();
- }
-
- @Test
- public void allChangesSelected() throws OptionsParsingException {
- OptionsParser parser = OptionsParser.builder().optionsClasses(ExampleOptions.class).build();
- parser.parse("--all");
- ExampleOptions opts = parser.getOptions(ExampleOptions.class);
- assertThat(opts.x).isFalse();
- assertThat(opts.y).isTrue();
- assertThat(opts.incompatibleA).isTrue();
- assertThat(opts.incompatibleB).isTrue();
- assertThat(opts.incompatibleC).isTrue();
- }
-
- @Test
- public void rightmostOverrides() throws OptionsParsingException {
- // Check that all-expansion behaves just like any other expansion flag:
- // the rightmost setting of any individual option wins.
- OptionsParser parser = OptionsParser.builder().optionsClasses(ExampleOptions.class).build();
- parser.parse("--noincompatible_A", "--all", "--noincompatible_B");
- ExampleOptions opts = parser.getOptions(ExampleOptions.class);
- assertThat(opts.incompatibleA).isTrue();
- assertThat(opts.incompatibleB).isFalse();
- }
-
- @Test
- public void expansionOptions() throws OptionsParsingException {
- // Check that all-expansion behaves just like any other expansion flag:
- // the rightmost setting of any individual option wins.
- OptionsParser parser =
- OptionsParser.builder()
- .optionsClasses(ExampleOptions.class, ExampleExpansionOptions.class)
- .build();
- parser.parse("--all");
- ExampleOptions opts = parser.getOptions(ExampleOptions.class);
- assertThat(opts.x).isTrue();
- assertThat(opts.y).isFalse();
- assertThat(opts.incompatibleA).isTrue();
- assertThat(opts.incompatibleB).isTrue();
- }
-
- @Test
- public void invocationPolicy() throws OptionsParsingException {
- // Check that all-expansion behaves just like any other expansion flag and can be filtered
- // by invocation policy.
- InvocationPolicy.Builder invocationPolicyBuilder = InvocationPolicy.newBuilder();
- invocationPolicyBuilder
- .addFlagPoliciesBuilder()
- .setFlagName("incompatible_A")
- .setUseDefault(UseDefault.getDefaultInstance());
- InvocationPolicy policy = invocationPolicyBuilder.build();
- InvocationPolicyEnforcer enforcer = new InvocationPolicyEnforcer(policy);
-
- OptionsParser parser = OptionsParser.builder().optionsClasses(ExampleOptions.class).build();
- parser.parse("--all");
- enforcer.enforce(parser);
-
- ExampleOptions opts = parser.getOptions(ExampleOptions.class);
- assertThat(opts.x).isFalse();
- assertThat(opts.y).isTrue();
- assertThat(opts.incompatibleA).isFalse(); // A should have been removed from the expansion.
- assertThat(opts.incompatibleB).isTrue(); // B, without a policy, should have been left alone.
- }
-
- /** Option with the right prefix, but the wrong metadata tag. */
- public static class IncompatibleChangeTagOption extends OptionsBase {
- @Option(
- name = "some_option_with_a_tag",
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
- effectTags = {OptionEffectTag.NO_OP},
- defaultValue = "false",
- help = "nohelp"
- )
- public boolean opt;
- }
-
- @Test
- public void incompatibleChangeTagDoesNotTriggerAllIncompatibleChangesCheck() {
- try {
- OptionsParser.builder()
- .optionsClasses(ExampleOptions.class, IncompatibleChangeTagOption.class)
- .build();
- } catch (OptionsParser.ConstructionException e) {
- fail(
- "some_option_with_a_tag should not trigger the expansion, so there should be no checks "
- + "on it having the right prefix and metadata tags. Instead, the following exception "
- + "was thrown: "
- + e.getMessage());
- }
- }
-
- // There's no unit test to check that the expansion of --all is sorted. IsolatedOptionsData is not
- // exposed from OptionsParser, making it difficult to check, and it's not clear that exposing it
- // would be worth it.
-
- /**
- * Ensure that we get an {@link OptionsParser.ConstructionException} containing {@code message}
- * when the incompatible changes in the given {@link OptionsBase} subclass are validated.
- */
- // Because javadoc can't resolve inner classes.
- @SuppressWarnings("javadoc")
- private static void assertBadness(Class<? extends OptionsBase> optionsBaseClass, String message) {
- OptionsParser.ConstructionException e =
- assertThrows(
- "Should have failed with message \"" + message + "\"",
- OptionsParser.ConstructionException.class,
- () ->
- OptionsParser.builder()
- .optionsClasses(ExampleOptions.class, optionsBaseClass)
- .build());
- assertThat(e).hasMessageThat().contains(message);
- }
-
- /** Dummy comment (linter suppression) */
- public static class BadNameOptions extends OptionsBase {
- @Option(
- name = "badname",
- metadataTags = {
- OptionMetadataTag.INCOMPATIBLE_CHANGE,
- OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
- },
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.NO_OP},
- defaultValue = "false",
- help = "nohelp"
- )
- public boolean bad;
- }
-
- @Test
- public void badName() {
- assertBadness(
- BadNameOptions.class,
- "Incompatible change option '--badname' must have name "
- + "starting with \"incompatible_\"");
- }
-
- /** Option with the right prefix, but the wrong metadata tag. */
- public static class MissingTriggeredByTagOptions extends OptionsBase {
- @Option(
- name = "incompatible_bad",
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
- effectTags = {OptionEffectTag.NO_OP},
- defaultValue = "false",
- help = "nohelp"
- )
- public boolean bad;
- }
-
- @Test
- public void badTag() {
- assertBadness(
- MissingTriggeredByTagOptions.class,
- "must have metadata tag OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES");
- }
-
- /** Option with the right prefix, but the wrong metadata tag. */
- public static class MissingIncompatibleTagOptions extends OptionsBase {
- @Option(
- name = "incompatible_bad",
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- metadataTags = {OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES},
- effectTags = {OptionEffectTag.NO_OP},
- defaultValue = "false",
- help = "nohelp"
- )
- public boolean bad;
- }
-
- @Test
- public void otherBadTag() {
- assertBadness(
- MissingIncompatibleTagOptions.class,
- "must have metadata tag OptionMetadataTag.INCOMPATIBLE_CHANGE");
- }
-
- /** Dummy comment (linter suppression) */
- public static class BadTypeOptions extends OptionsBase {
- @Option(
- name = "incompatible_bad",
- metadataTags = {
- OptionMetadataTag.INCOMPATIBLE_CHANGE,
- OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
- },
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.NO_OP},
- defaultValue = "0",
- help = "nohelp"
- )
- public int bad;
- }
-
- @Test
- public void badType() {
- assertBadness(BadTypeOptions.class, "must have boolean type");
- }
-
- /** Dummy comment (linter suppression) */
- public static class BadHelpOptions extends OptionsBase {
- @Option(
- name = "incompatible_bad",
- metadataTags = {
- OptionMetadataTag.INCOMPATIBLE_CHANGE,
- OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
- },
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.NO_OP},
- defaultValue = "false"
- )
- public boolean bad;
- }
-
- @Test
- public void badHelp() {
- assertBadness(BadHelpOptions.class, "must have a \"help\" string");
- }
-
- /** Dummy comment (linter suppression) */
- public static class BadAbbrevOptions extends OptionsBase {
- @Option(
- name = "incompatible_bad",
- metadataTags = {
- OptionMetadataTag.INCOMPATIBLE_CHANGE,
- OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
- },
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.NO_OP},
- defaultValue = "false",
- help = "nohelp",
- abbrev = 'x'
- )
- public boolean bad;
- }
-
- @Test
- public void badAbbrev() {
- assertBadness(BadAbbrevOptions.class, "must not use the abbrev field");
- }
-
- /** Dummy comment (linter suppression) */
- public static class BadValueHelpOptions extends OptionsBase {
- @Option(
- name = "incompatible_bad",
- metadataTags = {
- OptionMetadataTag.INCOMPATIBLE_CHANGE,
- OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
- },
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.NO_OP},
- defaultValue = "false",
- help = "nohelp",
- valueHelp = "x"
- )
- public boolean bad;
- }
-
- @Test
- public void badValueHelp() {
- assertBadness(BadValueHelpOptions.class, "must not use the valueHelp field");
- }
-
- /** Dummy comment (linter suppression) */
- public static class BadConverterOptions extends OptionsBase {
- @Option(
- name = "incompatible_bad",
- metadataTags = {
- OptionMetadataTag.INCOMPATIBLE_CHANGE,
- OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
- },
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.NO_OP},
- defaultValue = "false",
- help = "nohelp",
- converter = Converters.BooleanConverter.class
- )
- public boolean bad;
- }
-
- @Test
- public void badConverter() {
- assertBadness(BadConverterOptions.class, "must not use the converter field");
- }
-
- /** Dummy comment (linter suppression) */
- public static class BadAllowMultipleOptions extends OptionsBase {
- @Option(
- name = "incompatible_bad",
- metadataTags = {
- OptionMetadataTag.INCOMPATIBLE_CHANGE,
- OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
- },
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.NO_OP},
- defaultValue = "null",
- help = "nohelp",
- allowMultiple = true
- )
- public List<String> bad;
- }
-
- @Test
- public void badAllowMutliple() {
- assertBadness(BadAllowMultipleOptions.class, "must not use the allowMultiple field");
- }
-
- /** Dummy comment (linter suppression) */
- public static class BadImplicitRequirementsOptions extends OptionsBase {
- @Option(
- name = "incompatible_bad",
- metadataTags = {
- OptionMetadataTag.INCOMPATIBLE_CHANGE,
- OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
- },
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.NO_OP},
- defaultValue = "false",
- help = "nohelp",
- implicitRequirements = "--x"
- )
- public boolean bad;
- }
-
- @Test
- public void badImplicitRequirements() {
- assertBadness(
- BadImplicitRequirementsOptions.class, "must not use the implicitRequirements field");
- }
-
- /** Dummy comment (linter suppression) */
- public static class BadOldNameOptions extends OptionsBase {
- @Option(
- name = "incompatible_bad",
- metadataTags = {
- OptionMetadataTag.INCOMPATIBLE_CHANGE,
- OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
- },
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.NO_OP},
- defaultValue = "false",
- help = "nohelp",
- oldName = "x"
- )
- public boolean bad;
- }
-
- @Test
- public void badOldName() {
- assertBadness(BadOldNameOptions.class, "must not use the oldName field");
- }
-}