Skip to content

Commit 284590b

Browse files
fix
1 parent 1dfde02 commit 284590b

File tree

6 files changed

+19
-11
lines changed

6 files changed

+19
-11
lines changed

.mise.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ gotestsum = "latest"
66
description = "Create VSCode symlinks for tools not automatically handled by mise-vscode"
77
run = [
88
"mkdir -p .vscode/mise-tools",
9-
"ln -sf $(mise exec golangci-lint@2.5.0 -- which golangci-lint) .vscode/mise-tools/golangci-lint",
9+
"ln -sf $(mise exec golangci-lint@2.7.2 -- which golangci-lint) .vscode/mise-tools/golangci-lint",
1010
]
1111

1212
[hooks]
1313
postinstall = [
1414
"ln -sf ./AGENTS.md ./CLAUDE.md",
1515
"git submodule update --init --recursive",
16-
"mise exec [email protected] -- go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.5.0",
16+
"mise exec [email protected] -- go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.7.2",
1717
"mise run setup-vscode-symlinks",
1818
"go install go.uber.org/nilaway/cmd/nilaway@8ad05f0",
1919
]

mise-tasks/examples-check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if ! git diff --quiet openapi/README.md arazzo/README.md; then
1919
git diff openapi/README.md arazzo/README.md
2020
echo ""
2121
echo "💡 To fix this, run: mise run update-examples"
22-
echo " Then commit the updated README files."
22+
echo " Then stage/commit the updated README files."
2323
exit 1
2424
else
2525
echo "✅ All examples in README files are up to date!"

mise-tasks/lint

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ set -euo pipefail
33

44
echo "🔍 Running linting checks..."
55

6-
echo "🧹 Running golangci-lint (includes go vet)..."
6+
GOLANGCI_VERSION=$(golangci-lint --version | grep -oP 'golangci-lint has version \K[0-9.]+' || echo "unknown")
7+
echo "🧹 Running golangci-lint v${GOLANGCI_VERSION} (includes go vet)..."
78
golangci-lint run
89

910
echo "🛡️ Running nilaway..."

openapi/operation.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ func (o *Operation) GetExtensions() *extensions.Extensions {
151151
}
152152

153153
// IsDeprecated is an alias for GetDeprecated for backward compatibility.
154+
//
154155
// Deprecated: Use GetDeprecated instead for consistency with other models.
155156
func (o *Operation) IsDeprecated() bool {
156157
return o.GetDeprecated()

openapi/reference.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"strings"
78
"sync"
89

910
"github.com/speakeasy-api/openapi/internal/interfaces"
@@ -636,11 +637,13 @@ func joinReferenceChain(chain []string) string {
636637
return chain[0]
637638
}
638639

639-
result := chain[0]
640+
var result strings.Builder
641+
result.WriteString(chain[0])
640642
for i := 1; i < len(chain); i++ {
641-
result += " -> " + chain[i]
643+
result.WriteString(" -> ")
644+
result.WriteString(chain[i])
642645
}
643-
return result
646+
return result.String()
644647
}
645648

646649
func unmarshaler[T any, V interfaces.Validator[T], C marshaller.CoreModeler](_ *OpenAPI) func(context.Context, *yaml.Node, bool) (*Reference[T, V, C], []error, error) {

yml/config.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func inspectData(data []byte) (OutputFormat, int, IndentationStyle) {
187187
}
188188

189189
func getGlobalStringStyle(doc *yaml.Node, cfg *Config) {
190-
const minSamples = 3
190+
const minSamples = 5
191191

192192
keyStyles := make([]yaml.Style, 0, minSamples)
193193
valueStyles := make([]yaml.Style, 0, minSamples)
@@ -253,7 +253,8 @@ func looksLikeNumber(s string) bool {
253253
return err == nil
254254
}
255255

256-
// mostCommonStyle returns the most frequently occurring style from the provided styles
256+
// mostCommonStyle returns the most frequently occurring style from the provided styles.
257+
// In case of a tie, it returns the style that appears first in the slice for deterministic behavior.
257258
func mostCommonStyle(styles []yaml.Style) yaml.Style {
258259
if len(styles) == 0 {
259260
return 0
@@ -264,10 +265,12 @@ func mostCommonStyle(styles []yaml.Style) yaml.Style {
264265
counts[style]++
265266
}
266267

267-
// Find the style with the highest count
268+
// Find the style with the highest count by iterating through the original slice.
269+
// This ensures deterministic results when there are ties - the first occurrence wins.
268270
var maxCount int
269271
var mostCommon yaml.Style
270-
for style, count := range counts {
272+
for _, style := range styles {
273+
count := counts[style]
271274
if count > maxCount {
272275
maxCount = count
273276
mostCommon = style

0 commit comments

Comments
 (0)