示例#1
0
文件: code.go 项目: frankMilde/rol
func PercentOfLinesOverLimit(s string) float64 {
	if s == "" {
		return 0.
	}
	x := float64(LinesAboveTextWidthLimit(s))
	y := float64(strmult.TotalLines(s))
	return x / y
}
示例#2
0
文件: code.go 项目: frankMilde/rol
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)
}