mirror of
https://github.com/chylex/Code-Statistics.git
synced 2025-07-23 05:04:39 +02:00
Add Percent method to VariableUtils and update a call in JavaHandler
This commit is contained in:
parent
9c46d439de
commit
d8d3bcb068
CodeStatistics/Handling
@ -245,7 +245,7 @@ namespace CodeStatistics.Handling.Languages{
|
||||
variables.SetVariable("javaControlFlowCaseMin",state.GlobalInfo.MinSwitchCases);
|
||||
variables.SetVariable("javaControlFlowCaseMax",state.GlobalInfo.MaxSwitchCases);
|
||||
variables.Average("javaControlFlowCaseAvg","javaControlFlowCaseTotal","javaControlFlowSwitch");
|
||||
variables.SetVariable("javaControlFlowCaseDefaultPerc",(int)Math.Round(100.0*state.GlobalInfo.Statements[FlowStatement.SwitchDefault]/state.GlobalInfo.Statements[FlowStatement.Switch]));
|
||||
variables.Percent("javaControlFlowCaseDefaultPerc","javaControlFlowCaseDefaultTotal","javaControlFlowSwitch");
|
||||
}
|
||||
|
||||
protected override object GetFileObject(FileIntValue fi, Variables.Root variables){
|
||||
|
@ -7,6 +7,11 @@ namespace CodeStatistics.Handling.Utils{
|
||||
variables.SetVariable(targetName,avg >= roundingThreshold ? (int)Math.Round(avg) : avg);
|
||||
}
|
||||
|
||||
public static void Percent(this Variables.Root variables, string targetName, string totalValueName, string unitValueName){
|
||||
int val = (int)Math.Round(100.0*variables.GetVariable(totalValueName,0)/Math.Max(1,variables.GetVariable(unitValueName,1)));
|
||||
variables.SetVariable(targetName,val);
|
||||
}
|
||||
|
||||
public static void Minimum(this Variables.Root variables, string name, int nextValue){
|
||||
int currentValue = variables.GetVariable(name,int.MaxValue);
|
||||
if (nextValue < currentValue)variables.SetVariable(name,nextValue);
|
||||
|
Loading…
Reference in New Issue
Block a user