mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-16 22:07:09 +09:00
Fix quality issues (#1856)
* Add .deepsource.toml * Remove unnecessary comparison with bool * Remove unnecessary use of slice * Replace multiple `append`s with one * Remove unnecessary wrapping of function call * Fix check for empty string * Simplify error creation with `fmt.Errorf` * Fix defers before error check Signed-off-by: sourya_deepsource <sourya@deepsource.io> * Remove untrappable `os.Kill` signal Signed-off-by: sourya_deepsource <sourya@deepsource.io> * Remove empty else branch Signed-off-by: sourya_deepsource <sourya@deepsource.io> * Add missing error check Signed-off-by: sourya_deepsource <sourya@deepsource.io> * Merge variable declaration and assignment Signed-off-by: sourya_deepsource <sourya@deepsource.io> * Remove unnecessary `nil` check Signed-off-by: sourya_deepsource <sourya@deepsource.io> * Revert changes to generated files Signed-off-by: sourya_deepsource <sourya@deepsource.io> * Remove .deepsource.toml Signed-off-by: sourya_deepsource <sourya@deepsource.io> Co-authored-by: DeepSource Bot <bot@deepsource.io> Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
This commit is contained in:
@@ -54,8 +54,6 @@ func (b *Buffer) CycleAutocomplete(forward bool) {
|
||||
end := c.Loc
|
||||
if prevSuggestion < len(b.Suggestions) && prevSuggestion >= 0 {
|
||||
start = end.Move(-util.CharacterCountInString(b.Completions[prevSuggestion]), b)
|
||||
} else {
|
||||
// end = start.Move(1, b)
|
||||
}
|
||||
|
||||
b.Replace(start, end, b.Completions[b.CurSuggestion])
|
||||
|
||||
@@ -69,7 +69,7 @@ func (b *Buffer) Backup() error {
|
||||
}
|
||||
|
||||
backupdir, err := util.ReplaceHome(b.Settings["backupdir"].(string))
|
||||
if len(backupdir) == 0 || err != nil {
|
||||
if backupdir == "" || err != nil {
|
||||
backupdir = filepath.Join(config.ConfigDir, "backups")
|
||||
}
|
||||
if _, err := os.Stat(backupdir); os.IsNotExist(err) {
|
||||
|
||||
@@ -610,6 +610,9 @@ func (b *Buffer) UpdateRules() {
|
||||
}
|
||||
|
||||
header, err = highlight.MakeHeaderYaml(data)
|
||||
if err != nil {
|
||||
screen.TermMessage("Error parsing header for syntax file " + f.Name() + ": " + err.Error())
|
||||
}
|
||||
file, err := highlight.ParseFile(data)
|
||||
if err != nil {
|
||||
screen.TermMessage("Error parsing syntax file " + f.Name() + ": " + err.Error())
|
||||
|
||||
@@ -130,7 +130,7 @@ func NewLineArray(size uint64, endings FileFormat, reader io.Reader) *LineArray
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
la.lines = Append(la.lines, Line{
|
||||
data: data[:],
|
||||
data: data,
|
||||
state: nil,
|
||||
match: nil,
|
||||
rehighlight: false,
|
||||
|
||||
@@ -51,8 +51,8 @@ func (b *Buffer) Unserialize() error {
|
||||
return nil
|
||||
}
|
||||
file, err := os.Open(filepath.Join(config.ConfigDir, "buffers", util.EscapePath(b.AbsPath)))
|
||||
defer file.Close()
|
||||
if err == nil {
|
||||
defer file.Close()
|
||||
var buffer SerializedBuffer
|
||||
decoder := gob.NewDecoder(file)
|
||||
err = decoder.Decode(&buffer)
|
||||
|
||||
Reference in New Issue
Block a user