<FindBugsFilter>
    <!-- Bug descriptions:   http://findbugs.sourceforge.net/bugDescriptions.html  -->
    <!-- Filter file format: http://findbugs.sourceforge.net/manual/filter.html    -->

    <!-- Match all violations. -->
    <!-- But ignore these:
           * comparator should be serializable
           * something else dealing with serialization
           * format string should use %n instead of /n
           * inner class should be static (awkard, but possible with generics)
           * using entrySet() is more efficient than keySet(), but it is awkward
           * uses non-localized toLowerCase() or toUpperCase()
           * switch statement with no default; seems OK when used for cases with (int) (4 * Math.random())
           * class  naming convention (defer to Checkstyle)
           * method naming convention (defer to Checkstyle)
           * class defines compareTo() and inherits equals()
      -->
    <Match>
        <BugPattern name="SE_COMPARATOR_SHOULD_BE_SERIALIZABLE,
                          SE_BAD_FIELD,
                          VA_FORMAT_STRING_USES_NEWLINE,
                          SIC_INNER_SHOULD_BE_STATIC,
                          WMI_WRONG_MAP_ITERATOR,
                          DM_CONVERT_CASE,
                          SF_SWITCH_NO_DEFAULT,
                          NM_METHOD_NAMING_CONVENTION,
                          NM_CLASS_NAMING_CONVENTION,
                          EQ_COMPARETO_USE_OBJECT_EQUALS" />
    </Match>

    <!-- from fb-contrib-7.0.2.jar plugin -->
    <Match>
        <BugPattern name="BL_BURYING_LOGIC,
                          CLI_CONSTANT_LIST_INDEX,
                          CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET_NAME,
                          EXS_EXCEPTION_SOFTENING_NO_CONSTRAINTS,
                          IMC_IMMATURE_CLASS_NO_EQUALS,
                          IMC_IMMATURE_CLASS_NO_PACKAGE,
                          IMC_IMMATURE_CLASS_NO_TOSTRING,
                          IMC_IMMATURE_CLASS_NO_HASHCODE,
                          IMC_IMMATURE_CLASS_WRONG_FIELD_ORDER,
                          ISB_EMPTY_STRING_APPENDING,
                          ISB_INEFFICIENT_STRING_BUFFERING,
                          ISB_TOSTRING_APPENDING,
                          LSC_LITERAL_STRING_COMPARISON,
                          MAC_MANUAL_ARRAY_COPY,
                          MDM_RANDOM_SEED,
                          OPM_OVERLY_PERMISSIVE_METHOD,
                          PCOA_PARTIALLY_CONSTRUCTED_OBJECT_ACCESS,
                          PCAIL_POSSIBLE_CONSTANT_ALLOCATION_IN_LOOP,
                          PL_PARALLEL_LISTS,
                          PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS,
                          S508C_NON_TRANSLATABLE_STRING,
                          SACM_STATIC_ARRAY_CREATED_IN_METHOD,
                          SEO_SUBOPTIMAL_EXPRESSION_ORDER,
                          SPP_TEMPORARY_TRIM,
                          STT_STRING_PARSING_A_FIELD,
                          UCPM_USE_CHARACTER_PARAMETERIZED_METHOD,
                          USBR_UNNECESSARY_STORE_BEFORE_RETURN,
                          UVA_USE_VAR_ARGS,
                          WEM_WEAK_EXCEPTION_MESSAGING" />
    </Match>

    

    <!-- Ignore DLS_DEAD_LOCAL_STORE for low confidence warnings
         Otherwise it will flag code like the following:
             for (String x : set)
                 count++;
    -->
    <Match>
        <BugPattern name="DLS_DEAD_LOCAL_STORE, UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" />
        <Confidence value="3" />
    </Match>

    <!--  ***********************************************************************  -->
    <!--  STDLIB.JAR EXCEPTIONS                                                    -->
    <!--  ***********************************************************************  -->

    <Match>
        <Class name = "~.*(Std)?Draw" />
        <BugPattern name="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD, DE_MIGHT_IGNORE" />
    </Match>

    <Match>
        <Class name = "~.*StdAudio" />
        <BugPattern name="DM_EXIT" />
    </Match>

    <Match>
        <Class name = "~.*In" />
        <BugPattern name="DMI_HARDCODED_ABSOLUTE_FILENAME" />
    </Match>

    <Match>
        <Class name = "~.*(In|StdIn)" />
        <BugPattern name="LEST_LOST_EXCEPTION_STACK_TRACE" />
    </Match>

    <Match>
        <Class name = "~.*(BinaryIn|BinaryOut|BinaryStdIn|BinaryStdOut)" />
        <BugPattern name="FCCD_FIND_CLASS_CIRCULAR_DEPENDENCY" />
    </Match>

    <Match>
        <Class name = "~.*(BinaryOut|BinaryStdOut|Draw|Out|Picture|StdAudio|StdDraw)" />
        <BugPattern name="IMC_IMMATURE_CLASS_PRINTSTACKTRACE" />
    </Match>

    <Match>
        <Class name = "~.*(Draw|StdDraw)" />
        <BugPattern name="MDM_THREAD_YIELD" />
    </Match>

    <!-- false positive -->
    <Match>
        <Class name = "~.*(StdRandom)" />
        <Method name="poisson" params="double" returns="int" />
        <BugPattern name="MRC_METHOD_RETURNS_CONSTANT" />
    </Match>


    <!--  ***********************************************************************  -->
    <!--  INTRO TO PROGRAMMING IN JAVA EXCEPTIONS                                  -->
    <!--  ***********************************************************************  -->

    <Match>
        <Class name = "~.*Bug.*" />
    </Match>

    <Match>
        <Class name = "Confusion" />
        <BugPattern name="SA_LOCAL_SELF_ASSIGNMENT, DLS_OVERWRITTEN_INCREMENT" />
    </Match>

    <!-- Double.valueOf() not introduced, so better to use Double.parseDouble()  -->
    <Match>
        <Class name = "Evaluate" />
        <BugPattern name="NAB_NEEDLESS_BOXING_VALUEOF" />
    </Match>

    <Match>
        <Class name = "PassByValue" />
        <BugPattern name="IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN" />
    </Match>

    <Match>
        <Class name = "ArrayExamples" />
        <BugPattern name="DMI_INVOKING_TOSTRING_ON_ARRAY" />
    </Match>

    <Match>
        <Class name = "PhoneNumber" />
        <BugPattern name="SA_LOCAL_SELF_COMPARISON" />
    </Match>

    <Match>
        <Class name = "HashCode" />
        <BugPattern name="ES_COMPARING_STRINGS_WITH_EQ,DM_STRING_CTOR" />
    </Match>

    <Match>
        <Class name = "~NoBaseCase|NoConvergence" />
        <BugPattern name="IL_INFINITE_RECURSIVE_LOOP" />
    </Match>

    <!-- Exclude Gaussian.Phi() test for floating-point equality. -->
    <Match>
        <Class name = "Gaussian" />
        <BugPattern name="FE_FLOATING_POINT_EQUALITY" />
    </Match>

    <!-- generating random integers before StdRandom.uniform() is introduced -->
    <Match>
        <Class name = "~Coupon|CouponCollector|TwentyQuestions|Craps|Functions|
                              |Mozart|Birthday|Birthdays|RollDie|SumOfTwoDice|
                              |RandomStudent|Sicherman|Chaos|DiscreteDistribution|
                              |MonteHall|MostLikelyRoll" />
        <BugPattern name="DM_NEXTINT_VIA_NEXTDOUBLE" />
    </Match>


    <!-- string concatenation before StringBuffer is introduced -->
    <Match>
        <Class name = "~RulerN|DigitReverser|Loops|LongestCommonSubsequence|
                              |ThueMorse|Ordinal|DeBruijn|Soundex|Repeat|
                              |Quote|CircularQuote" />
        <BugPattern name="SBSC_USE_STRINGBUFFER_CONCATENATION" />
    </Match>

    <!-- we are measuring side effect of elapsed time -->
    <Match>
        <Class name = "DoublingTest" />
        <BugPattern name="DLS_DEAD_LOCAL_STORE" />
    </Match>


    <!--  ***********************************************************************  -->
    <!--  ALGS4.JAR EXCEPTIONS                                                     -->
    <!--  ***********************************************************************  -->

    <!-- techincally, need (edu\.princeton\.cs\.algs4\.)? instead of .* for package version -->
    <Match>
        <Class name = "~.*(BellmanFordSP|DijkstraSP|DynamicProgrammingSP|UniqueMincut|
                                        |Hungarian|DijkstraUndirectedSP)" />
        <BugPattern name="FE_FLOATING_POINT_EQUALITY" />
    </Match>

    <Match>
        <Class name = "~.*Doubling.*" />
        <BugPattern name="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT,UC_USELESS_OBJECT" />
    </Match>

    <Match>
        <Class name = "~(Autoboxing|DualPivotQuicksort)" />
    </Match>

    <Match>
        <Class name = "~Mutable(String|Integer)" />
        <BugPattern name="DP_DO_INSIDE_DO_PRIVILEGED" />
    </Match>

    <Match>
        <Class name = "~AntiQuicksorter.*" />
        <BugPattern name="HE_EQUALS_USE_HASHCODE" />
    </Match>

    <Match>
        <Class name = "BrokenShuffle" />
        <BugPattern name="DM_NEXTINT_VIA_NEXTDOUBLE" />
    </Match>

    <Match>
        <Class name = "~.*RabinKarp" />
        <BugPattern name="UPM_UNCALLED_PRIVATE_METHOD" />
    </Match>

    <Match>
        <Class name = "CovariantPhoneNumber" />
        <BugPattern name="EQ_SELF_USE_OBJECT" />
    </Match>

    <Match>
        <Class name = "~.*MemoryOf.*" />
        <BugPattern name="DM_NUMBER_CTOR" />
    </Match>

    <Match>
        <Class name = "Concatenate" />
        <BugPattern name="SBSC_USE_STRINGBUFFER_CONCATENATION" />
    </Match>

    <Match>
        <Class name = "~(edu.princeton.cs.algs4.)?Student" />
        <BugPattern name="SA_LOCAL_SELF_COMPARISON, EC_UNRELATED_TYPES" />
    </Match>

    <Match>
        <Class name = "~(edu.princeton.cs.algs4.)?Person" />
        <BugPattern name="SA_LOCAL_SELF_COMPARISON" />
    </Match>

    <!-- These properly handle NaN and -0.0 -->
    <Match>
        <Class name = "~(edu.princeton.cs.algs4.)?(Transaction|Interval1D|Point2D).*" />
        <BugPattern name="FE_FLOATING_POINT_EQUALITY,CO_COMPARETO_INCORRECT_FLOATING" />
    </Match>

    <Match>
        <Class name = "~(edu.princeton.cs.algs4.)?(GaussJordanElimination|GaussianElimination)" />
        <BugPattern name="PZLA_PREFER_ZERO_LENGTH_ARRAYS" />
    </Match>

    <Match>
        <Class name = "~.*(SET)" />
        <BugPattern name="ITU_INAPPROPRIATE_TOSTRING_USE,OCP_OVERLY_CONCRETE_PARAMETER" />
    </Match>

    <Match>
        <Class name = "~.*((Index)?(Binomial|Fibonacci)(Min|Max)PQ)" />
        <BugPattern name="CFS_CONFUSING_FUNCTION_SEMANTICS" />
    </Match>


    <!--  ***********************************************************************  -->
    <!--  COS 126 PROGRAMMING ASSIGNMENT EXCEPTIONS                                -->
    <!--  ***********************************************************************  -->

    <!-- n will always be non-negative -->
    <Match>
        <Class name = "~(Checkerboard)(126)?" />
        <BugPattern name="IM_BAD_CHECK_FOR_ODD" />
    </Match>

    <!-- generating random integers before StdRandom.uniform() is introduced -->
    <Match>
        <Class name = "~(RollDice|TenDice|RandomWalker|RandomWalkers|Art)(126)?" />
        <BugPattern name="DM_NEXTINT_VIA_NEXTDOUBLE" />
    </Match>

    <!-- ok to return null in copy() if argument is null -->
    <Match>
        <Class name = "~(Transform2D)(126)?" />
        <Method name="copy" params="double[]" returns="double[]" />
        <BugPattern name="PZLA_PREFER_ZERO_LENGTH_ARRAYS" />
    </Match>

    <!-- string concatenation before StringBuffer is introduced -->
    <Match>
        <Class name = "~(LFSR)(126)?" />
        <BugPattern name="SBSC_USE_STRINGBUFFER_CONCATENATION" />
    </Match>
    <Match>
        <Class name = "~(RingBuffer)(126)?" />
        <Method name="toString" params="" returns="java.lang.String" />
        <BugPattern name="SBSC_USE_STRINGBUFFER_CONCATENATION" />
    </Match>
    <Match>
        <Class name = "~(MarkovModel)(126)?" />
        <Method name="main" />
        <BugPattern name="SBSC_USE_STRINGBUFFER_CONCATENATION" />
    </Match>


    <!--  ***********************************************************************  -->
    <!--  COS 226 / COURSERA PROGRAMMING ASSIGNMENT EXCEPTIONS                     -->
    <!--  ***********************************************************************  -->

    <!-- Exclude compare() by slope order in Point.java on collinear assignment -->
    <!-- It produces a warning even though it properly handles NaN              -->
    <Match>
        <Class name = "~Point.*(226)?" />
        <BugPattern name="CO_COMPARETO_INCORRECT_FLOATING" />
    </Match>

    <!-- Exclude compare() by slope order in Point.java on collinear assignment -->
    <!-- It produces a warning even though it properly handles NaN              -->
    <Match>
        <Class name = "~(LineSegment)(226)?" />
        <BugPattern name="HE_HASHCODE_USE_OBJECT_EQUALS" />
    </Match>

    <!-- slider puzzle, before we've introduced hashCode() -->
    <Match>
        <Class name = "~(Board)(226)?" />
        <BugPattern name="HE_EQUALS_USE_HASHCODE" />
    </Match>

    <!--  ***********************************************************************  -->
    <!--  AUTOGRADER                                                               -->
    <!--  ***********************************************************************  -->

    <!-- allow methods in *API to return null or false without complaints          -->
    <Match>
        <Class name = "~.*API" />
        <BugPattern name="PZLA_PREFER_ZERO_LENGTH_ARRAYS,
                          NP_TOSTRING_COULD_RETURN_NULL,
                          UP_UNUSED_PARAMETER,
                          MRC_METHOD_RETURNS_CONSTANT,
                          EQ_ALWAYS_FALSE" />
    </Match>

    <!-- allow methods to write to static instance variables ending in "count"     -->
    <!-- allow methods to store operation counts that are not currently used       -->
    <Match>
        <Field name = "~.*[Cc]ount" />
        <BugPattern name="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD,
                          URF_UNREAD_FIELD" />
    </Match>

    <Match>
        <Class name = "~.*TimingData" />
        <BugPattern name="FCBL_FIELD_COULD_BE_LOCAL" />
    </Match>

    <!-- allow methods to store values in variables with name "ignore"             -->
    <Match>
        <Local name = "~.*[Ii]gnore.*" />
        <BugPattern name="DLS_DEAD_LOCAL_STORE" />
    </Match>

    <Match>
        <Class name = "~ScreenPrimitiveContainer.*" />
        <BugPattern name="HE_EQUALS_USE_HASHCODE" />
    </Match>

    <Match>
        <Class name = "LineSegment" />
        <BugPattern name="HE_EQUALS_USE_HASHCODE" />
    </Match>


    <Match>
        <Class name = "~Test.*" />
        <Method name = "~extract.*" />
        <BugPattern name="PZLA_PREFER_ZERO_LENGTH_ARRAYS" />
    </Match>

    <Match>
        <Class name = "~(Test|Time).*" />
        <BugPattern name="EXS_EXCEPTION_SOFTENING_RETURN_FALSE,
                          RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE" />
    </Match>

    <!--  ***********************************************************************  -->
    <!--  JAVA MATRIX PACKAGE                                                      -->
    <!--  ***********************************************************************  -->
    <Match>
        <Class name = "~Jama\..*" />
    </Match>


</FindBugsFilter>
