Skip to content

Commit

Permalink
Set assertIdentifier & enumIdentifier options to "error" by default
Browse files Browse the repository at this point in the history
Both options are still present in compiler/core code, but shouldn't be
set to any other value as "error". For now we will ignore any provided
values and use "error" by default.

See eclipse-jdt#2536
  • Loading branch information
iloveeclipse committed Aug 7, 2024
1 parent 783a077 commit a8b93dd
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3869,7 +3869,7 @@ private void handleErrorOrWarningToken(String token, boolean isEnabling, int sev
setSeverity(CompilerOptions.OPTION_ReportMissingJavadocComments, severity, isEnabling);
return;
} else if (token.equals("assertIdentifier")) { //$NON-NLS-1$
setSeverity(CompilerOptions.OPTION_ReportAssertIdentifier, severity, isEnabling);
// error by default, no other values accepted
return;
} else if (token.equals("allDeadCode")) { //$NON-NLS-1$
setSeverity(CompilerOptions.OPTION_ReportDeadCode, severity, isEnabling);
Expand Down Expand Up @@ -3966,7 +3966,7 @@ private void handleErrorOrWarningToken(String token, boolean isEnabling, int sev
setSeverity(CompilerOptions.OPTION_ReportUndocumentedEmptyBlock, severity, isEnabling);
return;
} else if (token.equals("enumIdentifier")) { //$NON-NLS-1$
setSeverity(CompilerOptions.OPTION_ReportEnumIdentifier, severity, isEnabling);
// error by default, no other values accepted
return;
} else if (token.equals("exports")) { //$NON-NLS-1$
setSeverity(CompilerOptions.OPTION_ReportAPILeak, severity, isEnabling);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,6 @@ public static long versionToJdkLevel(String versionID, boolean supportUnreleased
public static String[] warningOptionNames() {
String[] result = {
OPTION_ReportAnnotationSuperInterface,
OPTION_ReportAssertIdentifier,
OPTION_ReportAutoboxing,
OPTION_ReportComparingIdentical,
OPTION_ReportDeadCode,
Expand All @@ -1022,7 +1021,6 @@ public static String[] warningOptionNames() {
OPTION_ReportDeprecationWhenOverridingDeprecatedMethod,
OPTION_ReportDiscouragedReference,
OPTION_ReportEmptyStatement,
OPTION_ReportEnumIdentifier,
OPTION_ReportFallthroughCase,
OPTION_ReportFieldHiding,
OPTION_ReportFinallyBlockNotCompletingNormally,
Expand Down Expand Up @@ -1372,8 +1370,8 @@ public Map<String, String> getMap() {
optionsMap.put(OPTION_ReportTypeParameterHiding, getSeverityString(TypeHiding));
optionsMap.put(OPTION_ReportPossibleAccidentalBooleanAssignment, getSeverityString(AccidentalBooleanAssign));
optionsMap.put(OPTION_ReportEmptyStatement, getSeverityString(EmptyStatement));
optionsMap.put(OPTION_ReportAssertIdentifier, getSeverityString(AssertUsedAsAnIdentifier));
optionsMap.put(OPTION_ReportEnumIdentifier, getSeverityString(EnumUsedAsAnIdentifier));
optionsMap.put(OPTION_ReportAssertIdentifier, ERROR);
optionsMap.put(OPTION_ReportEnumIdentifier, ERROR);
optionsMap.put(OPTION_ReportUndocumentedEmptyBlock, getSeverityString(UndocumentedEmptyBlock));
optionsMap.put(OPTION_ReportUnnecessaryTypeCheck, getSeverityString(UnnecessaryTypeCheck));
optionsMap.put(OPTION_ReportUnnecessaryElse, getSeverityString(UnnecessaryElse));
Expand Down Expand Up @@ -1956,8 +1954,8 @@ public void set(Map<String, String> optionsMap) {
if ((optionValue = optionsMap.get(OPTION_ReportPossibleAccidentalBooleanAssignment)) != null) updateSeverity(AccidentalBooleanAssign, optionValue);
if ((optionValue = optionsMap.get(OPTION_ReportEmptyStatement)) != null) updateSeverity(EmptyStatement, optionValue);
if ((optionValue = optionsMap.get(OPTION_ReportNonExternalizedStringLiteral)) != null) updateSeverity(NonExternalizedString, optionValue);
if ((optionValue = optionsMap.get(OPTION_ReportAssertIdentifier)) != null) updateSeverity(AssertUsedAsAnIdentifier, optionValue);
if ((optionValue = optionsMap.get(OPTION_ReportEnumIdentifier)) != null) updateSeverity(EnumUsedAsAnIdentifier, optionValue);
if ((optionValue = optionsMap.get(OPTION_ReportAssertIdentifier)) != null) updateSeverity(AssertUsedAsAnIdentifier, ERROR);
if ((optionValue = optionsMap.get(OPTION_ReportEnumIdentifier)) != null) updateSeverity(EnumUsedAsAnIdentifier, ERROR);
if ((optionValue = optionsMap.get(OPTION_ReportNonStaticAccessToStatic)) != null) updateSeverity(NonStaticAccessToStatic, optionValue);
if ((optionValue = optionsMap.get(OPTION_ReportIndirectStaticAccess)) != null) updateSeverity(IndirectStaticAccess, optionValue);
if ((optionValue = optionsMap.get(OPTION_ReportIncompatibleNonInheritedInterfaceMethod)) != null) updateSeverity(IncompatibleNonInheritedInterfaceMethod, optionValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ public void test013() {
" <option key=\"org.eclipse.jdt.core.compiler.problem.APILeak\" value=\"warning\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.problem.annotatedTypeArgumentToUnannotated\" value=\"info\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.problem.annotationSuperInterface\" value=\"warning\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.problem.assertIdentifier\" value=\"warning\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.problem.assertIdentifier\" value=\"error\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.problem.autoboxing\" value=\"ignore\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.problem.comparingIdentical\" value=\"warning\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.problem.deadCode\" value=\"warning\"/>\n" +
Expand All @@ -1062,7 +1062,7 @@ public void test013() {
" <option key=\"org.eclipse.jdt.core.compiler.problem.discouragedReference\" value=\"warning\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.problem.emptyStatement\" value=\"ignore\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures\" value=\"disabled\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.problem.enumIdentifier\" value=\"warning\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.problem.enumIdentifier\" value=\"error\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable\" value=\"ignore\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.problem.fallthroughCase\" value=\"ignore\"/>\n" +
" <option key=\"org.eclipse.jdt.core.compiler.problem.fatalOptionalError\" value=\"disabled\"/>\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ private Map getDefaultCompilerOptions() {
optionsMap.put(CompilerOptions.OPTION_ReportFieldHiding, CompilerOptions.IGNORE);
optionsMap.put(CompilerOptions.OPTION_ReportPossibleAccidentalBooleanAssignment, CompilerOptions.IGNORE);
optionsMap.put(CompilerOptions.OPTION_ReportEmptyStatement, CompilerOptions.IGNORE);
optionsMap.put(CompilerOptions.OPTION_ReportAssertIdentifier, CompilerOptions.IGNORE);
optionsMap.put(CompilerOptions.OPTION_ReportEnumIdentifier, CompilerOptions.IGNORE);
optionsMap.put(CompilerOptions.OPTION_ReportAssertIdentifier, CompilerOptions.ERROR);
optionsMap.put(CompilerOptions.OPTION_ReportEnumIdentifier, CompilerOptions.ERROR);
optionsMap.put(CompilerOptions.OPTION_ReportUndocumentedEmptyBlock, CompilerOptions.IGNORE);
optionsMap.put(CompilerOptions.OPTION_ReportUnnecessaryTypeCheck, CompilerOptions.IGNORE);
optionsMap.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.IGNORE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1498,8 +1498,8 @@ private Map getDefaultCompilerOptions() {
optionsMap.put(CompilerOptions.OPTION_ReportFieldHiding, CompilerOptions.IGNORE);
optionsMap.put(CompilerOptions.OPTION_ReportPossibleAccidentalBooleanAssignment, CompilerOptions.IGNORE);
optionsMap.put(CompilerOptions.OPTION_ReportEmptyStatement, CompilerOptions.IGNORE);
optionsMap.put(CompilerOptions.OPTION_ReportAssertIdentifier, CompilerOptions.IGNORE);
optionsMap.put(CompilerOptions.OPTION_ReportEnumIdentifier, CompilerOptions.IGNORE);
optionsMap.put(CompilerOptions.OPTION_ReportAssertIdentifier, CompilerOptions.ERROR);
optionsMap.put(CompilerOptions.OPTION_ReportEnumIdentifier, CompilerOptions.ERROR);
optionsMap.put(CompilerOptions.OPTION_ReportUndocumentedEmptyBlock, CompilerOptions.IGNORE);
optionsMap.put(CompilerOptions.OPTION_ReportUnnecessaryTypeCheck, CompilerOptions.IGNORE);
optionsMap.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.IGNORE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,6 @@ protected Hashtable warningOptions(int kind) {
optionsMap.put(CompilerOptions.OPTION_ReportFieldHiding, warning);
optionsMap.put(CompilerOptions.OPTION_ReportPossibleAccidentalBooleanAssignment, warning);
optionsMap.put(CompilerOptions.OPTION_ReportEmptyStatement, warning);
optionsMap.put(CompilerOptions.OPTION_ReportAssertIdentifier, warning);
optionsMap.put(CompilerOptions.OPTION_ReportUndocumentedEmptyBlock, warning);
optionsMap.put(CompilerOptions.OPTION_ReportUnnecessaryTypeCheck, warning);
optionsMap.put(CompilerOptions.OPTION_ReportUnnecessaryElse, warning);
Expand All @@ -1254,7 +1253,6 @@ protected Hashtable warningOptions(int kind) {

// Ignore 3.1 options
optionsMap.put(CompilerOptions.OPTION_ReportMissingSerialVersion, CompilerOptions.IGNORE);
optionsMap.put(CompilerOptions.OPTION_ReportEnumIdentifier, CompilerOptions.IGNORE);

// Ignore 3.2 options
optionsMap.put(CompilerOptions.OPTION_ReportUnusedLabel, CompilerOptions.IGNORE);
Expand Down
4 changes: 2 additions & 2 deletions org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ public final class JavaCore extends Plugin {
* <dl>
* <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.assertIdentifier"</code></dd>
* <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd>
* <dt>Default:</dt><dd><code>"warning"</code></dd>
* <dt>Default:</dt><dd><code>"error"</code></dd>
* </dl>
* @since 2.0
* @category CompilerOptionID
Expand All @@ -660,7 +660,7 @@ public final class JavaCore extends Plugin {
* <dl>
* <dt>Option id:</dt><dd><code>"org.eclipse.jdt.core.compiler.problem.enumIdentifier"</code></dd>
* <dt>Possible values:</dt><dd><code>{ "error", "warning", "info", "ignore" }</code></dd>
* <dt>Default:</dt><dd><code>"warning"</code></dd>
* <dt>Default:</dt><dd><code>"error"</code></dd>
* </dl>
* @since 3.1
* @category CompilerOptionID
Expand Down

0 comments on commit a8b93dd

Please sign in to comment.