From 043f7cdc47cc820369143d0ac1c1dab4b1d0ead2 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Tue, 21 Feb 2017 13:07:37 -0500 Subject: [PATCH] Fix various linter and vet warnings --- cmd/micro/actions.go | 9 +++++---- cmd/micro/autocomplete.go | 2 +- cmd/micro/bindings.go | 2 +- cmd/micro/lineArray.go | 2 +- cmd/micro/plugin.go | 2 +- cmd/micro/split_tree.go | 2 +- cmd/micro/tab.go | 22 +++++++++++----------- tools/info-plist.go | 38 +++++++++++++++++++------------------- 8 files changed, 40 insertions(+), 39 deletions(-) diff --git a/cmd/micro/actions.go b/cmd/micro/actions.go index 5e7c52ac..4f2411ac 100644 --- a/cmd/micro/actions.go +++ b/cmd/micro/actions.go @@ -464,7 +464,7 @@ func (v *View) InsertNewline(usePlugin bool) bool { } // Remove the whitespaces if keepautoindent setting is off - if IsSpacesOrTabs(v.Buf.Line(v.Cursor.Y - 1)) && !v.Buf.Settings["keepautoindent"].(bool) { + if IsSpacesOrTabs(v.Buf.Line(v.Cursor.Y-1)) && !v.Buf.Settings["keepautoindent"].(bool) { line := v.Buf.Line(v.Cursor.Y - 1) v.Buf.Remove(Loc{0, v.Cursor.Y - 1}, Loc{Count(line), v.Cursor.Y - 1}) } @@ -1445,9 +1445,10 @@ func (v *View) QuitAll(usePlugin bool) bool { if closeAll { // only quit if all of the buffers can be closed and the user confirms that they actually want to quit everything - should_quit, _ := messenger.YesNoPrompt("Do you want to quit micro (all open files will be closed)?") - - if should_quit { + + shouldQuit, _ := messenger.YesNoPrompt("Do you want to quit micro (all open files will be closed)?") + + if shouldQuit { for _, tab := range tabs { for _, v := range tab.views { v.CloseBuffer() diff --git a/cmd/micro/autocomplete.go b/cmd/micro/autocomplete.go index 47aeca73..b1557e07 100644 --- a/cmd/micro/autocomplete.go +++ b/cmd/micro/autocomplete.go @@ -129,7 +129,7 @@ func OptionComplete(input string) (string, []string) { return chosen, suggestions } -// MakeCompletion registeres a function from a plugin for autocomplete commands +// MakeCompletion registers a function from a plugin for autocomplete commands func MakeCompletion(function string) Completion { pluginCompletions = append(pluginCompletions, LuaFunctionComplete(function)) return Completion(-len(pluginCompletions)) diff --git a/cmd/micro/bindings.go b/cmd/micro/bindings.go index 8cfe01c5..9c813f06 100644 --- a/cmd/micro/bindings.go +++ b/cmd/micro/bindings.go @@ -350,7 +350,7 @@ func BindKey(k, v string) { if helpBinding == k && v != "ToggleHelp" { helpBinding = "" } - + actionNames := strings.Split(v, ",") if actionNames[0] == "UnbindKey" { delete(bindings, key) diff --git a/cmd/micro/lineArray.go b/cmd/micro/lineArray.go index 9583c04e..6d62663d 100644 --- a/cmd/micro/lineArray.go +++ b/cmd/micro/lineArray.go @@ -44,7 +44,7 @@ func NewLineArray(reader io.Reader) *LineArray { data, err := br.ReadBytes('\n') if err != nil { if err == io.EOF { - la.lines = append(la.lines, data[:len(data)]) + la.lines = append(la.lines, data[:]) } // Last line was read break diff --git a/cmd/micro/plugin.go b/cmd/micro/plugin.go index 4e8bfdde..eba09f33 100644 --- a/cmd/micro/plugin.go +++ b/cmd/micro/plugin.go @@ -6,8 +6,8 @@ import ( "os" "strings" - "layeh.com/gopher-luar" "github.com/yuin/gopher-lua" + "layeh.com/gopher-luar" ) var loadedPlugins map[string]string diff --git a/cmd/micro/split_tree.go b/cmd/micro/split_tree.go index 60a431b4..c089fd8f 100644 --- a/cmd/micro/split_tree.go +++ b/cmd/micro/split_tree.go @@ -1,6 +1,6 @@ package main -// SpltType specifies whether a split is horizontal or vertical +// SplitType specifies whether a split is horizontal or vertical type SplitType bool const ( diff --git a/cmd/micro/tab.go b/cmd/micro/tab.go index 90e1220c..bbdd7eb0 100644 --- a/cmd/micro/tab.go +++ b/cmd/micro/tab.go @@ -120,7 +120,7 @@ func TabbarHandleMouseEvent(event tcell.Event) bool { return false } str, indicies := TabbarString() - if x + tabBarOffset >= len(str) { + if x+tabBarOffset >= len(str) { return false } var tabnum int @@ -130,7 +130,7 @@ func TabbarHandleMouseEvent(event tcell.Event) bool { } sort.Ints(keys) for _, k := range keys { - if x + tabBarOffset <= k { + if x+tabBarOffset <= k { tabnum = indicies[k] - 1 break } @@ -167,7 +167,7 @@ func DisplayTabs() { if tooWide == true { // first we have to work out where the selected tab is // out of the total length of the tab bar. this is done - // by extracting the hit-areas from the indicies map + // by extracting the hit-areas from the indicies map // that was constructed by `TabbarString()` var keys []int for offset := range indicies { @@ -197,7 +197,7 @@ func DisplayTabs() { rightBuffer := currentTabOffset + (centeringOffset / 2) // check to make sure we haven't overshot the bounds of the string, - // if we have, then take that remainder and put it on the left side + // if we have, then take that remainder and put it on the left side overshotRight := rightBuffer - len(fileRunes) if overshotRight > 0 { leftBuffer = leftBuffer + overshotRight @@ -210,12 +210,12 @@ func DisplayTabs() { } else { rightBuffer = leftBuffer + (w - 2) } - - if rightBuffer > len(fileRunes) - 1 { + + if rightBuffer > len(fileRunes)-1 { rightBuffer = len(fileRunes) - 1 } - // construct a new buffer of text to put the + // construct a new buffer of text to put the // newly formatted tab bar text into. var displayText []rune @@ -232,13 +232,13 @@ func DisplayTabs() { } // if there is more text to the right of the right-most // column in the tab bar text, then indicate there are more - // tabs to ther right by displaying a "+" - if rightBuffer < len(fileRunes) - 1 { + // tabs to the right by displaying a "+" + if rightBuffer < len(fileRunes)-1 { displayText = append(displayText, '+') } // now store the offset from zero of the left-most text - // that is being displayed. This is to ensure that when + // that is being displayed. This is to ensure that when // clicking on the tab bar, the correct tab gets selected. tabBarOffset = leftBuffer @@ -250,7 +250,7 @@ func DisplayTabs() { } // iterate over the width of the terminal display and for each column, - // write a character into the tab display area with the appropraite style. + // write a character into the tab display area with the appropriate style. for x := 0; x < w; x++ { if x < len(fileRunes) { screen.SetContent(x, 0, fileRunes[x], nil, tabBarStyle) diff --git a/tools/info-plist.go b/tools/info-plist.go index b16a8aee..231901aa 100644 --- a/tools/info-plist.go +++ b/tools/info-plist.go @@ -1,22 +1,22 @@ package main import ( - "os" - "fmt" - "runtime" - "io/ioutil" + "fmt" + "io/ioutil" + "os" + "runtime" ) func check(e error) { - if e != nil { - panic(e) - } + if e != nil { + panic(e) + } } func main() { - if runtime.GOOS == "darwin" { - if len(os.Args) == 2 { - raw_info_plist_string := ` + if runtime.GOOS == "darwin" { + if len(os.Args) == 2 { + rawInfoPlistString := ` @@ -33,13 +33,13 @@ func main() { ` - info_plist_data := []byte(raw_info_plist_string) - - err := ioutil.WriteFile("/tmp/micro-info.plist", info_plist_data, 0644) - check(err) - fmt.Println("-linkmode external -extldflags -Wl,-sectcreate,__TEXT,__info_plist,/tmp/micro-info.plist") - } else { - panic("missing argument for version number!") - } - } + infoPlistData := []byte(rawInfoPlistString) + + err := ioutil.WriteFile("/tmp/micro-info.plist", infoPlistData, 0644) + check(err) + fmt.Println("-linkmode external -extldflags -Wl,-sectcreate,__TEXT,__info_plist,/tmp/micro-info.plist") + } else { + panic("missing argument for version number!") + } + } }