<?xml version="1.0"?>
<!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You 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.
-->

<!--
  This file contains some false positive bugs detected by spotbugs. Their
  false positive nature has been analyzed individually and they have been
  put here to instruct spotbugs it must ignore them.
-->
<FindBugsFilter
    xmlns="https://github.com/spotbugs/filter/3.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd">

  <Match>
    <Class name="~.*\.jmh\..*generated\..*" />
  </Match>

  <Match>
    <Class name="org.apache.commons.statistics.distribution.SaddlePointExpansionUtils" />
    <Or>
      <Method name="getStirlingError" />
      <Method name="getDeviancePart" />
    </Or>
    <Bug pattern="FE_FLOATING_POINT_EQUALITY" />
  </Match>
  <Match>
    <Class name="org.apache.commons.statistics.distribution.TrapezoidalDistribution" />
    <Method name="of" />
    <Bug pattern="FE_FLOATING_POINT_EQUALITY" />
  </Match>

  <Match>
    <Class name="org.apache.commons.statistics.distribution.AbstractContinuousDistribution$BrentSolver" />
    <Method name="brent" />
    <Bug pattern="FE_FLOATING_POINT_EQUALITY" />
  </Match>

  <!-- Rounding double-double requires comparison to 0.5 -->
  <Match>
    <Class name="org.apache.commons.statistics.descriptive.Interpolation" />
    <Method name="interpolate" />
    <Bug pattern="FE_FLOATING_POINT_EQUALITY" />
  </Match>

  <Match>
    <Class name="org.apache.commons.statistics.inference.UnconditionedExactTest" />
    <Or>
      <Method name="findExtremeTablesZ" />
      <Method name="statisticZ" />
    </Or>
    <Bug pattern="FE_FLOATING_POINT_EQUALITY" />
  </Match>

  <!-- Intentional use of floating-point loop counters -->
  <Match>
    <Class name="org.apache.commons.statistics.distribution.AbstractContinuousDistribution" />
    <Method name="searchPlateau" />
    <Bug pattern="FL_FLOATS_AS_LOOP_COUNTERS" />
  </Match>
  <Match>
    <Class name="org.apache.commons.statistics.distribution.SaddlePointExpansionUtils" />
    <Method name="getDeviancePart" />
    <Bug pattern="FL_FLOATS_AS_LOOP_COUNTERS" />
  </Match>
  <Match>
    <Class name="org.apache.commons.statistics.distribution.TruncatedNormalDistribution" />
    <Method name="lambda$createSampler$2" />
    <Bug pattern="FL_FLOATS_AS_LOOP_COUNTERS" />
  </Match>
  <Match>
    <Class name="org.apache.commons.statistics.distribution.HypergeometricDistribution" />
    <Method name="getMidPoint" />
    <Bug pattern="FL_FLOATS_AS_LOOP_COUNTERS" />
  </Match>
  <!-- Same logic as above distribution is used in the internal helper class constructor -->
  <Match>
    <Class name="org.apache.commons.statistics.inference.Hypergeom" />
    <Method name="&lt;init&gt;" />
    <Bug pattern="FL_FLOATS_AS_LOOP_COUNTERS" />
  </Match>

  <Match>
    <Class name="org.apache.commons.statistics.ranking.NaturalRanking$DataPosition" />
    <Bug pattern="EQ_COMPARETO_USE_OBJECT_EQUALS" />
  </Match>

  <!-- False positive of static method returning an immutable instance -->
  <Match>
    <Class name="org.apache.commons.statistics.inference.UnconditionedExactTest" />
    <Bug pattern="MS_EXPOSE_REP" />
  </Match>

  <!-- False positive -->
  <Match>
    <Class name="org.apache.commons.statistics.inference.UnconditionedExactTest" />
    <Method name="computePValue" />
    <Bug pattern="DLS_DEAD_LOCAL_STORE" />
  </Match>

</FindBugsFilter>
