Skip to content

Commit 772285d

Browse files
authoredNov 16, 2024
fix: change URL to the page with rules descriptions (#1129)
1 parent 3378f70 commit 772285d

File tree

7 files changed

+19
-14
lines changed

7 files changed

+19
-14
lines changed
 

‎formatter/default.go

+4
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ func (*Default) Format(failures <-chan lint.Failure, _ lint.Config) (string, err
2626
}
2727
return buf.String(), nil
2828
}
29+
30+
func ruleDescriptionURL(ruleName string) string {
31+
return "https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#" + ruleName
32+
}

‎formatter/formatter_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func TestFormatter(t *testing.T) {
5050
{
5151
formatter: &formatter.Friendly{},
5252
want: `
53-
⚠ https://revive.run/r#rule test failure
53+
⚠ https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#rule test failure
5454
test.go:2:5
5555
5656
⚠ 1 problem (0 errors, 1 warning)
@@ -69,7 +69,7 @@ Warnings:
6969
},
7070
{
7171
formatter: &formatter.Plain{},
72-
want: `test.go:2:5: test failure https://revive.run/r#rule`,
72+
want: `test.go:2:5: test failure https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#rule`,
7373
},
7474
{
7575
formatter: &formatter.Sarif{},
@@ -100,7 +100,7 @@ Warnings:
100100
],
101101
"tool": {
102102
"driver": {
103-
"informationUri": "https://revive.run",
103+
"informationUri": "https://github.com/mgechev/revive",
104104
"name": "revive"
105105
}
106106
}
@@ -114,7 +114,7 @@ Warnings:
114114
formatter: &formatter.Stylish{},
115115
want: `
116116
test.go
117-
(2, 5) https://revive.run/r#rule test failure
117+
(2, 5) https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#rule test failure
118118
119119
120120
✖ 1 problem (0 errors) (1 warnings)

‎formatter/friendly.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (f *Friendly) printHeaderRow(w io.Writer, failure lint.Failure, severity li
6767
if severity == lint.SeverityError {
6868
emoji = getErrorEmoji()
6969
}
70-
fmt.Fprint(w, f.table([][]string{{emoji, "https://revive.run/r#" + failure.RuleName, color.GreenString(failure.Failure)}}))
70+
fmt.Fprint(w, f.table([][]string{{emoji, ruleDescriptionURL(failure.RuleName), color.GreenString(failure.Failure)}}))
7171
}
7272

7373
func (*Friendly) printFilePosition(w io.Writer, failure lint.Failure) {

‎formatter/plain.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func (*Plain) Name() string {
2222
func (*Plain) Format(failures <-chan lint.Failure, _ lint.Config) (string, error) {
2323
var buf bytes.Buffer
2424
for failure := range failures {
25-
fmt.Fprintf(&buf, "%v: %s %s\n", failure.Position.Start, failure.Failure, "https://revive.run/r#"+failure.RuleName)
25+
fmt.Fprintf(&buf, "%v: %s %s\n", failure.Position.Start, failure.Failure, ruleDescriptionURL(failure.RuleName))
2626
}
2727
return buf.String(), nil
2828
}

‎formatter/sarif.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func (*Sarif) Name() string {
2020
return "sarif"
2121
}
2222

23-
const reviveSite = "https://revive.run"
23+
const reviveSite = "https://github.com/mgechev/revive"
2424

2525
// Format formats the failures gotten from the lint.
2626
func (*Sarif) Format(failures <-chan lint.Failure, cfg lint.Config) (string, error) {

‎formatter/stylish.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ func (*Stylish) Name() string {
2222

2323
func formatFailure(failure lint.Failure, severity lint.Severity) []string {
2424
fString := color.CyanString(failure.Failure)
25-
fName := color.RedString("https://revive.run/r#" + failure.RuleName)
25+
fURL := ruleDescriptionURL(failure.RuleName)
26+
fName := color.RedString(fURL)
2627
lineColumn := failure.Position
2728
pos := fmt.Sprintf("(%d, %d)", lineColumn.Start.Line, lineColumn.Start.Column)
2829
if severity == lint.SeverityWarning {
29-
fName = color.YellowString("https://revive.run/r#" + failure.RuleName)
30+
fName = color.YellowString(fURL)
3031
}
3132
return []string{failure.GetFilename(), pos, fName, fString}
3233
}

‎revivelib/core_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ func TestReviveFormat(t *testing.T) {
5454
}
5555

5656
errorMsgs := []string{
57-
"(91, 3) https://revive.run/r#unreachable-code unreachable code after this statement",
58-
"(98, 3) https://revive.run/r#unreachable-code unreachable code after this statement",
59-
"(15, 2) https://revive.run/r#if-return redundant if ...; err != nil check, just return error instead.",
60-
"(88, 3) https://revive.run/r#if-return redundant if ...; err != nil check, just return error instead.",
61-
"(95, 3) https://revive.run/r#if-return redundant if ...; err != nil check, just return error instead.",
57+
"(91, 3) https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unreachable-code unreachable code after this statement",
58+
"(98, 3) https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unreachable-code unreachable code after this statement",
59+
"(15, 2) https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#if-return redundant if ...; err != nil check, just return error instead.",
60+
"(88, 3) https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#if-return redundant if ...; err != nil check, just return error instead.",
61+
"(95, 3) https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#if-return redundant if ...; err != nil check, just return error instead.",
6262
}
6363
for _, errorMsg := range errorMsgs {
6464
if !strings.Contains(failures, errorMsg) {

0 commit comments

Comments
 (0)