Beispiel #1
0
func PercentOfLinesOverLimit(s string) float64 {
	if s == "" {
		return 0.
	}
	x := float64(LinesAboveTextWidthLimit(s))
	y := float64(strmult.TotalLines(s))
	return x / y
}
Beispiel #2
0
func codeShouldHaveFullPageWidth(codeText string) bool {

	codeHasSingleLine := strmult.TotalLines(codeText) == 1
	oneLineBreaksThreeTimes := moreThanXPercentOfLinesOverLimit(2.0, codeText)

	if codeHasSingleLine {
		if oneLineBreaksThreeTimes {
			return true
		} else {
			return false
		}
	}

	moreThanAQuarterOfLinesAreOverLimit := moreThanXPercentOfLinesOverLimit(0.25, codeText)
	codeHasMoreThan4Lines := strmult.TotalLines(codeText) > 4
	allLinesAreOverLimit := moreThanXPercentOfLinesOverLimit(1.0, codeText)

	return moreThanAQuarterOfLinesAreOverLimit && (codeHasMoreThan4Lines || allLinesAreOverLimit)
}