Skip to content

Commit 4d9f136

Browse files
committed
fix: text formatting of nameless exec and linting
1 parent 54b8c35 commit 4d9f136

File tree

8 files changed

+28
-11
lines changed

8 files changed

+28
-11
lines changed

.github/workflows/analyze.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
- name: golangci-lint
5555
uses: golangci/golangci-lint-action@v6
5656
with:
57-
version: v1.60.3
57+
version: v1.64.5
5858
args: --out-format=sarif:results.sarif,colored-line-number,github-actions
5959
- name: Upload SARIF file
6060
uses: github/codeql-action/upload-sarif@v3

.golangci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ issues:
9292
- gosec
9393
- noctx
9494
- wrapcheck
95+
- linters: [gosec]
96+
text: "G115"
9597
- linters:
9698
- staticcheck
9799
text: "SA5011" # SA5011: Should not use unsafe.Pointer - this throws false positives when a nil check does not result in a return

cmd/internal/flags/helpers.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/jahvon/flow/internal/context"
1111
)
1212

13+
//nolint:errcheck
1314
func ToPflag(cmd *cobra.Command, metadata Metadata, persistent bool) (*pflag.FlagSet, error) {
1415
flagSet := cmd.Flags()
1516
if persistent {
@@ -66,6 +67,7 @@ func ToPflag(cmd *cobra.Command, metadata Metadata, persistent bool) (*pflag.Fla
6667
return flagSet, nil
6768
}
6869

70+
//nolint:errcheck
6971
func ValueFor[T any](ctx *context.Context, cmd *cobra.Command, metadata Metadata, persistent bool) T {
7072
logger := ctx.Logger
7173
flagName := metadata.Name

cmd/internal/flags/helpers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ var _ = Describe("ValueFor", func() {
7171
Expect(err).NotTo(HaveOccurred())
7272
cmd.Flags().AddFlagSet(flagset)
7373
if reflect.TypeOf(expectedValue).Kind() == reflect.Slice {
74-
err = cmd.ParseFlags([]string{"--test", expectedValue.([]string)[0]})
74+
err = cmd.ParseFlags([]string{"--test", expectedValue.([]string)[0]}) //nolint:errcheck
7575
} else {
7676
err = cmd.ParseFlags([]string{"--test=" + fmt.Sprintf("%v", expectedValue)})
7777
}

internal/crypto/crypto.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func EncryptValue(encryptionKey string, text string) (string, error) {
7878
return "", fmt.Errorf("error reading random bytes: %w", err)
7979
}
8080

81-
cfb := cipher.NewCFBEncrypter(block, iv)
81+
cfb := cipher.NewCTR(block, iv)
8282
cfb.XORKeyStream(ciphertext[aes.BlockSize:], plaintext)
8383
return string(ciphertext), nil
8484
}
@@ -103,7 +103,7 @@ func DecryptValue(encryptionKey string, text string) (string, error) {
103103
iv := ciphertext[:aes.BlockSize]
104104
ciphertext = ciphertext[aes.BlockSize:]
105105

106-
cfb := cipher.NewCFBDecrypter(block, iv)
106+
cfb := cipher.NewCTR(block, iv)
107107
cfb.XORKeyStream(plainText, ciphertext)
108108
return string(plainText), nil
109109
}

internal/crypto/crypto_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package crypto_test
33
import (
44
"testing"
55

6-
"github.com/jahvon/flow/internal/crypto"
76
. "github.com/onsi/ginkgo/v2"
87
. "github.com/onsi/gomega"
8+
9+
"github.com/jahvon/flow/internal/crypto"
910
)
1011

1112
func TestCrypto(t *testing.T) {

internal/io/library/view.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var (
4141
func (l *Library) View() string {
4242
l.paneZeroViewport.Style = paneStyle(0, l.theme, l.splitView)
4343
l.paneZeroViewport.SetContent(l.paneZeroContent())
44-
l.paneZeroViewport.SetYOffset(int(l.currentWorkspace + l.currentNamespace)) //nolint:gosec
44+
l.paneZeroViewport.SetYOffset(int(l.currentWorkspace + l.currentNamespace))
4545

4646
l.paneOneViewport.Style = paneStyle(1, l.theme, l.splitView)
4747
l.paneOneViewport.SetContent(l.paneOneContent())

types/executable/executable.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -504,11 +504,23 @@ func MustParseExecutableID(id string) (workspace, namespace, name string) {
504504
}
505505

506506
func NewExecutableID(workspace, namespace, name string) string {
507-
if namespace == "" || namespace == WildcardNamespace {
508-
return fmt.Sprintf("%s/%s", workspace, name)
507+
var ws, ns string
508+
if namespace != "" && namespace != WildcardNamespace {
509+
ns = namespace
509510
}
510-
if workspace == "" || workspace == WildcardWorkspace {
511-
return fmt.Sprintf("%s:%s", namespace, name)
511+
if workspace != "" && workspace != WildcardWorkspace {
512+
ws = workspace
513+
}
514+
515+
switch {
516+
case ws == "", ns != "" && name == "":
517+
return "" // TODO: return error or log warning
518+
case ns != "":
519+
return fmt.Sprintf("%s/%s:%s", ws, ns, name)
520+
case name != "":
521+
return fmt.Sprintf("%s/%s", ws, name)
522+
default: // ws != "" && ns == "" && name == ""
523+
// for now, exclude the workspace from the string (until we can indicate that it's root / not named in the tui)
524+
return ""
512525
}
513-
return fmt.Sprintf("%s/%s:%s", workspace, namespace, name)
514526
}

0 commit comments

Comments
 (0)