@@ -39,13 +39,13 @@ type Checker struct {
39
39
// If not set, current working directory is used.
40
40
AbsPath string
41
41
42
- // Calculated changes for next calls to IsNewIssue
42
+ // Calculated changes for next calls to [Checker. IsNewIssue]/[Checker.IsNew].
43
43
changes map [string ][]pos
44
44
}
45
45
46
46
// Prepare extracts a patch and changed lines.
47
47
//
48
- // WARNING: it should only be used before an explicit call to [Checker.IsNewIssue].
48
+ // WARNING: it should only be used before an explicit call to [Checker.IsNewIssue]/[Checker.IsNew] .
49
49
//
50
50
// WARNING: only [Checker.Patch], [Checker.RevisionFrom], [Checker.RevisionTo], [Checker.WholeFiles] options are used,
51
51
// the other options ([Checker.Regexp], [Checker.AbsPath]) are only used by [Checker.Check].
@@ -57,18 +57,18 @@ func (c *Checker) Prepare(ctx context.Context) error {
57
57
return err
58
58
}
59
59
60
- // IsNewIssue checks whether issue found by linter is new: it was found in changed lines.
60
+ // IsNew checks whether issue found by linter is new: it was found in changed lines.
61
61
//
62
62
// WARNING: it requires to call [Checker.Prepare] before call this method to load the changes from patch.
63
- func (c * Checker ) IsNewIssue ( i InputIssue ) (hunkPos int , isNew bool ) {
64
- changes , ok := c .changes [filepath .ToSlash (i . FilePath () )]
63
+ func (c * Checker ) IsNew ( filePath string , line int ) (hunkPos int , isNew bool ) {
64
+ changes , ok := c .changes [filepath .ToSlash (filePath )]
65
65
if ! ok {
66
66
// file wasn't changed
67
67
return 0 , false
68
68
}
69
69
70
70
if c .WholeFiles {
71
- return i . Line () , true
71
+ return line , true
72
72
}
73
73
74
74
var (
@@ -78,7 +78,7 @@ func (c *Checker) IsNewIssue(i InputIssue) (hunkPos int, isNew bool) {
78
78
79
79
// found file, see if lines matched
80
80
for _ , pos := range changes {
81
- if pos .lineNo == i . Line () {
81
+ if pos .lineNo == line {
82
82
fpos = pos
83
83
changed = true
84
84
@@ -101,6 +101,13 @@ func (c *Checker) IsNewIssue(i InputIssue) (hunkPos int, isNew bool) {
101
101
return 0 , false
102
102
}
103
103
104
+ // IsNewIssue checks whether issue found by linter is new: it was found in changed lines.
105
+ //
106
+ // WARNING: it requires to call [Checker.Prepare] before call this method to load the changes from patch.
107
+ func (c * Checker ) IsNewIssue (i InputIssue ) (hunkPos int , isNew bool ) {
108
+ return c .IsNew (i .FilePath (), i .Line ())
109
+ }
110
+
104
111
// Check scans reader and writes any lines to writer that have been added in [Checker.Patch].
105
112
//
106
113
// Returns the issues written to writer when no error occurs.
0 commit comments