Commit 7cc2df92 authored by Johnny's avatar Johnny

chore: fix linter

parent 3d1c1977
......@@ -12,23 +12,17 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/usememos/memos/internal/profile"
"github.com/usem fmt.Println()
fmt.Printf("Documentation: %s\n", "https://usememos.com")
fmt.Printf("Source code: %s\n", "https://github.com/usememos/memos")
fmt.Println("\nHappy note-taking!")/memos/internal/profile"
"github.com/usememos/memos/internal/version"
"github.com/usememos/memos/server"
"github.com/usememos/memos/store"
"github.com/usememos/memos/store/db"
)
const (
greetingBanner = `
███╗ ███╗███████╗███╗ ███╗ ██████╗ ███████╗
████╗ ████║██╔════╝████╗ ████║██╔═══██╗██╔════╝
██╔████╔██║█████╗ ██╔████╔██║██║ ██║███████╗
██║╚██╔╝██║██╔══╝ ██║╚██╔╝██║██║ ██║╚════██║
██║ ╚═╝ ██║███████╗██║ ╚═╝ ██║╚██████╔╝███████║
╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚══════╝
`
)
var (
rootCmd = &cobra.Command{
......@@ -146,38 +140,37 @@ func init() {
}
func printGreetings(profile *profile.Profile) {
fmt.Printf("Memos %s started successfully!\n", profile.Version)
if profile.IsDev() {
println("Development mode is enabled")
println("DSN: ", profile.DSN)
fmt.Fprintf(os.Stderr, "Development mode is enabled\n")
if profile.DSN != "" {
fmt.Fprintf(os.Stderr, "Database: %s\n", profile.DSN)
}
}
fmt.Printf(`---
Server profile
version: %s
data: %s
addr: %s
port: %d
unix-sock: %s
mode: %s
driver: %s
---
`, profile.Version, profile.Data, profile.Addr, profile.Port, profile.UNIXSock, profile.Mode, profile.Driver)
print(greetingBanner)
// Server information
fmt.Printf("Data directory: %s\n", profile.Data)
fmt.Printf("Database driver: %s\n", profile.Driver)
fmt.Printf("Mode: %s\n", profile.Mode)
// Connection information
if len(profile.UNIXSock) == 0 {
if len(profile.Addr) == 0 {
fmt.Printf("Version %s has been started on port %d\n", profile.Version, profile.Port)
fmt.Printf("Server running on port %d\n", profile.Port)
fmt.Printf("Access your memos at: http://localhost:%d\n", profile.Port)
} else {
fmt.Printf("Version %s has been started on address '%s' and port %d\n", profile.Version, profile.Addr, profile.Port)
fmt.Printf("Server running on %s:%d\n", profile.Addr, profile.Port)
fmt.Printf("Access your memos at: http://%s:%d\n", profile.Addr, profile.Port)
}
} else {
fmt.Printf("Version %s has been started on unix socket %s\n", profile.Version, profile.UNIXSock)
fmt.Printf("Server running on unix socket: %s\n", profile.UNIXSock)
}
fmt.Printf(`---
See more in:
👉Website: %s
👉GitHub: %s
---
`, "https://usememos.com", "https://github.com/usememos/memos")
fmt.Println()
fmt.Printf("� Documentation: %s\n", "https://usememos.com")
fmt.Printf("💻 Source code: %s\n", "https://github.com/usememos/memos")
fmt.Println("\n✨ Happy note-taking!")
}
func main() {
......
package util
package util //nolint:revive // util is an appropriate package name for utility functions
import (
"testing"
......
......@@ -420,6 +420,8 @@ func parseDescriptor(descriptor string, loc *time.Location) (Schedule, error) {
Dow: all(dow),
Location: loc,
}, nil
default:
// Continue to check @every prefix below
}
const every = "@every "
......
......@@ -45,6 +45,8 @@ func (c *CommonSQLConverter) ConvertExprToSQL(ctx *ConvertContext, expr *exprv1.
return c.handleInOperator(ctx, v.CallExpr)
case "contains":
return c.handleContainsOperator(ctx, v.CallExpr)
default:
return errors.Errorf("unsupported call expression function: %s", v.CallExpr.Function)
}
} else if v, ok := expr.ExprKind.(*exprv1.Expr_IdentExpr); ok {
return c.handleIdentifier(ctx, v.IdentExpr)
......@@ -144,9 +146,9 @@ func (c *CommonSQLConverter) handleComparisonOperator(ctx *ConvertContext, callE
return c.handlePinnedComparison(ctx, operator, value)
case "has_task_list", "has_link", "has_code", "has_incomplete_tasks":
return c.handleBooleanComparison(ctx, identifier, operator, value)
default:
return errors.Errorf("unsupported identifier in comparison: %s", identifier)
}
return nil
}
func (c *CommonSQLConverter) handleSizeComparison(ctx *ConvertContext, callExpr *exprv1.Expr_Call, sizeCall *exprv1.Expr_Call) error {
......@@ -567,6 +569,8 @@ func (c *CommonSQLConverter) handleBooleanComparison(ctx *ConvertContext, field,
jsonPath = "$.property.hasCode"
case "has_incomplete_tasks":
jsonPath = "$.property.hasIncompleteTasks"
default:
return errors.Errorf("unsupported boolean field: %s", field)
}
// Special handling for SQLite based on field
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.7
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: api/v1/activity_service.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.7
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: api/v1/attachment_service.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.7
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: api/v1/auth_service.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.7
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: api/v1/common.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.7
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: api/v1/idp_service.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.7
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: api/v1/inbox_service.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.7
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: api/v1/markdown_service.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.7
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: api/v1/memo_service.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.7
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: api/v1/shortcut_service.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.7
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: api/v1/user_service.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.7
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: api/v1/workspace_service.proto
......
This diff is collapsed.
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.7
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: store/activity.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.7
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: store/attachment.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.7
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: store/idp.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.7
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: store/inbox.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.7
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: store/memo.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.7
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: store/user_setting.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.7
// protoc-gen-go v1.36.8
// protoc (unknown)
// source: store/workspace_setting.proto
......
......@@ -582,8 +582,9 @@ func replaceFilenameWithPathTemplate(path, filename string) string {
return fmt.Sprintf("%02d", t.Second())
case "{uuid}":
return util.GenUUID()
default:
return s
}
return s
})
return path
}
......
......@@ -162,7 +162,7 @@ func TestClientInfoExamples(t *testing.T) {
t.Logf("Device Type: %s", clientInfo.DeviceType)
t.Logf("Operating System: %s", clientInfo.Os)
t.Logf("Browser: %s", clientInfo.Browser)
t.Logf("---")
t.Log("---")
// Ensure all fields are populated
if clientInfo.DeviceType == "" {
......
......@@ -82,6 +82,8 @@ func (s *APIV1Service) UpdateIdentityProvider(ctx context.Context, request *v1pb
update.IdentifierFilter = &request.IdentityProvider.IdentifierFilter
case "config":
update.Config = convertIdentityProviderConfigToStore(request.IdentityProvider.Type, request.IdentityProvider.Config)
default:
// Ignore unsupported fields
}
}
......
......@@ -405,6 +405,8 @@ func (s *APIV1Service) UpdateUserSetting(ctx context.Context, request *v1pb.Upda
updatedGeneral.Theme = incomingGeneral.Theme
case "locale":
updatedGeneral.Locale = incomingGeneral.Locale
default:
// Ignore unsupported fields
}
}
......@@ -899,6 +901,8 @@ func (s *APIV1Service) UpdateUserWebhook(ctx context.Context, request *v1pb.Upda
}
case "display_name":
updatedWebhook.Title = request.Webhook.DisplayName
default:
// Ignore unsupported fields
}
}
} else {
......@@ -1143,6 +1147,11 @@ func convertUserSettingFromStore(storeSetting *storepb.UserSetting, userID int32
Webhooks: []*v1pb.UserWebhook{},
},
}
default:
// Default to general setting
setting.Value = &v1pb.UserSetting_GeneralSetting_{
GeneralSetting: getDefaultUserGeneralSetting(),
}
}
return setting
}
......@@ -1223,6 +1232,11 @@ func convertUserSettingFromStore(storeSetting *storepb.UserSetting, userID int32
Webhooks: apiWebhooks,
},
}
default:
// Default to general setting if unknown key
setting.Value = &v1pb.UserSetting_GeneralSetting_{
GeneralSetting: getDefaultUserGeneralSetting(),
}
}
return setting
......
......@@ -141,6 +141,8 @@ func convertWorkspaceSettingToStore(setting *v1pb.WorkspaceSetting) *storepb.Wor
workspaceSetting.Value = &storepb.WorkspaceSetting_MemoRelatedSetting{
MemoRelatedSetting: convertWorkspaceMemoRelatedSettingToStore(setting.GetMemoRelatedSetting()),
}
default:
// Keep the default GeneralSetting value
}
return workspaceSetting
}
......
......@@ -31,30 +31,30 @@ func TestCacheBasicOperations(t *testing.T) {
// Test Delete
cache.Delete(ctx, "key1")
if _, ok := cache.Get(ctx, "key1"); ok {
t.Errorf("Key 'key1' should have been deleted")
t.Error("Key 'key1' should have been deleted")
}
// Test automatic expiration
time.Sleep(150 * time.Millisecond)
if _, ok := cache.Get(ctx, "key1"); ok {
t.Errorf("Key 'key1' should have expired")
t.Error("Key 'key1' should have expired")
}
// key2 should still be valid (200ms TTL)
if _, ok := cache.Get(ctx, "key2"); !ok {
t.Errorf("Key 'key2' should still be valid")
t.Error("Key 'key2' should still be valid")
}
// Wait for key2 to expire
time.Sleep(100 * time.Millisecond)
if _, ok := cache.Get(ctx, "key2"); ok {
t.Errorf("Key 'key2' should have expired")
t.Error("Key 'key2' should have expired")
}
// Test Clear
cache.Set(ctx, "key3", "value3")
cache.Clear(ctx)
if _, ok := cache.Get(ctx, "key3"); ok {
t.Errorf("Cache should be empty after Clear()")
t.Error("Cache should be empty after Clear()")
}
}
......@@ -98,15 +98,15 @@ func TestCacheEviction(t *testing.T) {
}
if evictedCount == 0 {
t.Errorf("No keys were evicted despite exceeding max items")
t.Error("No keys were evicted despite exceeding max items")
}
// The newer keys should still be present
if _, ok := cache.Get(ctx, "keyA"); !ok {
t.Errorf("Key 'keyA' should be in the cache")
t.Error("Key 'keyA' should be in the cache")
}
if _, ok := cache.Get(ctx, "keyB"); !ok {
t.Errorf("Key 'keyB' should be in the cache")
t.Error("Key 'keyB' should be in the cache")
}
}
......@@ -193,7 +193,7 @@ func TestEvictionCallback(t *testing.T) {
time.Sleep(10 * time.Millisecond) // Small delay to ensure callback processed
evictedMu.Lock()
if evicted["key1"] != "value1" {
t.Errorf("Eviction callback not triggered for manual deletion")
t.Error("Eviction callback not triggered for manual deletion")
}
evictedMu.Unlock()
......@@ -203,7 +203,7 @@ func TestEvictionCallback(t *testing.T) {
// Verify TTL expiration triggered callback
evictedMu.Lock()
if evicted["key2"] != "value2" {
t.Errorf("Eviction callback not triggered for TTL expiration")
t.Error("Eviction callback not triggered for TTL expiration")
}
evictedMu.Unlock()
}
......@@ -29,8 +29,9 @@ func (v Visibility) String() string {
return "PROTECTED"
case Private:
return "PRIVATE"
default:
return "PRIVATE"
}
return "PRIVATE"
}
type Memo struct {
......
......@@ -102,6 +102,8 @@ func (s *Store) Migrate(ctx context.Context) error {
if err := s.seed(ctx); err != nil {
return errors.Wrap(err, "failed to seed")
}
default:
// For other modes (like dev), no special migration handling needed
}
return nil
}
......
......@@ -24,8 +24,9 @@ func (e Role) String() string {
return "ADMIN"
case RoleUser:
return "USER"
default:
return "USER"
}
return "USER"
}
const (
......
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