mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
Fix linter warnings about ignoring errors from bufio.Scanner
This commit is contained in:
parent
562d0541a1
commit
8dbdd74400
|
|
@ -79,6 +79,10 @@ func (self *SubmoduleCommands) GetConfigs(parentModule *models.SubmoduleConfig)
|
|||
}
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return configs, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -392,6 +392,10 @@ func (self *cmdObjRunner) processOutput(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
self.log.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
// having a function that returns a function because we need to maintain some state inbetween calls hence the closure
|
||||
|
|
|
|||
|
|
@ -93,11 +93,11 @@ func FileHasConflictMarkers(path string) (bool, error) {
|
|||
|
||||
defer file.Close()
|
||||
|
||||
return fileHasConflictMarkersAux(file), nil
|
||||
return fileHasConflictMarkersAux(file)
|
||||
}
|
||||
|
||||
// Efficiently scans through a file looking for merge conflict markers. Returns true if it does
|
||||
func fileHasConflictMarkersAux(file io.Reader) bool {
|
||||
func fileHasConflictMarkersAux(file io.Reader) (bool, error) {
|
||||
scanner := bufio.NewScanner(file)
|
||||
scanner.Split(utils.ScanLinesAndTruncateWhenLongerThanBuffer(bufio.MaxScanTokenSize))
|
||||
for scanner.Scan() {
|
||||
|
|
@ -105,13 +105,13 @@ func fileHasConflictMarkersAux(file io.Reader) bool {
|
|||
|
||||
// only searching for start/end markers because the others are more ambiguous
|
||||
if bytes.HasPrefix(line, CONFLICT_START_BYTES) {
|
||||
return true
|
||||
return true, nil
|
||||
}
|
||||
|
||||
if bytes.HasPrefix(line, CONFLICT_END_BYTES) {
|
||||
return true
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
return false, scanner.Err()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,6 +96,8 @@ func TestFindConflictsAux(t *testing.T) {
|
|||
|
||||
for _, s := range scenarios {
|
||||
reader := strings.NewReader(s.content)
|
||||
assert.EqualValues(t, s.expected, fileHasConflictMarkersAux(reader))
|
||||
result, err := fileHasConflictMarkersAux(reader)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, s.expected, result)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,9 @@ func tailFrom(lastOffset int64, logFilePath string, opts *humanlog.HandlerOption
|
|||
lines = append(lines, fileScanner.Text())
|
||||
}
|
||||
file.Close()
|
||||
if err := fileScanner.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
lineCount := len(lines)
|
||||
lastTen := lines
|
||||
if lineCount > 10 {
|
||||
|
|
|
|||
|
|
@ -210,6 +210,10 @@ func (self *ViewBufferManager) NewCmdTask(start func() (*exec.Cmd, io.Reader), p
|
|||
<-lineWrittenChan
|
||||
}
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
self.Log.Error(err)
|
||||
}
|
||||
})
|
||||
|
||||
loaded := false
|
||||
|
|
|
|||
Loading…
Reference in a new issue