Add Golangci Lint (#676)

Increase golangci timeout

Fix installing golangci-lint in ci

Remove mage targets replaced by golangci

Run golint in ci

Add goheader linter

Enable & fix more linters

Fix lint issues

Add mage target to automagically fix issues found by golangci

golangci-lint run --fix

Add golangci config

Add golangci mage target

Co-authored-by: kolaente <k@knt.li>
Reviewed-on: vikunja/api#676
Co-Authored-By: konrad <konrad@kola-entertainments.de>
Co-Committed-By: konrad <konrad@kola-entertainments.de>
This commit is contained in:
konrad 2020-10-11 20:10:03 +00:00
parent d56a611be7
commit 699d3d6060
143 changed files with 630 additions and 426 deletions

View File

@ -83,16 +83,9 @@ steps:
depends_on: [ build ]
commands:
- ./mage-static build:generate
- ./mage-static check:lint
- ./mage-static check:fmt
- ./mage-static check:got-swag
- ./mage-static check:ineffassign
- ./mage-static check:misspell
- ./mage-static check:goconst
- ./mage-static check:gocyclo
- ./mage-static check:static
- wget -O - -q https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $GOPATH/bin v2.2.0 # Need to manually install as it does not support being installed via go modules like the rest.
- ./mage-static check:gosec
- wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.31.0
- ./mage-static check:golangci
when:
event: [ push, tag, pull_request ]

73
.golangci.yml Normal file
View File

@ -0,0 +1,73 @@
run:
timeout: 5m
tests: true
linters:
enable:
- megacheck
- govet
- goconst
- gocritic
- gocyclo
- goerr113
- goheader
- gofmt
- goimports
- golint
- misspell
disable:
- scopelint # Obsolete, using exportloopref instead
presets:
- bugs
- unused
fast: false
linter-settings:
nestif:
min-complexity: 6
goheader:
template-path: code-hesader-template.txt
issues:
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- gocyclo
- deadcode
- path: pkg/integrations/*
linters:
- gocyclo
- deadcode
- varcheck
- unparam
- bodyclose
- path: pkg/integrations/*
text: "unlambda"
linters:
- gocritic
- path: pkg/modules/background/unsplash/unsplash\.go
linters:
- bodyclose
- path: pkg/migration/*
linters:
- exhaustive
- goconst
- goerr113
- path: pkg/models/task_collection_filter\.go
linters:
- exhaustive
- path: pkg/utils/random_string\.go
text: "G404:" # We don't care about cryptographically secure randomness when we're using that utility function.
linters:
- gosec
- path: pkg/modules/dump/*
linters:
- goerr113
- path: pkg/
text: "err113: do not define dynamic errors, use wrapped static errors instead:"
linters:
- goerr113
- text: "commentFormatting: put a space between `//` and comment text"
linters:
- gocritic

15
code-header-template.txt Normal file
View File

@ -0,0 +1,15 @@
Vikunja is a to-do list application to facilitate your life.
Copyright 2018-2020 Vikunja and contributors. All rights reserved.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

1
go.mod
View File

@ -33,6 +33,7 @@ require (
github.com/fzipp/gocyclo v0.0.0-20150627053110-6acd4345c835
github.com/gabriel-vasile/mimetype v1.1.1
github.com/getsentry/sentry-go v0.7.0
github.com/go-errors/errors v1.0.1
github.com/go-redis/redis/v7 v7.4.0
github.com/go-sql-driver/mysql v1.5.0
github.com/go-testfixtures/testfixtures/v3 v3.4.0

View File

@ -59,7 +59,6 @@ var (
Aliases = map[string]interface{}{
"build": Build.Build,
"do-the-swag": DoTheSwag,
"check:go-sec": Check.GoSec,
"check:got-swag": Check.GotSwag,
"release:os-package": Release.OsPackage,
"dev:create-migration": Dev.CreateMigration,
@ -330,34 +329,6 @@ func (Test) Integration() {
type Check mg.Namespace
// Checks if the code is properly formatted with go fmt
func (Check) Fmt() error {
mg.Deps(initVars)
args := append([]string{"-s", "-d"}, GoFiles...)
c := exec.Command("gofmt", args...)
out, err := c.Output()
if err != nil {
return err
}
if len(out) > 0 {
fmt.Println("Code is not properly gofmt'ed.")
fmt.Println("Please run 'mage fmt' and commit the result:")
fmt.Print(string(out))
os.Exit(1)
}
return nil
}
// Runs golint on all packages
func (Check) Lint() {
mg.Deps(initVars)
checkAndInstallGoTool("golint", "golang.org/x/lint/golint")
args := append([]string{"-set_exit_status"}, ApiPackages...)
runAndStreamOutput("golint", args...)
}
// Checks if the swagger docs need to be re-generated from the code annotations
func (Check) GotSwag() {
mg.Deps(initVars)
@ -388,65 +359,31 @@ func (Check) GotSwag() {
}
}
// Checks the source code for misspellings
func (Check) Misspell() {
func checkGolangCiLintInstalled() {
mg.Deps(initVars)
checkAndInstallGoTool("misspell", "github.com/client9/misspell/cmd/misspell")
runAndStreamOutput("misspell", append([]string{"-error"}, GoFiles...)...)
}
// Checks the source code for ineffectual assigns
func (Check) Ineffassign() {
mg.Deps(initVars)
checkAndInstallGoTool("ineffassign", "github.com/gordonklaus/ineffassign")
runAndStreamOutput("ineffassign", GoFiles...)
}
// Checks for the cyclomatic complexity of the source code
func (Check) Gocyclo() {
mg.Deps(initVars)
checkAndInstallGoTool("gocyclo", "github.com/fzipp/gocyclo")
runAndStreamOutput("gocyclo", append([]string{"-over", "49"}, GoFiles...)...)
}
// Statically analyzes the source code about a range of different problems
func (Check) Static() {
mg.Deps(initVars)
checkAndInstallGoTool("staticcheck", "honnef.co/go/tools/cmd/staticcheck")
runAndStreamOutput("staticcheck", ApiPackages...)
}
// Checks the source code for potential security issues
func (Check) GoSec() {
mg.Deps(initVars)
if err := exec.Command("gosec").Run(); err != nil && strings.Contains(err.Error(), "executable file not found") {
fmt.Println("Please manually install gosec by running")
fmt.Println("curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | bash -s -- -b $GOPATH/bin v2.2.0")
if err := exec.Command("golangci-lint").Run(); err != nil && strings.Contains(err.Error(), "executable file not found") {
fmt.Println("Please manually install golangci-lint by running")
fmt.Println("curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.31.0")
os.Exit(1)
}
runAndStreamOutput("gosec", "./...")
}
// Checks for repeated strings that could be replaced by a constant
func (Check) Goconst() {
mg.Deps(initVars)
checkAndInstallGoTool("goconst", "github.com/jgautheron/goconst/cmd/goconst")
runAndStreamOutput("goconst", ApiPackages...)
func (Check) Golangci() {
checkGolangCiLintInstalled()
runAndStreamOutput("golangci-lint", "run")
}
func (Check) GolangciFix() {
checkGolangCiLintInstalled()
runAndStreamOutput("golangci-lint", "run", "--fix")
}
// Runs fmt-check, lint, got-swag, misspell-check, ineffasign-check, gocyclo-check, static-check, gosec-check, goconst-check all in parallel
func (Check) All() {
mg.Deps(initVars)
mg.Deps(
Check.Fmt,
Check.Lint,
Check.Golangci,
Check.GotSwag,
Check.Misspell,
Check.Ineffassign,
Check.Gocyclo,
Check.Static,
Check.GoSec,
Check.Goconst,
)
}

View File

@ -17,13 +17,14 @@
package caldav
import (
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/user"
"code.vikunja.io/api/pkg/utils"
"fmt"
"strconv"
"strings"
"time"
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/user"
"code.vikunja.io/api/pkg/utils"
)
// DateFormat ist the caldav date format

View File

@ -17,10 +17,11 @@
package caldav
import (
"code.vikunja.io/api/pkg/config"
"github.com/stretchr/testify/assert"
"testing"
"time"
"code.vikunja.io/api/pkg/config"
"github.com/stretchr/testify/assert"
)
func TestParseEvents(t *testing.T) {

View File

@ -18,8 +18,9 @@ package cmd
import (
"fmt"
"github.com/spf13/cobra"
"os"
"github.com/spf13/cobra"
)
var rootCmd = &cobra.Command{

View File

@ -17,11 +17,12 @@
package cmd
import (
"time"
"code.vikunja.io/api/pkg/initialize"
"code.vikunja.io/api/pkg/log"
"code.vikunja.io/api/pkg/modules/dump"
"github.com/spf13/cobra"
"time"
)
func init() {

View File

@ -18,17 +18,18 @@
package cmd
import (
"code.vikunja.io/api/pkg/initialize"
"code.vikunja.io/api/pkg/log"
"code.vikunja.io/api/pkg/user"
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
"golang.org/x/crypto/ssh/terminal"
"os"
"strconv"
"strings"
"time"
"code.vikunja.io/api/pkg/initialize"
"code.vikunja.io/api/pkg/log"
"code.vikunja.io/api/pkg/user"
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
"golang.org/x/crypto/ssh/terminal"
)
var (

View File

@ -17,10 +17,11 @@
package cmd
import (
"code.vikunja.io/api/pkg/version"
"fmt"
"github.com/spf13/cobra"
"runtime"
"code.vikunja.io/api/pkg/version"
"github.com/spf13/cobra"
)
func init() {

View File

@ -17,17 +17,18 @@
package cmd
import (
"context"
"os"
"os/signal"
"time"
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/initialize"
"code.vikunja.io/api/pkg/log"
"code.vikunja.io/api/pkg/routes"
"code.vikunja.io/api/pkg/swagger"
"code.vikunja.io/api/pkg/version"
"context"
"github.com/spf13/cobra"
"os"
"os/signal"
"time"
)
func init() {

View File

@ -17,16 +17,17 @@
package db
import (
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/log"
"encoding/gob"
"fmt"
xrc "gitea.com/xorm/xorm-redis-cache"
"net/url"
"os"
"strconv"
"strings"
"time"
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/log"
xrc "gitea.com/xorm/xorm-redis-cache"
"xorm.io/core"
"xorm.io/xorm"
"xorm.io/xorm/caches"
@ -52,23 +53,24 @@ func CreateDBEngine() (engine *xorm.Engine, err error) {
}
// Use Mysql if set
if config.DatabaseType.GetString() == "mysql" {
switch config.DatabaseType.GetString() {
case "mysql":
engine, err = initMysqlEngine()
if err != nil {
return
}
} else if config.DatabaseType.GetString() == "postgres" {
case "postgres":
engine, err = initPostgresEngine()
if err != nil {
return
}
} else if config.DatabaseType.GetString() == "sqlite" {
case "sqlite":
// Otherwise use sqlite
engine, err = initSqliteEngine()
if err != nil {
return
}
} else {
default:
log.Fatalf("Unknown database type %s", config.DatabaseType.GetString())
}

View File

@ -18,12 +18,13 @@
package db
import (
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/log"
"fmt"
"github.com/stretchr/testify/assert"
"os"
"testing"
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/log"
"github.com/stretchr/testify/assert"
"xorm.io/core"
"xorm.io/xorm"
)

View File

@ -18,12 +18,13 @@
package db
import (
"code.vikunja.io/api/pkg/config"
"fmt"
"github.com/go-testfixtures/testfixtures/v3"
"github.com/stretchr/testify/assert"
"path/filepath"
"testing"
"code.vikunja.io/api/pkg/config"
"github.com/go-testfixtures/testfixtures/v3"
"github.com/stretchr/testify/assert"
"xorm.io/xorm/schemas"
)

View File

@ -29,7 +29,7 @@ func (err ErrFileDoesNotExist) Error() string {
return fmt.Sprintf("file %d does not exist", err.FileID)
}
//IsErrFileDoesNotExist checks if an error is ErrFileDoesNotExist
// IsErrFileDoesNotExist checks if an error is ErrFileDoesNotExist
func IsErrFileDoesNotExist(err error) bool {
_, ok := err.(ErrFileDoesNotExist)
return ok
@ -45,7 +45,7 @@ func (err ErrFileIsTooLarge) Error() string {
return fmt.Sprintf("file is too large [Size: %d]", err.Size)
}
//IsErrFileIsTooLarge checks if an error is ErrFileIsTooLarge
// IsErrFileIsTooLarge checks if an error is ErrFileIsTooLarge
func IsErrFileIsTooLarge(err error) bool {
_, ok := err.(ErrFileIsTooLarge)
return ok
@ -62,7 +62,7 @@ func (err ErrFileIsNotUnsplashFile) Error() string {
return fmt.Sprintf("file was not downloaded from unsplash [FileID: %d]", err.FileID)
}
//IsErrFileIsNotUnsplashFile checks if an error is ErrFileIsNotUnsplashFile
// IsErrFileIsNotUnsplashFile checks if an error is ErrFileIsNotUnsplashFile
func IsErrFileIsNotUnsplashFile(err error) bool {
_, ok := err.(ErrFileIsNotUnsplashFile)
return ok

View File

@ -17,13 +17,14 @@
package files
import (
"os"
"testing"
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/db"
"code.vikunja.io/api/pkg/log"
"github.com/spf13/afero"
"github.com/stretchr/testify/assert"
"os"
"testing"
)
// This file handles storing and retrieving a file for different backends
@ -49,7 +50,7 @@ func initFixtures(t *testing.T) {
InitTestFileFixtures(t)
}
//InitTestFileFixtures initializes file fixtures
// InitTestFileFixtures initializes file fixtures
func InitTestFileFixtures(t *testing.T) {
// Init fixture files
filename := config.FilesBasePath.GetString() + "/1"

View File

@ -17,13 +17,14 @@
package files
import (
"io"
"strconv"
"time"
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/web"
"github.com/c2h5oh/datasize"
"github.com/spf13/afero"
"io"
"strconv"
"time"
)
// File holds all information about a file

View File

@ -18,10 +18,11 @@
package files
import (
"github.com/stretchr/testify/assert"
"io"
"os"
"testing"
"github.com/stretchr/testify/assert"
)
type testfile struct {

View File

@ -18,11 +18,12 @@
package integrations
import (
"net/url"
"testing"
"code.vikunja.io/api/pkg/models"
"code.vikunja.io/web/handler"
"github.com/stretchr/testify/assert"
"net/url"
"testing"
)
// This tests the following behaviour:

View File

@ -17,6 +17,13 @@
package integrations
import (
"net/http"
"net/http/httptest"
"net/url"
"os"
"strings"
"testing"
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/db"
"code.vikunja.io/api/pkg/files"
@ -29,12 +36,6 @@ import (
"github.com/dgrijalva/jwt-go"
"github.com/labstack/echo/v4"
"github.com/stretchr/testify/assert"
"net/http"
"net/http/httptest"
"net/url"
"os"
"strings"
"testing"
)
// These are the test users, the same way they are in the test database

View File

@ -17,11 +17,12 @@
package integrations
import (
"testing"
"code.vikunja.io/api/pkg/models"
"code.vikunja.io/web/handler"
"github.com/labstack/echo/v4"
"github.com/stretchr/testify/assert"
"testing"
)
func TestBucket(t *testing.T) {

View File

@ -17,12 +17,13 @@
package integrations
import (
"net/url"
"testing"
"code.vikunja.io/api/pkg/models"
"code.vikunja.io/web/handler"
"github.com/labstack/echo/v4"
"github.com/stretchr/testify/assert"
"net/url"
"testing"
)
func TestLinkSharing(t *testing.T) {

View File

@ -17,12 +17,13 @@
package integrations
import (
"net/url"
"testing"
"code.vikunja.io/api/pkg/models"
"code.vikunja.io/web/handler"
"github.com/labstack/echo/v4"
"github.com/stretchr/testify/assert"
"net/url"
"testing"
)
func TestList(t *testing.T) {

View File

@ -17,11 +17,12 @@
package integrations
import (
"net/http"
"testing"
apiv1 "code.vikunja.io/api/pkg/routes/api/v1"
"code.vikunja.io/api/pkg/user"
"github.com/stretchr/testify/assert"
"net/http"
"testing"
)
func TestLogin(t *testing.T) {

View File

@ -17,11 +17,12 @@
package integrations
import (
"net/http"
"testing"
apiv1 "code.vikunja.io/api/pkg/routes/api/v1"
"code.vikunja.io/api/pkg/user"
"github.com/stretchr/testify/assert"
"net/http"
"testing"
)
func TestRegister(t *testing.T) {

View File

@ -18,11 +18,12 @@
package integrations
import (
"net/url"
"testing"
"code.vikunja.io/api/pkg/models"
"code.vikunja.io/web/handler"
"github.com/stretchr/testify/assert"
"net/url"
"testing"
)
func TestTaskCollection(t *testing.T) {

View File

@ -17,11 +17,12 @@
package integrations
import (
"testing"
"code.vikunja.io/api/pkg/models"
"code.vikunja.io/web/handler"
"github.com/labstack/echo/v4"
"github.com/stretchr/testify/assert"
"testing"
)
func TestTaskComments(t *testing.T) {

View File

@ -17,11 +17,12 @@
package integrations
import (
"testing"
"code.vikunja.io/api/pkg/models"
"code.vikunja.io/web/handler"
"github.com/labstack/echo/v4"
"github.com/stretchr/testify/assert"
"testing"
)
func TestTask(t *testing.T) {

View File

@ -17,10 +17,11 @@
package integrations
import (
apiv1 "code.vikunja.io/api/pkg/routes/api/v1"
"github.com/stretchr/testify/assert"
"net/http"
"testing"
apiv1 "code.vikunja.io/api/pkg/routes/api/v1"
"github.com/stretchr/testify/assert"
)
func TestCheckToken(t *testing.T) {

View File

@ -17,11 +17,12 @@
package integrations
import (
"net/http"
"testing"
apiv1 "code.vikunja.io/api/pkg/routes/api/v1"
"code.vikunja.io/api/pkg/user"
"github.com/stretchr/testify/assert"
"net/http"
"testing"
)
func TestUserChangePassword(t *testing.T) {

View File

@ -17,12 +17,13 @@
package integrations
import (
"net/http"
"testing"
apiv1 "code.vikunja.io/api/pkg/routes/api/v1"
"code.vikunja.io/api/pkg/user"
"github.com/labstack/echo/v4"
"github.com/stretchr/testify/assert"
"net/http"
"testing"
)
func TestUserConfirmEmail(t *testing.T) {

View File

@ -17,10 +17,11 @@
package integrations
import (
apiv1 "code.vikunja.io/api/pkg/routes/api/v1"
"github.com/stretchr/testify/assert"
"net/http"
"testing"
apiv1 "code.vikunja.io/api/pkg/routes/api/v1"
"github.com/stretchr/testify/assert"
)
func TestUserList(t *testing.T) {

View File

@ -17,12 +17,13 @@
package integrations
import (
"net/http"
"testing"
apiv1 "code.vikunja.io/api/pkg/routes/api/v1"
"code.vikunja.io/api/pkg/user"
"github.com/labstack/echo/v4"
"github.com/stretchr/testify/assert"
"net/http"
"testing"
)
func TestUserRequestResetPasswordToken(t *testing.T) {

View File

@ -17,12 +17,13 @@
package integrations
import (
"net/http"
"testing"
apiv1 "code.vikunja.io/api/pkg/routes/api/v1"
"code.vikunja.io/api/pkg/user"
"github.com/labstack/echo/v4"
"github.com/stretchr/testify/assert"
"net/http"
"testing"
)
func TestUserPasswordReset(t *testing.T) {

View File

@ -17,10 +17,11 @@
package integrations
import (
apiv1 "code.vikunja.io/api/pkg/routes/api/v1"
"github.com/stretchr/testify/assert"
"net/http"
"testing"
apiv1 "code.vikunja.io/api/pkg/routes/api/v1"
"github.com/stretchr/testify/assert"
)
func TestUserShow(t *testing.T) {

View File

@ -17,13 +17,14 @@
package log
import (
"code.vikunja.io/api/pkg/config"
"github.com/op/go-logging"
"github.com/spf13/viper"
"io"
"os"
"strings"
"time"
"code.vikunja.io/api/pkg/config"
"github.com/op/go-logging"
"github.com/spf13/viper"
)
// ErrFmt holds the format for all the console logging
@ -105,7 +106,6 @@ func GetLogger() *logging.Logger {
return logInstance
}
/////
// The following functions are to be used as an "eye-candy", so one can just write log.Error() instead of log.Log.Error()
// Debug is for debug messages

View File

@ -17,10 +17,11 @@
package log
import (
"code.vikunja.io/api/pkg/config"
"github.com/op/go-logging"
"strings"
"time"
"code.vikunja.io/api/pkg/config"
"github.com/op/go-logging"
"xorm.io/xorm/log"
)

View File

@ -17,11 +17,12 @@
package mail
import (
"crypto/tls"
"time"
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/log"
"crypto/tls"
"gopkg.in/gomail.v2"
"time"
)
// Queue is the mail queue

View File

@ -18,13 +18,14 @@ package mail
import (
"bytes"
"html/template"
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/log"
"code.vikunja.io/api/pkg/static"
"code.vikunja.io/api/pkg/utils"
"github.com/shurcooL/httpfs/html/vfstemplate"
"gopkg.in/gomail.v2"
"html/template"
)
// Opts holds infos for a mail

View File

@ -17,13 +17,14 @@
package metrics
import (
"sync"
"time"
"code.vikunja.io/api/pkg/log"
"code.vikunja.io/api/pkg/modules/keyvalue"
"code.vikunja.io/web"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"sync"
"time"
)
// SecondsUntilInactive defines the seconds until a user is considered inactive

View File

@ -18,6 +18,7 @@ package migration
import (
"math"
"src.techknowlogick.com/xormigrate"
"xorm.io/xorm"
)

View File

@ -17,8 +17,9 @@
package migration
import (
"src.techknowlogick.com/xormigrate"
"strings"
"src.techknowlogick.com/xormigrate"
"xorm.io/xorm"
)
@ -55,7 +56,7 @@ func init() {
// The general idea here is to take the title and slice it into pieces, until we found a unique piece.
var exists = true
titleSlug := []rune(strings.Replace(strings.ToUpper(l.Title), " ", "", -1))
titleSlug := []rune(strings.ReplaceAll(strings.ToUpper(l.Title), " ", ""))
// We can save at most 10 characters in the db, so we need to ensure it has at most 10 characters
if len(titleSlug) > 10 {

View File

@ -18,8 +18,9 @@ package migration
import (
"fmt"
"src.techknowlogick.com/xormigrate"
"strings"
"src.techknowlogick.com/xormigrate"
"xorm.io/xorm"
"xorm.io/xorm/schemas"
)
@ -654,7 +655,7 @@ create unique index UQE_users_namespace_id
// The statement is probably useless anyway since its only purpose is to clean up old tables
// which may be leftovers from a previously failed migration. However, since the whole thing
// is wrapped in sessions, this is extremely unlikely to happen anyway.
//"ALTER TABLE " + table + " DROP COLUMN IF EXISTS " + colTmp + ";",
// "ALTER TABLE " + table + " DROP COLUMN IF EXISTS " + colTmp + ";",
"ALTER TABLE " + table + " ADD COLUMN " + colTmp + " DATETIME NULL;",
// #nosec
"UPDATE " + table + " SET " + colTmp + " = IF(" + colOld + " = 0, NULL, FROM_UNIXTIME(" + colOld + "));",

View File

@ -17,9 +17,10 @@
package migration
import (
"time"
"code.vikunja.io/api/pkg/models"
"src.techknowlogick.com/xormigrate"
"time"
"xorm.io/xorm"
)

View File

@ -17,6 +17,9 @@
package migration
import (
"os"
"sort"
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/db"
"code.vikunja.io/api/pkg/files"
@ -25,8 +28,6 @@ import (
"code.vikunja.io/api/pkg/modules/migration"
"code.vikunja.io/api/pkg/user"
"github.com/olekukonko/tablewriter"
"os"
"sort"
"src.techknowlogick.com/xormigrate"
"xorm.io/xorm"
)

View File

@ -1,9 +1,10 @@
package models
import (
"testing"
"code.vikunja.io/api/pkg/db"
"code.vikunja.io/api/pkg/user"
"testing"
)
func TestBulkTask_Update(t *testing.T) {

View File

@ -17,10 +17,11 @@
package models
import (
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/web"
"fmt"
"net/http"
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/web"
)
// Generic

View File

@ -17,10 +17,11 @@
package models
import (
"time"
"code.vikunja.io/api/pkg/log"
"code.vikunja.io/api/pkg/user"
"code.vikunja.io/web"
"time"
"xorm.io/xorm"
)

View File

@ -17,10 +17,11 @@
package models
import (
"testing"
"code.vikunja.io/api/pkg/db"
"code.vikunja.io/api/pkg/user"
"github.com/stretchr/testify/assert"
"testing"
)
func TestBucket_ReadAll(t *testing.T) {

View File

@ -17,9 +17,10 @@
package models
import (
"time"
"code.vikunja.io/api/pkg/user"
"code.vikunja.io/web"
"time"
)
// Label represents a label

View File

@ -17,9 +17,10 @@
package models
import (
"time"
"code.vikunja.io/api/pkg/user"
"code.vikunja.io/web"
"time"
"xorm.io/builder"
)

View File

@ -1,14 +1,15 @@
package models
import (
"code.vikunja.io/api/pkg/db"
"code.vikunja.io/api/pkg/user"
"gopkg.in/d4l3k/messagediff.v1"
"reflect"
"runtime"
"testing"
"time"
"code.vikunja.io/api/pkg/db"
"code.vikunja.io/api/pkg/user"
"gopkg.in/d4l3k/messagediff.v1"
"code.vikunja.io/web"
)

View File

@ -17,14 +17,15 @@
package models
import (
"code.vikunja.io/api/pkg/db"
"code.vikunja.io/api/pkg/user"
"gopkg.in/d4l3k/messagediff.v1"
"reflect"
"runtime"
"testing"
"time"
"code.vikunja.io/api/pkg/db"
"code.vikunja.io/api/pkg/user"
"gopkg.in/d4l3k/messagediff.v1"
"code.vikunja.io/web"
)

View File

@ -18,11 +18,12 @@
package models
import (
"time"
"code.vikunja.io/api/pkg/user"
"code.vikunja.io/api/pkg/utils"
"code.vikunja.io/web"
"github.com/dgrijalva/jwt-go"
"time"
)
// SharingType holds the sharing type

View File

@ -17,12 +17,13 @@
package models
import (
"strings"
"time"
"code.vikunja.io/api/pkg/files"