Skip to content

Commit

Permalink
Merge pull request #84 from infinytum/master
Browse files Browse the repository at this point in the history
Partial Fix for #83 (Excluding Gocyclo)
  • Loading branch information
mum4k committed Jan 24, 2019
2 parents ecc5614 + 85b3189 commit 1e1dc15
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 39 deletions.
13 changes: 5 additions & 8 deletions draw/braille_line.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,13 @@ func brailleLinePoints(start, end image.Point) []image.Point {
if vertProj < horizProj {
if start.X > end.X {
return lineLow(end.X, end.Y, start.X, start.Y)
} else {
return lineLow(start.X, start.Y, end.X, end.Y)
}
} else {
if start.Y > end.Y {
return lineHigh(end.X, end.Y, start.X, start.Y)
} else {
return lineHigh(start.X, start.Y, end.X, end.Y)
}
return lineLow(start.X, start.Y, end.X, end.Y)
}
if start.Y > end.Y {
return lineHigh(end.X, end.Y, start.X, start.Y)
}
return lineHigh(start.X, start.Y, end.X, end.Y)
}

// lineLow returns points that create a line whose horizontal projection
Expand Down
5 changes: 2 additions & 3 deletions eventqueue/eventqueue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,12 @@ func TestPullBlocksUntilAvailable(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Millisecond)
defer cancel()

got, err := q.Pull(ctx)
if err == nil {
if _, err := q.Pull(ctx); err == nil {
t.Fatal("Pull => expected timeout error, got nil")
}

close(ch)
got, err = q.Pull(context.Background())
got, err := q.Pull(context.Background())
if err != nil {
t.Fatalf("Pull => unexpected error: %v", err)
}
Expand Down
33 changes: 7 additions & 26 deletions termdashdemo/termdashdemo.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,7 @@ func newTextTime(ctx context.Context) *text.Text {
go periodic(ctx, 1*time.Second, func() error {
t.Reset()
txt := time.Now().UTC().Format(time.UnixDate)
if err := t.Write(fmt.Sprintf("\n%s", txt), text.WriteCellOpts(cell.FgColor(cell.ColorMagenta))); err != nil {
return err
}
return nil
return t.Write(fmt.Sprintf("\n%s", txt), text.WriteCellOpts(cell.FgColor(cell.ColorMagenta)))
})
return t
}
Expand Down Expand Up @@ -226,10 +223,7 @@ func newSparkLines(ctx context.Context) (*sparkline.SparkLine, *sparkline.SparkL
const max = 100
go periodic(ctx, 250*time.Millisecond, func() error {
v := int(rand.Int31n(max + 1))
if err := spGreen.Add([]int{v}); err != nil {
return err
}
return nil
return spGreen.Add([]int{v})
})

spRed := sparkline.New(
Expand All @@ -238,10 +232,7 @@ func newSparkLines(ctx context.Context) (*sparkline.SparkLine, *sparkline.SparkL
)
go periodic(ctx, 500*time.Millisecond, func() error {
v := int(rand.Int31n(max + 1))
if err := spRed.Add([]int{v}); err != nil {
return err
}
return nil
return spRed.Add([]int{v})
})
return spGreen, spRed

Expand Down Expand Up @@ -308,15 +299,12 @@ func newHeartbeat(ctx context.Context) *linechart.LineChart {
step := 0
go periodic(ctx, redrawInterval/3, func() error {
step = (step + 1) % len(inputs)
if err := lc.Series("heartbeat", rotate(inputs, step),
return lc.Series("heartbeat", rotate(inputs, step),
linechart.SeriesCellOpts(cell.FgColor(cell.ColorNumber(87))),
linechart.SeriesXLabels(map[int]string{
0: "zero",
}),
); err != nil {
return err
}
return nil
)
})
return lc
}
Expand Down Expand Up @@ -353,10 +341,7 @@ func newBarChart(ctx context.Context) *barchart.BarChart {
values[i] = int(rand.Int31n(max + 1))
}

if err := bc.Values(values, max); err != nil {
return err
}
return nil
return bc.Values(values, max)
})
return bc
}
Expand Down Expand Up @@ -384,11 +369,7 @@ func newSines(ctx context.Context) *linechart.LineChart {
}

step2 := (step1 + 100) % len(inputs)
if err := lc.Series("second", rotate(inputs, step2), linechart.SeriesCellOpts(cell.FgColor(cell.ColorWhite))); err != nil {
return err
}

return nil
return lc.Series("second", rotate(inputs, step2), linechart.SeriesCellOpts(cell.FgColor(cell.ColorWhite)))
})
return lc
}
Expand Down
3 changes: 3 additions & 0 deletions widgets/linechart/axes/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ func rowLabel(scale *YScale, y int, labelWidth int) (*Label, error) {

ar := rowLabelArea(y, labelWidth)
pos, err := align.Text(ar, v.Text(), align.HorizontalRight, align.VerticalMiddle)
if err != nil {
return nil, fmt.Errorf("unable to align the label value: %v", err)
}
return &Label{
Value: v,
Pos: pos,
Expand Down
4 changes: 2 additions & 2 deletions widgets/linechart/linechart.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,12 @@ func (lc *LineChart) drawSeries(cvs *canvas.Canvas, xd *axes.XDetails, yd *axes.
return nil
}

// Implements widgetapi.Widget.Keyboard.
// Keyboard implements widgetapi.Widget.Keyboard.
func (lc *LineChart) Keyboard(k *terminalapi.Keyboard) error {
return errors.New("the LineChart widget doesn't support keyboard events")
}

// Implements widgetapi.Widget.Mouse.
// Mouse implements widgetapi.Widget.Mouse.
func (lc *LineChart) Mouse(m *terminalapi.Mouse) error {
return errors.New("the LineChart widget doesn't support mouse events")
}
Expand Down

0 comments on commit 1e1dc15

Please sign in to comment.