<?xml version="1.0" encoding="UTF-8" ?>

<FindBugsFilter>
  <!-- In general, do not run this on tests or generated benchmark classes -->
  <Match>
    <Source name="~.*\/testsrc\/.*"/>
  </Match>
  <Match>
    <Source name="~.*\\testsrc\\.*"/>
  </Match>
  <Match>
    <Source name="~.*\/examples\/.*"/>
  </Match>
  <Match>
    <Source name="~.*\\examples\\.*"/>
  </Match>
  <Match>
    <Class name="~org\.mozilla\.javascript\.benchmarks\.jmh_generated.*"/>
  </Match>

  <!-- Things below are legit exemptions -->
  <Match>
    <!-- Existing "Token" constants have values to 255 -->
    <Class name="org.mozilla.javascript.Interpreter" />
    <Bug pattern="INT_BAD_COMPARISON_WITH_SIGNED_BYTE" />
  </Match>
  <Match>
    <!-- Let this class do its job -->
    <Class name="org.mozilla.javascript.DToA" />
    <Bug pattern="FE_FLOATING_POINT_EQUALITY" />
  </Match>
  <Match>
    <!-- A bigger task to take this on across the codebase -->
    <Bug pattern="DM_DEFAULT_ENCODING" />
  </Match>
  <Match>
    <!-- SymbolKey and NativeSymbol objects may be compared directly. -->
    <Class name="org.mozilla.javascript.SymbolKey"/>
    <Bug pattern="EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS" />
  </Match>
  <Match>
    <!-- SymbolKey and NativeSymbol objects may be compared directly. -->
    <Class name="org.mozilla.javascript.NativeSymbol"/>
    <Bug pattern="EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS" />
  </Match>
  <Match>
    <!-- Legacy code depends on being able to reassign values in Main -->
    <Class name="org.mozilla.javascript.tools.shell.Main"/>
    <Bug pattern="MS_SHOULD_BE_FINAL"/>
  </Match>
  <Match>
    <!-- Legacy code depends on being able to reassign values in Main -->
    <Class name="org.mozilla.javascript.tools.shell.Main"/>
    <Bug pattern="MS_PKGPROTECT"/>
  </Match>
  <Match>
    <!-- GUI code just loves to swallow exceptions -->
    <Class name="org.mozilla.javascript.tools.debugger.SwingGui"/>
    <Bug pattern="DE_MIGHT_IGNORE"/>
  </Match>
  <Match>
    <!-- In general, the tools need to exit -->
    <Class name="~org\.mozilla\.javascript\.tools.*"/>
    <Bug pattern="DM_EXIT"/>
  </Match>
  <Match>
    <!-- Fixing this would break our public API -->
    <Bug pattern="EI_EXPOSE_REP"/>
  </Match>
  <Match>
    <!-- We do this in a few places for performance in legacy code -->
    <Bug pattern="EI_EXPOSE_REP2"/>
  </Match>
  <Match>
    <!-- We check for this in checkstyle using a different annotation -->
    <Bug pattern="SF_SWITCH_FALLTHROUGH"/>
  </Match>
  <Match>
    <!-- We check for this in checkstyle using a different annotation -->
    <Bug pattern="SF_SWITCH_NO_DEFAULT"/>
  </Match>
  <Match>
    <!-- Fixing this would break "DEBUG" -->
    <Class name="org.mozilla.javascript.optimizer.Block"/>
    <Bug pattern="UUF_UNUSED_FIELD"/>
  </Match>
  <Match>
    <!-- Fixing this would break "DEBUG" -->
    <Class name="org.mozilla.javascript.regexp.NativeRegExp"/>
    <Bug pattern="DLS_DEAD_LOCAL_STORE"/>
  </Match>
  <Match>
    <!-- This is kind of a weird thing that's necessary for the security manager -->
    <Class name="org.mozilla.javascript.tools.shell.JavaPolicySecurity"/>
    <Bug pattern="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT"/>
  </Match>
  <Match>
    <!-- And this is a weird thing related to maybe multithreading the GUI -->
    <Class name="org.mozilla.javascript.tools.debugger.Dim"/>
    <Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
  </Match>
  <Match>
    <!-- Referenced in generated code -->
    <Class name="org.mozilla.javascript.optimizer.OptRuntime$GeneratorState"/>
    <Bug pattern="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD"/>
  </Match>
  <Match>
    <!-- Referenced in generated code -->
    <Class name="org.mozilla.javascript.optimizer.OptRuntime$GeneratorState"/>
    <Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
  </Match>
  <!-- Complex legacy stuff -->
  <!--<Match>
    <Class name="org.mozilla.javascript.regexp.RegExpImpl"/>
    <Bug pattern="RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN"/>
  </Match>-->

  <!-- Things below are things that we aspire to fix! -->
  <Match>
    <!-- We are planning to eliminate serialization -->
    <Bug pattern="SE_BAD_FIELD"/>
  </Match>
  <Match>
    <!-- We are planning to eliminate serialization -->
    <Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
  </Match>
  <Match>
    <!-- We are planning to get rid of synchronization -->
    <Bug pattern="DC_DOUBLECHECK"/>
  </Match>
  <Match>
    <!-- We are planning to get rid of synchronization -->
    <Bug pattern="IS2_INCONSISTENT_SYNC"/>
  </Match>
  <Match>
    <!-- We are planning to get rid of synchronization -->
    <Bug pattern="UG_SYNC_SET_UNSYNC_GET"/>
  </Match>
</FindBugsFilter>