Merge pull request #1026 from gavin-ts/lint

lint for go 1.20
This commit is contained in:
gavin-ts 2023-03-14 18:21:38 -07:00 committed by GitHub
commit 6614000fe5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 100 additions and 92 deletions

View file

@ -355,13 +355,13 @@ func (sd *sequenceDiagram) placeActors() {
}
// addLifelineEdges adds a new edge for each actor in the graph that represents the its lifeline
// ┌──────────────┐
// │ actor │
// └──────┬───────┘
//
// │ lifeline
//
//
// . ┌──────────────┐
// . │ actor │
// . └──────┬───────┘
// .
// . │ lifeline
// .
// .
func (sd *sequenceDiagram) addLifelineEdges() {
endY := 0.
if len(sd.messages) > 0 {
@ -433,17 +433,17 @@ func (sd *sequenceDiagram) placeNotes() {
}
// placeSpans places spans over the object lifeline
// ┌──────────┐
// │ actor │
// └────┬─────┘
// ┌─┴──┐
// │ │
// |span|
// │ │
// └─┬──┘
//
// lifeline
//
// . ┌──────────┐
// . │ actor │
// . └────┬─────┘
// . ┌─┴──┐
// . │ │
// . |span|
// . │ │
// . └─┬──┘
// .
// . lifeline
// .
func (sd *sequenceDiagram) placeSpans() {
// quickly find the span center X
rankToX := make(map[int]float64)

View file

@ -102,6 +102,7 @@ func ParseValue(value string) (d2ast.Value, error) {
// - streaming parser isn't really helpful.
// - just read into a string even and decode runes forward/back as needed
// - the whole file essentially exists within the parser as the AST anyway...
//
// TODO: ast struct that combines map & errors and pass that around
type parser struct {
path string
@ -315,10 +316,12 @@ func (p *parser) commit() {
//
// TODO: make each parse function read its delimiter and return nil if not as expected
// TODO: lookahead *must* always be empty in between parse calls. you either commit or
//
// rewind in each function. if you don't, you pass a hint.
//
// TODO: omg we don't need two buffers, just a single lookahead and an index...
// TODO: get rid of lookaheadPos or at least never use directly. maybe rename to beforePeekPos?
//
// or better yet keep positions in the lookahead buffer.
// ok so plan here is to get rid of lookaheadPos and add a rewindPos that stores
// the pos to rewind to.

View file

@ -65,7 +65,7 @@ func (bc BezierCurve) At(point float64) *Point {
return NewPoint(float64(curvePoint.X), float64(curvePoint.Y))
}
//nolint
// nolint
func ComputeIntersections(px, py, lx, ly []float64) []*Point {
out := make([]*Point, 0)
@ -111,7 +111,7 @@ func ComputeIntersections(px, py, lx, ly []float64) []*Point {
return out
}
//nolint
// nolint
func cubicRoots(P []float64) []float64 {
if PrecisionCompare(P[0], 0, PRECISION) == 0 {
if PrecisionCompare(P[1], 0, PRECISION) == 0 {
@ -209,7 +209,7 @@ func cubicRoots(P []float64) []float64 {
return t
}
//nolint
// nolint
func sortSpecial(a []float64) []float64 {
var flip bool
var temp float64
@ -235,7 +235,7 @@ func sortSpecial(a []float64) []float64 {
return a
}
//nolint
// nolint
func sgn(x float64) float64 {
if x < 0.0 {
return -1
@ -243,7 +243,7 @@ func sgn(x float64) float64 {
return 1
}
//nolint
// nolint
func bezierCoeffs(P0, P1, P2, P3 float64) []float64 {
Z := make([]float64, 4)
Z[0] = -P0 + 3*P1 + -3*P2 + P3

View file

@ -55,24 +55,24 @@ func (segment Segment) Intersections(otherSegment Segment) []*Point {
// If there is no floor or ceiling, negative or positive infinity is used, respectively
// The direction is inferred, e.g. b/c the passed in segment is vertical, it's inferred we want horizontal bounds
// buffer says how close the segment can be, on both axes, to other segments given
// │ │
// │ │
// │ │
// │ │
// │ non-overlap
//
//
//
// │ segment
// │ │
// │ │ ceil
// │ │ │
// │ │
// floor │ │
//
//
//
//
// . │ │
// . │ │
// . │ │
// . │ │
// . │ non-overlap
// .
// .
// .
// . │ segment
// . │ │
// . │ │ ceil
// . │ │ │
// . │ │
// . floor │ │
// .
// .
// .
// .
// NOTE: the assumption is that all segments given are orthogonal
func (segment *Segment) GetBounds(segments []*Segment, buffer float64) (float64, float64) {
ceil := math.Inf(1)

View file

@ -175,22 +175,22 @@ func NewShape(shapeType string, box *geo.Box) Shape {
// p is the prev point (used to calculate slope)
// s is the point on the actual shape border that'll be returned
//
// p
//
//
//
// ┌────r─────────────────────────┐
// │ │
// │ │ │
// │ │ xxxxxxxx │
// │ ▼ xxxxx xxxx │
// │ sxxx xx │
// │ x xx │
// │ xx xx │
// │ x xx │
// │ xx xxx │
// │ xxxx xxxx │
// └──────xxxxxxxxxxxxxx──────────┘
// . p
// .
// .
// .
// . ┌────r─────────────────────────┐
// . │ │
// . │ │ │
// . │ │ xxxxxxxx │
// . │ ▼ xxxxx xxxx │
// . │ sxxx xx │
// . │ x xx │
// . │ xx xx │
// . │ x xx │
// . │ xx xxx │
// . │ xxxx xxxx │
// . └──────xxxxxxxxxxxxxx──────────┘
func TraceToShapeBorder(shape Shape, rectBorderPoint, prevPoint *geo.Point) *geo.Point {
if shape.Is("") || shape.IsRectangular() {
return rectBorderPoint

View file

@ -32,6 +32,7 @@ func init() {
// Ruler allows for effiecient and convenient text drawing.
//
// To create a Ruler object, use the New constructor:
//
// txt := text.New(pixel.ZV, text.NewAtlas(face, text.ASCII))
//
// As suggested by the constructor, a Ruler object is always associated with one font face and a
@ -39,15 +40,18 @@ func init() {
// contained in the face variable and is capable of drawing ASCII characters.
//
// Here we create a Ruler object which can draw ASCII and Katakana characters:
//
// txt := text.New(0, text.NewAtlas(face, text.ASCII, text.RangeTable(unicode.Katakana)))
//
// Similarly to IMDraw, Ruler functions as a buffer. It implements io.Writer interface, so writing
// text to it is really simple:
//
// fmt.Print(txt, "Hello, world!")
//
// Newlines, tabs and carriage returns are supported.
//
// Finally, if we want the written text to show up on some other Target, we can draw it:
//
// txt.Draw(target)
//
// Ruler exports two important fields: Orig and Dot. Dot is the position where the next character
@ -93,6 +97,7 @@ type Ruler struct {
// will be initially set to orig.
//
// Here we create a Ruler capable of drawing ASCII characters using the Go Regular font.
//
// ttf, err := truetype.Parse(goregular.TTF)
// if err != nil {
// panic(err)