From 148ddcbeb13719c86ba1f0cbe0e95b81eaa77fdb Mon Sep 17 00:00:00 2001 From: domi41 Date: Fri, 9 Jul 2021 17:56:37 +0200 Subject: [PATCH] refacto: remove **some** of the disgusting int type casting The line was too long anyway, it's best to have an intermediate variable --- judgment/majorityjudgment.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/judgment/majorityjudgment.go b/judgment/majorityjudgment.go index 3629599..4f97641 100644 --- a/judgment/majorityjudgment.go +++ b/judgment/majorityjudgment.go @@ -105,11 +105,17 @@ func (mj *MajorityJudgment) ComputeScore(tally *ProposalTally, favorContestation for i := uint8(0); i < amountOfGrades; i++ { analysis.Run(mutatedTally, favorContestation) score += fmt.Sprintf("%0"+fmt.Sprintf("%d", amountOfDigitsForGrade)+"d", analysis.MedianGrade) - // fixme: BAD → uint64 to int conversion — either move to int everywhere, or use whatever bigint Go has - score += fmt.Sprintf("%0"+fmt.Sprintf("%d", amountOfDigitsForAdhesionScore)+"d", int(amountOfJudgments)+int(analysis.SecondGroupSize)*analysis.SecondGroupSign) + //adhesionScore := amountOfJudgments) + analysis.SecondGroupSize * analysis.SecondGroupSign + adhesionScore := amountOfJudgments + if analysis.SecondGroupSign > 0 { + adhesionScore = adhesionScore + analysis.SecondGroupSize + } else if analysis.SecondGroupSign < 0 { + adhesionScore = adhesionScore - analysis.SecondGroupSize + } + score += fmt.Sprintf("%0"+fmt.Sprintf("%d", amountOfDigitsForAdhesionScore)+"d", adhesionScore) regradingErr := mutatedTally.RegradeJudgments(analysis.MedianGrade, analysis.SecondMedianGrade) if nil != regradingErr { - return "", regradingErr // 仕方がない + return "", regradingErr // 仕方がない – C'est la vie ! (see issue #4) } }