Fix linter warnings

main
Jan Dittberner 2 years ago
parent 368bd8eefb
commit 7f0b52c5b5

@ -30,6 +30,7 @@ const (
httpReadHeaderTimeout = 5 * time.Second httpReadHeaderTimeout = 5 * time.Second
httpReadTimeout = 5 * time.Second httpReadTimeout = 5 * time.Second
httpWriteTimeout = 10 * time.Second httpWriteTimeout = 10 * time.Second
smtpPort = 25
smtpTimeout = 10 * time.Second smtpTimeout = 10 * time.Second
) )
@ -80,7 +81,7 @@ func parseConfig(configFile string) (*Config, error) {
}, },
MailConfig: &mailConfig{ MailConfig: &mailConfig{
SMTPHost: "localhost", SMTPHost: "localhost",
SMTPPort: 25, SMTPPort: smtpPort,
SMTPTimeOut: smtpTimeout, SMTPTimeOut: smtpTimeout,
}, },
} }

@ -659,8 +659,10 @@ func (app *application) healthCheck(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Refresh", "10") w.Header().Set("Refresh", "10")
w.Header().Add("Cache-Control", "no-store") w.Header().Add("Cache-Control", "no-store")
var err error var (
var hasErrors = false err error
hasErrors = false
)
if err = app.mailNotifier.Ping(); err != nil { if err = app.mailNotifier.Ping(); err != nil {
hasErrors = true hasErrors = true

@ -48,8 +48,9 @@ func prepareTestDb(t *testing.T) *sqlx.DB {
return dbx return dbx
} }
func StartTestTcpServer(t *testing.T) int { func StartTestTCPServer(t *testing.T) int {
t.Helper() t.Helper()
port, err := tcputil.EmptyPort() port, err := tcputil.EmptyPort()
require.NoError(t, err) require.NoError(t, err)
@ -68,6 +69,7 @@ func StartTestTcpServer(t *testing.T) int {
if err != nil { if err != nil {
t.Errorf("could not accept connection: %v", err) t.Errorf("could not accept connection: %v", err)
return return
} }
@ -81,7 +83,7 @@ func StartTestTcpServer(t *testing.T) int {
} }
func TestApplication_healthCheck(t *testing.T) { func TestApplication_healthCheck(t *testing.T) {
port := StartTestTcpServer(t) port := StartTestTCPServer(t)
t.Run("check with valid DB", func(t *testing.T) { t.Run("check with valid DB", func(t *testing.T) {
rr := httptest.NewRecorder() rr := httptest.NewRecorder()

@ -40,7 +40,8 @@ type RemindVotersJob struct {
} }
func (r *RemindVotersJob) Schedule() { func (r *RemindVotersJob) Schedule() {
// TODO: check logic. It would make more sense to remind at a specific interval before the next pending decision is closed // TODO: check logic. It would make more sense to remind at a specific interval before the next pending
// decision is closed
const reminderDays = 3 const reminderDays = 3
year, month, day := time.Now().UTC().Date() year, month, day := time.Now().UTC().Date()
@ -235,8 +236,8 @@ func (js *JobScheduler) Schedule() {
for { for {
select { select {
case jobId := <-js.rescheduleChannel: case jobID := <-js.rescheduleChannel:
js.jobs[jobId].Schedule() js.jobs[jobID].Schedule()
case <-js.quitChannel: case <-js.quitChannel:
for _, job := range js.jobs { for _, job := range js.jobs {
job.Stop() job.Stop()

@ -70,6 +70,7 @@ func (app *application) authenticateRequest(r *http.Request) (*models.User, *x50
clientCert := r.TLS.PeerCertificates[0] clientCert := r.TLS.PeerCertificates[0]
allowClientAuth := false allowClientAuth := false
for _, eku := range clientCert.ExtKeyUsage { for _, eku := range clientCert.ExtKeyUsage {
if eku == x509.ExtKeyUsageClientAuth { if eku == x509.ExtKeyUsageClientAuth {
allowClientAuth = true allowClientAuth = true

@ -53,6 +53,7 @@ func NotBlank(value string) bool {
func NotNil(value any) bool { func NotNil(value any) bool {
val := reflect.ValueOf(value) val := reflect.ValueOf(value)
return !val.IsNil() return !val.IsNil()
} }

Loading…
Cancel
Save