Skip to content

Commit 0b8c25d

Browse files
committed
Lint
1 parent 022a5b9 commit 0b8c25d

5 files changed

Lines changed: 32 additions & 37 deletions

File tree

internal/cli/experiments.go

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ var (
2929
}
3030

3131
experimentDescription = Flag{
32-
Name: "Description",
33-
LongForm: "description",
32+
Name: "Description",
33+
LongForm: "description",
3434
ShortForm: "d",
35-
Help: "Description of the experiment.",
35+
Help: "Description of the experiment.",
3636
}
3737

3838
experimentFeatureFlagID = Flag{
@@ -60,17 +60,9 @@ var (
6060
}
6161

6262
experimentAllocations = Flag{
63-
Name: "Allocations",
64-
LongForm: "allocations",
65-
ShortForm: "A",
66-
Help: `Allocations as JSON array. Example: '[{"variation_id":"vid","weight":1.0,"is_control":true}]'`,
67-
IsRequired: true,
68-
}
69-
70-
experimentStatusFilter = Flag{
71-
Name: "Status",
72-
LongForm: "status",
73-
Help: "Filter by status (draft, active, paused, completed, archived).",
63+
Name: "Allocations",
64+
LongForm: "allocations",
65+
Help: "JSON array of allocation items ({variation_id, weight, is_control} for percentage; {variation_id, segment_id, is_control} for segment).",
7466
}
7567
)
7668

@@ -104,8 +96,8 @@ func experimentsCmd(cli *cli) *cobra.Command {
10496

10597
func listExperimentsCmd(cli *cli) *cobra.Command {
10698
var inputs struct {
107-
Status string
108-
FeatureFlagID string
99+
Status string
100+
FeatureFlagID string
109101
AuthenticationFlow string
110102
}
111103

@@ -675,7 +667,8 @@ func (c *cli) buildAllocationsInteractively(cmd *cobra.Command, featureFlagID st
675667
IsControl: isControl,
676668
}
677669

678-
if strategy == "percentage" {
670+
switch strategy {
671+
case "percentage":
679672
defaultWeight := fmt.Sprintf("%.4f", 1.0/float64(len(variations.GetVariations())))
680673
var weightStr string
681674
q := prompt.TextInput(
@@ -696,8 +689,8 @@ func (c *cli) buildAllocationsInteractively(cmd *cobra.Command, featureFlagID st
696689
return nil, fmt.Errorf("invalid weight %q: must be a decimal between 0.0 and 1.0", weightStr)
697690
}
698691
alloc.Weight = &weight
699-
} else if strategy == "segment" {
700-
// segment_id is optional — fetch available segments and offer a picker
692+
case "segment":
693+
// Segment_id is optional — fetch available segments and offer a picker
701694
// with a "No segment" escape hatch. If no segments exist at all, skip silently.
702695
segOpts, err := c.segmentPickerOptions(ctx)
703696
if err != nil {

internal/cli/experiments_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ func TestExperimentsListCmd(t *testing.T) {
2929
name: "it successfully lists experiments",
3030
experiments: []*management.ExperimentListItem{
3131
{
32-
ID: "exp_001",
33-
Name: "button-color",
34-
Status: management.ExperimentStatusEnumDraft,
35-
FeatureFlagID: "ff_001",
36-
IsValid: false,
32+
ID: "exp_001",
33+
Name: "button-color",
34+
Status: management.ExperimentStatusEnumDraft,
35+
FeatureFlagID: "ff_001",
36+
IsValid: false,
3737
},
3838
{
39-
ID: "exp_002",
40-
Name: "checkout-flow",
41-
Status: management.ExperimentStatusEnumActive,
42-
FeatureFlagID: "ff_002",
43-
IsValid: true,
39+
ID: "exp_002",
40+
Name: "checkout-flow",
41+
Status: management.ExperimentStatusEnumActive,
42+
FeatureFlagID: "ff_002",
43+
IsValid: true,
4444
},
4545
},
4646
assertOutput: func(t testing.TB, out string) {

internal/cli/feature_flags_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ func TestFeatureFlagsUpdateCmd(t *testing.T) {
278278
expectedError: "nothing to update",
279279
},
280280
{
281-
name: "it returns an error when --parameters is invalid JSON",
282-
args: []string{flagID, "--parameters", "not-json"},
281+
name: "it returns an error when --parameters is invalid JSON",
282+
args: []string{flagID, "--parameters", "not-json"},
283283
expectedError: "invalid JSON for --parameters",
284284
},
285285
{

internal/cli/segments.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ var (
2929
}
3030

3131
segmentDescription = Flag{
32-
Name: "Description",
33-
LongForm: "description",
32+
Name: "Description",
33+
LongForm: "description",
3434
ShortForm: "d",
35-
Help: "Description of the segment.",
35+
Help: "Description of the segment.",
3636
}
3737

3838
segmentRules = Flag{

internal/display/experiments.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,13 @@ func formatAllocations(allocations []*management.AllocationItem) string {
9292
} else if a.GetIsFallback() {
9393
role = " (fallback)"
9494
}
95-
if a.GetWeight() > 0 {
95+
96+
switch {
97+
case a.GetWeight() > 0:
9698
part = fmt.Sprintf("%s%s %.0f%%", a.GetVariationID(), role, a.GetWeight()*100)
97-
} else if a.GetSegmentID() != "" {
99+
case a.GetSegmentID() != "":
98100
part = fmt.Sprintf("%s%s → segment:%s", a.GetVariationID(), role, a.GetSegmentID())
99-
} else {
101+
default:
100102
part = a.GetVariationID() + role
101103
}
102104
parts = append(parts, part)

0 commit comments

Comments
 (0)