From 386a27c0b6ab0789845f7ccc4f8e5c3e3b5eff4b Mon Sep 17 00:00:00 2001 From: sneak Date: Tue, 15 Jul 2025 06:06:48 +0200 Subject: [PATCH] fix: resolve all revive linter issues Added missing package comments: - cmd/secret/main.go - internal/cli/cli.go - internal/secret/constants.go - internal/vault/management.go - pkg/bip85/bip85.go Fixed comment format issues for exported items: - EnvStateDir, EnvMnemonic, EnvUnlockPassphrase, EnvGPGKeyID in constants.go - Metadata, UnlockerMetadata, SecretMetadata, Configuration in metadata.go - AppBIP39, AppHDWIF, AppXPRV in bip85.go Replaced unused parameters with underscore (_): - generate.go:39 - parameter 'args' - init.go:30 - parameter 'args' - unlockers.go:39,77,102 - parameter 'args' or 'cmd' - vault.go:37 - parameter 'args' - management.go:34 - parameter 'target' --- cmd/secret/main.go | 1 + internal/cli/cli.go | 1 + internal/cli/generate.go | 2 +- internal/cli/init.go | 2 +- internal/cli/unlockers.go | 6 +++--- internal/cli/vault.go | 2 +- internal/secret/constants.go | 12 ++++++++---- internal/vault/management.go | 3 ++- internal/vault/metadata.go | 18 +++++++++++------- pkg/bip85/bip85.go | 11 +++++++---- 10 files changed, 36 insertions(+), 22 deletions(-) diff --git a/cmd/secret/main.go b/cmd/secret/main.go index 734b532..dd909ab 100644 --- a/cmd/secret/main.go +++ b/cmd/secret/main.go @@ -1,3 +1,4 @@ +// Package main is the entry point for the secret CLI application. package main import "git.eeqj.de/sneak/secret/internal/cli" diff --git a/internal/cli/cli.go b/internal/cli/cli.go index 5ce82d6..ec120fb 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -1,3 +1,4 @@ +// Package cli implements the command-line interface for the secret application. package cli import ( diff --git a/internal/cli/generate.go b/internal/cli/generate.go index 2302023..06d1fb8 100644 --- a/internal/cli/generate.go +++ b/internal/cli/generate.go @@ -36,7 +36,7 @@ func newGenerateMnemonicCmd() *cobra.Command { Long: `Generate a cryptographically secure random BIP39 ` + `mnemonic phrase that can be used with 'secret init' ` + `or 'secret import'.`, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { cli := NewCLIInstance() return cli.GenerateMnemonic(cmd) diff --git a/internal/cli/init.go b/internal/cli/init.go index f668274..ef51820 100644 --- a/internal/cli/init.go +++ b/internal/cli/init.go @@ -27,7 +27,7 @@ func NewInitCmd() *cobra.Command { } // RunInit is the exported function that handles the init command -func RunInit(cmd *cobra.Command, args []string) error { +func RunInit(cmd *cobra.Command, _ []string) error { cli := NewCLIInstance() return cli.Init(cmd) diff --git a/internal/cli/unlockers.go b/internal/cli/unlockers.go index 4a69916..2415342 100644 --- a/internal/cli/unlockers.go +++ b/internal/cli/unlockers.go @@ -36,7 +36,7 @@ func newUnlockersListCmd() *cobra.Command { cmd := &cobra.Command{ Use: "list", Short: "List unlockers in the current vault", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { jsonOutput, _ := cmd.Flags().GetBool("json") cli := NewCLIInstance() @@ -74,7 +74,7 @@ func newUnlockersRmCmd() *cobra.Command { Use: "rm ", Short: "Remove an unlocker", Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, args []string) error { cli := NewCLIInstance() return cli.UnlockersRemove(args[0]) @@ -99,7 +99,7 @@ func newUnlockerSelectSubCmd() *cobra.Command { Use: "select ", Short: "Select an unlocker as current", Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, args []string) error { cli := NewCLIInstance() return cli.UnlockerSelect(args[0]) diff --git a/internal/cli/vault.go b/internal/cli/vault.go index 52fc129..30d9e7b 100644 --- a/internal/cli/vault.go +++ b/internal/cli/vault.go @@ -34,7 +34,7 @@ func newVaultListCmd() *cobra.Command { cmd := &cobra.Command{ Use: "list", Short: "List available vaults", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { jsonOutput, _ := cmd.Flags().GetBool("json") cli := NewCLIInstance() diff --git a/internal/secret/constants.go b/internal/secret/constants.go index 3422b27..7e82a80 100644 --- a/internal/secret/constants.go +++ b/internal/secret/constants.go @@ -1,3 +1,4 @@ +// Package secret provides core types and constants for the secret application. package secret import "os" @@ -6,11 +7,14 @@ const ( // AppID is the unique identifier for this application AppID = "berlin.sneak.pkg.secret" - // Environment variable names - EnvStateDir = "SB_SECRET_STATE_DIR" - EnvMnemonic = "SB_SECRET_MNEMONIC" + // EnvStateDir is the environment variable for specifying the state directory + EnvStateDir = "SB_SECRET_STATE_DIR" + // EnvMnemonic is the environment variable for providing the mnemonic phrase + EnvMnemonic = "SB_SECRET_MNEMONIC" + // EnvUnlockPassphrase is the environment variable for providing the unlock passphrase EnvUnlockPassphrase = "SB_UNLOCK_PASSPHRASE" //nolint:gosec // G101: This is an env var name, not a credential - EnvGPGKeyID = "SB_GPG_KEY_ID" + // EnvGPGKeyID is the environment variable for providing the GPG key ID + EnvGPGKeyID = "SB_GPG_KEY_ID" ) // File system permission constants diff --git a/internal/vault/management.go b/internal/vault/management.go index 024b924..0855540 100644 --- a/internal/vault/management.go +++ b/internal/vault/management.go @@ -1,3 +1,4 @@ +// Package vault provides functionality for managing encrypted vaults. package vault import ( @@ -31,7 +32,7 @@ func isValidVaultName(name string) bool { } // resolveRelativeSymlink resolves a relative symlink target to an absolute path -func resolveRelativeSymlink(symlinkPath, target string) (string, error) { +func resolveRelativeSymlink(symlinkPath, _ string) (string, error) { // Get the current directory before changing originalDir, err := os.Getwd() if err != nil { diff --git a/internal/vault/metadata.go b/internal/vault/metadata.go index 525a133..4c0fffb 100644 --- a/internal/vault/metadata.go +++ b/internal/vault/metadata.go @@ -12,13 +12,17 @@ import ( "github.com/spf13/afero" ) -// Alias the metadata types from secret package for convenience -type ( - Metadata = secret.VaultMetadata - UnlockerMetadata = secret.UnlockerMetadata - SecretMetadata = secret.Metadata - Configuration = secret.Configuration -) +// Metadata is an alias for secret.VaultMetadata +type Metadata = secret.VaultMetadata + +// UnlockerMetadata is an alias for secret.UnlockerMetadata +type UnlockerMetadata = secret.UnlockerMetadata + +// SecretMetadata is an alias for secret.Metadata +type SecretMetadata = secret.Metadata + +// Configuration is an alias for secret.Configuration +type Configuration = secret.Configuration // ComputeDoubleSHA256 computes the double SHA256 hash of data and returns it as hex func ComputeDoubleSHA256(data []byte) string { diff --git a/pkg/bip85/bip85.go b/pkg/bip85/bip85.go index 63c03eb..7911dc9 100644 --- a/pkg/bip85/bip85.go +++ b/pkg/bip85/bip85.go @@ -1,3 +1,4 @@ +// Package bip85 implements BIP85 deterministic entropy derivation. package bip85 import ( @@ -27,10 +28,12 @@ const ( // BIP85_KEY_HMAC_KEY is the HMAC key used for deriving the entropy BIP85_KEY_HMAC_KEY = "bip-entropy-from-k" //nolint:revive // ALL_CAPS used for BIP85 constants - // Application numbers - AppBIP39 = 39 // BIP39 mnemonics - AppHDWIF = 2 // WIF for Bitcoin Core - AppXPRV = 32 // Extended private key + // AppBIP39 is the application number for BIP39 mnemonics + AppBIP39 = 39 + // AppHDWIF is the application number for WIF (Wallet Import Format) for Bitcoin Core + AppHDWIF = 2 + // AppXPRV is the application number for extended private key + AppXPRV = 32 APP_HEX = 128169 //nolint:revive // ALL_CAPS used for BIP85 constants APP_PWD64 = 707764 // Base64 passwords //nolint:revive // ALL_CAPS used for BIP85 constants AppPWD85 = 707785 // Base85 passwords