public int computePriority ( int basePriority ) { boolean relaxedReporting = FindBugsAnalysisFeatures . isRelaxedMode ( ) ; boolean atLeastMedium = false ; boolean falsePositive = false ; boolean atMostLow = false ; boolean atMostMedium = false ; boolean peggedHigh = false ; int aLittleBitLower = 0 ; int priority = basePriority ; if ( ! relaxedReporting ) { for ( T warningProperty : map . keySet ( ) ) { PriorityAdjustment adj = warningProperty . getPriorityAdjustment ( ) ; if ( adj == PriorityAdjustment . PEGGED_HIGH ) { peggedHigh = true ; priority -- ; } else if ( adj == PriorityAdjustment . FALSE_POSITIVE ) { falsePositive = true ; atMostLow = true ; } else if ( adj == PriorityAdjustment . A_LITTLE_BIT_LOWER_PRIORITY ) { aLittleBitLower ++ ; } else if ( adj == PriorityAdjustment . A_LITTLE_BIT_HIGHER_PRIORITY ) { aLittleBitLower -- ; } else if ( adj == PriorityAdjustment . RAISE_PRIORITY ) { -- priority ; } else if ( adj == PriorityAdjustment . RAISE_PRIORITY_TO_AT_LEAST_NORMAL ) { -- priority ; atLeastMedium = true ; } else if ( adj == PriorityAdjustment . LOWER_PRIORITY_TO_AT_MOST_NORMAL ) { ++ priority ; atMostMedium = true ; } else if ( adj == PriorityAdjustment . RAISE_PRIORITY_TO_HIGH ) { return Priorities . HIGH_PRIORITY ; } else if ( adj == PriorityAdjustment . LOWER_PRIORITY ) { ++ priority ; } else if ( adj == PriorityAdjustment . AT_MOST_LOW ) { priority ++ ; atMostLow = true ; } else if ( adj == PriorityAdjustment . AT_MOST_MEDIUM ) { atMostMedium = true ; } else if ( adj == PriorityAdjustment . NO_ADJUSTMENT ) { assert true ; // do nothing } else { throw new IllegalStateException ( "Unknown priority " + adj ) ; } } if ( peggedHigh && ! falsePositive ) { return Priorities . HIGH_PRIORITY ; } if ( aLittleBitLower >= 3 || priority == 1 && aLittleBitLower == 2 ) { priority ++ ; } else if ( aLittleBitLower <= - 2 ) { priority -- ; } if ( atMostMedium ) { priority = Math . max ( Priorities . NORMAL_PRIORITY , priority ) ; } if ( falsePositive && ! atLeastMedium ) { return Priorities . EXP_PRIORITY + 1 ; } else if ( atMostLow ) { return Math . min ( Math . max ( Priorities . LOW_PRIORITY , priority ) , Priorities . EXP_PRIORITY ) ; } if ( atLeastMedium && priority > Priorities . NORMAL_PRIORITY ) { priority = Priorities . NORMAL_PRIORITY ; } if ( priority < Priorities . HIGH_PRIORITY ) { priority = Priorities . HIGH_PRIORITY ; } else if ( priority > Priorities . EXP_PRIORITY ) { priority = Priorities . EXP_PRIORITY ; } } return priority ; }
Use the PriorityAdjustments specified by the set s WarningProperty elements to compute a warning priority from the given base priority .