Commit fbfe0540 authored by Loïck Bonniot's avatar Loïck Bonniot

[c][p][mails] Apply gosimple propositions

parent 6dcd836e
Pipeline #622 passed with stage
...@@ -76,10 +76,10 @@ Code lint: ...@@ -76,10 +76,10 @@ Code lint:
- lint - lint
script: script:
- "ln -s $(pwd) $GOPATH/src/dfss" - "ln -s $(pwd) $GOPATH/src/dfss"
- "go get github.com/alecthomas/gometalinter" - "go get -u github.com/alecthomas/gometalinter"
- "./build/deps.sh" - "./build/deps.sh"
- "cd $GOPATH/src/dfss && make install_all" - "cd $GOPATH/src/dfss && make install_all"
- "gometalinter --install" - "gometalinter --install --update"
- "gometalinter -t --deadline=600s -j1 --skip=api --skip=fixtures --skip=gui --skip=dfssd --disable=aligncheck ./..." - "gometalinter -t --deadline=600s -j1 --skip=api --skip=fixtures --skip=gui --skip=dfssd --disable=aligncheck ./..."
Deploy: Deploy:
......
...@@ -44,12 +44,7 @@ func readPassphrases(keyPassphrase, confPassphrase *string, second bool) error { ...@@ -44,12 +44,7 @@ func readPassphrases(keyPassphrase, confPassphrase *string, second bool) error {
} }
fmt.Println("Enter the passphrase of your current key (if any)") fmt.Println("Enter the passphrase of your current key (if any)")
err = readPassword(keyPassphrase, false) return readPassword(keyPassphrase, false)
if err != nil {
return err
}
return nil
} }
// import the configuration // import the configuration
......
...@@ -81,12 +81,7 @@ func (m *AuthManager) Authenticate() error { ...@@ -81,12 +81,7 @@ func (m *AuthManager) Authenticate() error {
return err return err
} }
err = m.evaluateResponse(response) return m.evaluateResponse(response)
if err != nil {
return err
}
return nil
} }
// Creates the associated authentication request and sends it to the platform grpc server // Creates the associated authentication request and sends it to the platform grpc server
...@@ -117,10 +112,5 @@ func (m *AuthManager) sendRequest() (*pb.RegisteredUser, error) { ...@@ -117,10 +112,5 @@ func (m *AuthManager) sendRequest() (*pb.RegisteredUser, error) {
func (m *AuthManager) evaluateResponse(response *pb.RegisteredUser) error { func (m *AuthManager) evaluateResponse(response *pb.RegisteredUser) error {
cert := []byte(response.ClientCert) cert := []byte(response.ClientCert)
err := ioutil.WriteFile(m.fileCert, cert, 0600) return ioutil.WriteFile(m.fileCert, cert, 0600)
if err != nil {
return err
}
return nil
} }
...@@ -13,13 +13,7 @@ func Register(fileCA, fileCert, fileKey, addrPort, passphrase, country, organiza ...@@ -13,13 +13,7 @@ func Register(fileCA, fileCert, fileKey, addrPort, passphrase, country, organiza
if err != nil { if err != nil {
return err return err
} }
return manager.GetCertificate()
err = manager.GetCertificate()
if err != nil {
return err
}
return nil
} }
// Authenticate a user using the provided parameters // Authenticate a user using the provided parameters
...@@ -28,13 +22,7 @@ func Authenticate(fileCA, fileCert, addrPort, mail, token string) error { ...@@ -28,13 +22,7 @@ func Authenticate(fileCA, fileCert, addrPort, mail, token string) error {
if err != nil { if err != nil {
return err return err
} }
return manager.Authenticate()
err = manager.Authenticate()
if err != nil {
return err
}
return nil
} }
func connect(fileCA, addrPort string) (pb.PlatformClient, error) { func connect(fileCA, addrPort string) (pb.PlatformClient, error) {
......
...@@ -123,11 +123,7 @@ func (c *Config) checkData(keyPassphrase string) error { ...@@ -123,11 +123,7 @@ func (c *Config) checkData(keyPassphrase string) error {
} }
_, err = auth.EncryptedPEMToPrivateKey(c.KeyData, keyPassphrase) _, err = auth.EncryptedPEMToPrivateKey(c.KeyData, keyPassphrase)
if err != nil { return err
return err
}
return nil
} }
// SaveUserInformations save the certificate and private key to the files specified in the Config struct // SaveUserInformations save the certificate and private key to the files specified in the Config struct
......
...@@ -68,12 +68,7 @@ func Initialize(bits, days int, country, organization, unit, cn, path string, ca ...@@ -68,12 +68,7 @@ func Initialize(bits, days int, country, organization, unit, cn, path string, ca
} }
// Save the root certificate. // Save the root certificate.
err = ioutil.WriteFile(certPath, cert, 0600) return ioutil.WriteFile(certPath, cert, 0600)
if err != nil {
return err
}
return nil
} }
// Start fetches the platform's private rsa key and root certificate, and create a PlatformID accordingly. // Start fetches the platform's private rsa key and root certificate, and create a PlatformID accordingly.
......
...@@ -44,7 +44,7 @@ func TestCloseWaitingGroup(t *testing.T) { ...@@ -44,7 +44,7 @@ func TestCloseWaitingGroup(t *testing.T) {
go func() { go func() {
myChan, _, _ := w.Join("A") myChan, _, _ := w.Join("A")
for _ = range myChan { for range myChan {
t.Fatal("Should not be here") t.Fatal("Should not be here")
} }
// No need to call Unjoin here: if we do, we will try to unjoin a unknown room // No need to call Unjoin here: if we do, we will try to unjoin a unknown room
......
...@@ -137,7 +137,7 @@ func FindAndUpdatePendingSigner(mail string, signersReady *[]bool, signers *[]en ...@@ -137,7 +137,7 @@ func FindAndUpdatePendingSigner(mail string, signersReady *[]bool, signers *[]en
// Check if everyone is ready // Check if everyone is ready
for _, s := range *signersReady { for _, s := range *signersReady {
if s == false { if !s {
return return
} }
} }
......
...@@ -143,11 +143,7 @@ func createFullMessage(b io.Writer, receiver, sender, globalHeader, base64Messag ...@@ -143,11 +143,7 @@ func createFullMessage(b io.Writer, receiver, sender, globalHeader, base64Messag
return err return err
} }
} }
if err := writer.Close(); err != nil { return writer.Close()
return err
}
return nil
} }
// Create an attachment with a certain extension // Create an attachment with a certain extension
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment