Skip to content

Commit 94e8bf8

Browse files
Ajit Pratap SinghAjit Pratap Singh
authored andcommitted
fix: correct string conversion in long lines rule suggestion
- Replace string(rune()) with fmt.Sprintf for proper integer formatting - Fixes garbled output in violation messages (e.g., '{ chars' instead of '123 chars') - Addresses critical bug identified in PR #111 code review - Tested with 118-char line, now displays 'current: 118 chars, max: 100'
1 parent 8b78fe1 commit 94e8bf8

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

pkg/linter/rules/whitespace/long_lines.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package whitespace
22

33
import (
4+
"fmt"
45
"strings"
56

67
"github.com/ajitpratap0/GoSQLX/pkg/linter"
@@ -51,17 +52,13 @@ func (r *LongLinesRule) Check(ctx *linter.Context) ([]linter.Violation, error) {
5152

5253
if lineLength > r.MaxLength {
5354
violations = append(violations, linter.Violation{
54-
Rule: r.ID(),
55-
RuleName: r.Name(),
56-
Severity: r.Severity(),
57-
Message: "Line exceeds maximum length",
58-
Location: models.Location{Line: lineNum + 1, Column: r.MaxLength + 1},
59-
Line: line,
60-
Suggestion: func() string {
61-
return "Split this line into multiple lines (current: " +
62-
string(rune(lineLength)) + " chars, max: " +
63-
string(rune(r.MaxLength)) + ")"
64-
}(),
55+
Rule: r.ID(),
56+
RuleName: r.Name(),
57+
Severity: r.Severity(),
58+
Message: "Line exceeds maximum length",
59+
Location: models.Location{Line: lineNum + 1, Column: r.MaxLength + 1},
60+
Line: line,
61+
Suggestion: fmt.Sprintf("Split this line into multiple lines (current: %d chars, max: %d)", lineLength, r.MaxLength),
6562
CanAutoFix: false,
6663
})
6764
}

0 commit comments

Comments
 (0)