Commit 85ae7c50 authored by Kevin Lyda's avatar Kevin Lyda
Browse files

Address linting issues

parent f909088a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ func Choose(prompt string, choices []string) (int, error) {
	}
	choice--
	if choice < 0 || choice >= len(choices) {
		return -1, errors.New("Choice out of bounds")
		return -1, errors.New("choice out of bounds")
	}
	return choice, nil
}
+2 −0
Original line number Diff line number Diff line
@@ -130,6 +130,7 @@ the first user.`)
		Login: login,
		Name:  name,
	})
	ask.CheckErr(err)
	key.Add(login, sshkey)
	userCreated := map[string]bool{
		"SYSTEM": true,
@@ -189,6 +190,7 @@ func NewUser(args []string) int {
	q := storage.New(store.DB)
	ctx := storage.Context()
	u, err := q.GetUser(ctx, login)
	ask.CheckErr(err)
	if u.Login == "" {
		u, err = q.AddUser(ctx, storage.AddUserParams{
			Login: login,
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ func installCrontab(crontab string) error {
		return err
	}
	if n != len(crontab) {
		return fmt.Errorf("Failed to write crontab fully %d of %d chars written",
		return fmt.Errorf("failed to write crontab fully %d of %d chars written",
			n, len(crontab))
	}

+11 −11
Original line number Diff line number Diff line
@@ -158,11 +158,11 @@ func PrefixMatch(command string, commands []string) (string, error) {
	}
	switch len(possibles) {
	case 0:
		return "", fmt.Errorf("Unknown command '%s'", command)
		return "", fmt.Errorf("unknown command '%s'", command)
	case 1:
		return possibles[0], nil
	default:
		return "", fmt.Errorf("Ambiguous command '%s' (matches %s)",
		return "", fmt.Errorf("ambiguous command '%s' (matches %s)",
			command, strings.Join(possibles, ", "))
	}
}
@@ -188,12 +188,12 @@ func (c Commands) run(words []string) error {
		}
		switch len(possibles) {
		case 0:
			return fmt.Errorf("Unknown command '%s'", words[0])
			return fmt.Errorf("unknown command '%s'", words[0])
		case 1:
			wordup = possibles[0]
			cmd = c[wordup]
		default:
			return fmt.Errorf("Ambiguous command '%s' (matches %s)",
			return fmt.Errorf("ambiguous command '%s' (matches %s)",
				words[0], strings.Join(possibles, ", "))
		}
	}
@@ -210,7 +210,7 @@ func (c Commands) run(words []string) error {
	}

	if cmd.Action == nil {
		return fmt.Errorf("Command not implemented:\n%s", cmd.Description)
		return fmt.Errorf("command not implemented:\n%s", cmd.Description)
	}
	for flg := range cmd.Flags {
		cmd.Flags[flg].Value = cmd.Flags[flg].Default
@@ -220,7 +220,7 @@ func (c Commands) run(words []string) error {

	if len(words) == 1 {
		if len(cmd.Args) < cmd.MinArgs {
			return errors.New("Not enough args")
			return errors.New("not enough args")
		}
		return cmd.Action(cmd)
	}
@@ -240,15 +240,15 @@ func (c Commands) run(words []string) error {
				wordup = strings.Replace(wordup, "/NO", "/", 1)
				flg, ok = cmd.Flags[wordup]
				if !ok {
					return fmt.Errorf("Flag '%s' not recognised", args[i])
					return fmt.Errorf("flag '%s' not recognised", args[i])
				}
				toggleValue = "false"
			}
			if !flg.OptArg && assigned {
				return fmt.Errorf("Flag '%s' is a toggle", args[i])
				return fmt.Errorf("flag '%s' is a toggle", args[i])
			}
			if flg.Set {
				return fmt.Errorf("Flag '%s' is already set", args[i])
				return fmt.Errorf("flag '%s' is already set", args[i])
			}
			flg.Set = true
			if flg.OptArg {
@@ -260,13 +260,13 @@ func (c Commands) run(words []string) error {
			}
		} else {
			if len(cmd.Args) == cmd.MaxArgs {
				return fmt.Errorf("Too many args at '%s'", args[i])
				return fmt.Errorf("too many args at '%s'", args[i])
			}
			cmd.Args = append(cmd.Args, args[i])
		}
	}
	if len(cmd.Args) < cmd.MinArgs {
		return errors.New("Not enough args")
		return errors.New("not enough args")
	}
	return cmd.Action(cmd)
}
+6 −6
Original line number Diff line number Diff line
@@ -19,14 +19,14 @@ import (
// ValidFolder validates the folder name for this user.
func ValidFolder(folder string) (storage.Folder, error) {
	if !IsAlphaNum(folder) {
		return storage.Folder{}, errors.New("Folder can only have letters and numbers")
		return storage.Folder{}, errors.New("folder can only have letters and numbers")
	}
	correct := FindFolder(folder)
	if correct.Name == "" {
		return storage.Folder{}, errors.New("Unable to select the folder")
		return storage.Folder{}, errors.New("unable to select the folder")
	}
	if !IsFolderReadable(correct.Name, this.User.Login) {
		return storage.Folder{}, errors.New("Unable to select the folder")
		return storage.Folder{}, errors.New("unable to select the folder")
	}
	return correct, nil
}
@@ -34,14 +34,14 @@ func ValidFolder(folder string) (storage.Folder, error) {
// Values for FolderVisibility.
const (
	FolderPublic      int64 = 0
	FolderSemiPrivate       = 1
	FolderPrivate           = 2
	FolderSemiPrivate int64 = 1
	FolderPrivate     int64 = 2
)

// CreateFolder creates a new folder.
func CreateFolder(options storage.CreateFolderParams) error {
	if !IsAlphaNum(options.Name) {
		return errors.New("Folder can only have letters and numbers")
		return errors.New("folder can only have letters and numbers")
	}
	options.Name = strings.ToUpper(options.Name)

Loading