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:
parent
497a3925e0
commit
55317504a1
17 changed files with 53 additions and 67 deletions
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue