grokify/mogo

View on GitHub
time/timeutil/time_range.go

Summary

Maintainability
B
5 hrs
Test Coverage

Function ParseTimeRangeInterval has 70 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func ParseTimeRangeInterval(s string) (TimeRange, error) {
    s1 := strings.ToUpper(strings.TrimSpace(s))
    m := rxParseTimeRange.FindStringSubmatch(s1)
    if len(m) == 0 {
        return TimeRange{}, fmt.Errorf("cannot parse time range rx (%s)", s)
Severity: Minor
Found in time/timeutil/time_range.go - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

        if (incStart && needle.Before(rangeStart)) ||
            (needle.Before(rangeStart) || needle.Equal(rangeStart)) ||
            (incEnd && needle.After(rangeEnd)) ||
            (needle.After(rangeEnd) || needle.Equal(rangeEnd)) {
    Severity: Critical
    Found in time/timeutil/time_range.go - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

          if t.Before(tr.Min) || t.After(tr.Max) ||
              (!inclusiveMin && t.Equal(tr.Min)) ||
              (!inclusiveMax && t.Equal(tr.Max)) {
      Severity: Major
      Found in time/timeutil/time_range.go - About 40 mins to fix

        Function ParseTimeRangeInterval has 5 return statements (exceeds 4 allowed).
        Open

        func ParseTimeRangeInterval(s string) (TimeRange, error) {
            s1 := strings.ToUpper(strings.TrimSpace(s))
            m := rxParseTimeRange.FindStringSubmatch(s1)
            if len(m) == 0 {
                return TimeRange{}, fmt.Errorf("cannot parse time range rx (%s)", s)
        Severity: Major
        Found in time/timeutil/time_range.go - About 35 mins to fix

          Method TimeRange.IntersectionDuration has 5 return statements (exceeds 4 allowed).
          Open

          func (tr *TimeRange) IntersectionDuration(tr2 TimeRange) time.Duration {
              tr.Normalize()
              tr2.Normalize()
              if tr2.Min.After(tr.Max) || tr2.Max.Before(tr.Min) {
                  // No overlap
          Severity: Major
          Found in time/timeutil/time_range.go - About 35 mins to fix

            There are no issues that match your filters.

            Category
            Status