launchpad: minor cleaning

Michael Muré created

Change summary

bridge/launchpad/config.go        | 12 ++++++++----
bridge/launchpad/launchpad_api.go |  7 ++++---
2 files changed, 12 insertions(+), 7 deletions(-)

Detailed changes

bridge/launchpad/config.go 🔗

@@ -25,6 +25,14 @@ func (*Launchpad) Configure(repo repository.RepoCommon) (core.Configuration, err
 	return conf, nil
 }
 
+func (*Launchpad) ValidateConfig(conf core.Configuration) error {
+	if _, ok := conf[keyProject]; !ok {
+		return fmt.Errorf("missing %s key", keyProject)
+	}
+
+	return nil
+}
+
 func promptProjectName() (string, error) {
 	for {
 		fmt.Print("Launchpad project name: ")
@@ -44,7 +52,3 @@ func promptProjectName() (string, error) {
 		return line, nil
 	}
 }
-
-func (*Launchpad) ValidateConfig(conf core.Configuration) error {
-	return nil
-}

bridge/launchpad/launchpad_api.go 🔗

@@ -129,11 +129,12 @@ func (lapi *launchpadAPI) SearchTasks(project string) ([]LPBug, error) {
 			return nil, err
 		}
 
-		defer resp.Body.Close()
-
 		var result launchpadAnswer
 
-		if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
+		err = json.NewDecoder(resp.Body).Decode(&result)
+		_ = resp.Body.Close()
+
+		if err != nil {
 			return nil, err
 		}