MCPcopy Create free account
hub / github.com/openclaw/gogcli / ruleCoverage

Function ruleCoverage

internal/sheetsvalidation/copy.go:653–736  ·  view source on GitHub ↗
(
	segments []copySegment,
	startRow, endRow, startCol, endCol int64,
)

Source from the content-addressed store, hash-verified

651}
652
653func ruleCoverage(
654 segments []copySegment,
655 startRow, endRow, startCol, endCol int64,
656) (*sheets.BooleanCondition, string, bool) {
657 if endRow <= startRow || endCol <= startCol {
658 return nil, "", false
659 }
660 type interval struct {
661 start int64
662 end int64
663 key string
664 rule *sheets.DataValidationRule
665 }
666 expectedKey := ""
667 haveExpectedKey := false
668 var expectedCondition *sheets.BooleanCondition
669
670 for col := startCol; col < endCol; col++ {
671 intervals := make([]interval, 0)
672
673 for _, segment := range segments {
674 if col < segment.StartCol || col >= segment.EndCol {
675 continue
676 }
677 overlapStart := max(startRow, segment.StartRow)
678
679 overlapEnd := min(endRow, segment.EndRow)
680 if overlapEnd > overlapStart {
681 intervals = append(intervals, interval{
682 start: overlapStart,
683 end: overlapEnd,
684 key: segment.RuleKey,
685 rule: segment.Rule,
686 })
687 }
688 }
689
690 sort.Slice(intervals, func(i, j int) bool { return intervals[i].start < intervals[j].start })
691 cursor := startRow
692 ruleKey := ""
693 haveRuleKey := false
694 var condition *sheets.BooleanCondition
695
696 for _, item := range intervals {
697 if item.start > cursor {
698 return nil, "", false
699 }
700
701 if item.end <= cursor {
702 continue
703 }
704
705 if !haveRuleKey {
706 ruleKey = item.key
707 haveRuleKey = true
708
709 if item.rule != nil {
710 condition = item.rule.Condition

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected