From f9938135c62e504958ef6ec947877910556f274b Mon Sep 17 00:00:00 2001 From: sneak Date: Tue, 15 Jul 2025 06:33:25 +0200 Subject: [PATCH] fix: resolve all remaining linter issues (staticcheck, tagliatelle, lll) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix staticcheck QF1011: Remove explicit type declaration for io.Writer variables - Fix tagliatelle: Change all JSON tags from snake_case to camelCase - created_at → createdAt - keychain_item_name → keychainItemName - age_public_key → agePublicKey - age_priv_key_passphrase → agePrivKeyPassphrase - encrypted_longterm_key → encryptedLongtermKey - derivation_index → derivationIndex - public_key_hash → publicKeyHash - mnemonic_family_hash → mnemonicFamilyHash - gpg_key_id → gpgKeyId - Fix lll: Break long function signature line to stay under 120 character limit All linter issues have been resolved. The codebase now passes all linter checks. --- internal/cli/crypto.go | 4 ++-- internal/cli/unlockers.go | 2 +- internal/secret/keychainunlocker.go | 8 ++++---- internal/secret/metadata.go | 6 +++--- internal/secret/pgpunlocker.go | 2 +- internal/vault/management.go | 3 ++- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/internal/cli/crypto.go b/internal/cli/crypto.go index f3d4a70..691f326 100644 --- a/internal/cli/crypto.go +++ b/internal/cli/crypto.go @@ -124,7 +124,7 @@ func (cli *Instance) Encrypt(secretName, inputFile, outputFile string) error { } // Set up output writer - var output io.Writer = cli.cmd.OutOrStdout() + output := cli.cmd.OutOrStdout() if outputFile != "" { file, err := cli.fs.Create(outputFile) if err != nil { @@ -210,7 +210,7 @@ func (cli *Instance) Decrypt(secretName, inputFile, outputFile string) error { } // Set up output writer - var output io.Writer = cli.cmd.OutOrStdout() + output := cli.cmd.OutOrStdout() if outputFile != "" { file, err := cli.fs.Create(outputFile) if err != nil { diff --git a/internal/cli/unlockers.go b/internal/cli/unlockers.go index 2415342..e407c75 100644 --- a/internal/cli/unlockers.go +++ b/internal/cli/unlockers.go @@ -125,7 +125,7 @@ func (cli *Instance) UnlockersList(jsonOutput bool) error { type UnlockerInfo struct { ID string `json:"id"` Type string `json:"type"` - CreatedAt time.Time `json:"created_at"` + CreatedAt time.Time `json:"createdAt"` Flags []string `json:"flags,omitempty"` } diff --git a/internal/secret/keychainunlocker.go b/internal/secret/keychainunlocker.go index dff17a6..4402739 100644 --- a/internal/secret/keychainunlocker.go +++ b/internal/secret/keychainunlocker.go @@ -28,7 +28,7 @@ var keychainItemNameRegex = regexp.MustCompile(`^[A-Za-z0-9._-]+$`) type KeychainUnlockerMetadata struct { UnlockerMetadata // Keychain item name - KeychainItemName string `json:"keychain_item_name"` + KeychainItemName string `json:"keychainItemName"` } // KeychainUnlocker represents a macOS Keychain-protected unlocker @@ -40,9 +40,9 @@ type KeychainUnlocker struct { // KeychainData represents the data stored in the macOS keychain type KeychainData struct { - AgePublicKey string `json:"age_public_key"` - AgePrivKeyPassphrase string `json:"age_priv_key_passphrase"` - EncryptedLongtermKey string `json:"encrypted_longterm_key"` + AgePublicKey string `json:"agePublicKey"` + AgePrivKeyPassphrase string `json:"agePrivKeyPassphrase"` + EncryptedLongtermKey string `json:"encryptedLongtermKey"` } // GetIdentity implements Unlocker interface for Keychain-based unlockers diff --git a/internal/secret/metadata.go b/internal/secret/metadata.go index b1996a7..3699a61 100644 --- a/internal/secret/metadata.go +++ b/internal/secret/metadata.go @@ -8,11 +8,11 @@ import ( type VaultMetadata struct { CreatedAt time.Time `json:"createdAt"` Description string `json:"description,omitempty"` - DerivationIndex uint32 `json:"derivation_index"` + DerivationIndex uint32 `json:"derivationIndex"` // Double SHA256 hash of the actual long-term public key - PublicKeyHash string `json:"public_key_hash,omitempty"` + PublicKeyHash string `json:"publicKeyHash,omitempty"` // Double SHA256 hash of index-0 key (for grouping vaults from same mnemonic) - MnemonicFamilyHash string `json:"mnemonic_family_hash,omitempty"` + MnemonicFamilyHash string `json:"mnemonicFamilyHash,omitempty"` } // UnlockerMetadata contains information about an unlocker diff --git a/internal/secret/pgpunlocker.go b/internal/secret/pgpunlocker.go index 163e7d8..a938b12 100644 --- a/internal/secret/pgpunlocker.go +++ b/internal/secret/pgpunlocker.go @@ -43,7 +43,7 @@ var ( type PGPUnlockerMetadata struct { UnlockerMetadata // GPG key ID used for encryption - GPGKeyID string `json:"gpg_key_id"` + GPGKeyID string `json:"gpgKeyId"` } // PGPUnlocker represents a PGP-protected unlocker diff --git a/internal/vault/management.go b/internal/vault/management.go index 0855540..cb82bbd 100644 --- a/internal/vault/management.go +++ b/internal/vault/management.go @@ -197,7 +197,8 @@ func ListVaults(fs afero.Fs, stateDir string) ([]string, error) { } // processMnemonicForVault handles mnemonic processing for vault creation -func processMnemonicForVault(fs afero.Fs, stateDir, vaultDir, vaultName string) (derivationIndex uint32, publicKeyHash string, familyHash string, err error) { +func processMnemonicForVault(fs afero.Fs, stateDir, vaultDir, vaultName string) ( + derivationIndex uint32, publicKeyHash string, familyHash string, err error) { // Check if mnemonic is available in environment mnemonic := os.Getenv(secret.EnvMnemonic)