1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-03 23:56:22 -07:00

Fix anti-patterns pointed out by DeepSource

But not the switch fallthroughs/expression lists, there's no benefit
This commit is contained in:
Eggbertx 2020-07-09 15:54:31 -07:00
parent 497a3925e0
commit 55317504a1
17 changed files with 53 additions and 67 deletions

View file

@ -7,7 +7,7 @@ import (
"github.com/gochan-org/gochan/pkg/gcsql"
)
func versionHandler(foundDatabaseVersion int, targetDatabaseVersion int) error {
func versionHandler(foundDatabaseVersion, targetDatabaseVersion int) error {
if foundDatabaseVersion < targetDatabaseVersion {
for foundDatabaseVersion < targetDatabaseVersion {
gclog.Printf(gclog.LStdLog, "Migrating databasefrom version %v to version %v", foundDatabaseVersion, foundDatabaseVersion+1)
@ -29,7 +29,7 @@ func versionHandler(foundDatabaseVersion int, targetDatabaseVersion int) error {
return nil
}
func checkMigrationsExist(currentVersion int, target int) error {
func checkMigrationsExist(currentVersion, target int) error {
for i := currentVersion; i < target; i++ {
if _, ok := migrations[i]; !ok {
return fmt.Errorf("This version of the migrator does not contain a migration from version %v to %v, please upgrade the migrator", currentVersion, target)

View file

@ -90,13 +90,13 @@ func fixPostLinkingOnBoard(boardID int) error {
}
jumptable := make(map[int]int)
for rows.Next() {
var old int
var new int
err = rows.Scan(&old, &new)
var oldTable int
var newTable int
err = rows.Scan(&oldTable, &newTable)
if err != nil {
return err
}
jumptable[old] = new
jumptable[oldTable] = newTable
}
jumpTableFunc := func(intstring string) string {

View file

@ -4,7 +4,7 @@ import (
"github.com/gochan-org/gochan/pkg/gcsql"
)
func renameTable(tablename string, tableNameNew string) error {
func renameTable(tablename, tableNameNew string) error {
var sql = "ALTER TABLE DBPREFIX" + tablename + " RENAME TO DBPREFIX" + tableNameNew
_, err := gcsql.ExecSQL(sql)
return err