Skip to content

Commit bb01f73

Browse files
vojtabiberleclaude
andcommitted
DMD-919 - Refactor fetcher.go to avoid else-if and use inverted conditions
- Remove else blocks by assigning directly to struct fields - Use continue with nil check instead of nested if - Follows Go convention of early returns Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f1fd2c9 commit bb01f73

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

internal/pkg/llm/twinformat/fetcher.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,30 +60,24 @@ func (f *Fetcher) FetchAll(ctx context.Context, branchID keboola.BranchID) (data
6060
data.Tables = tables
6161

6262
// Fetch jobs from Queue API
63-
jobs, err := f.fetchJobsQueue(ctx, branchID)
63+
data.Jobs, err = f.fetchJobsQueue(ctx, branchID)
6464
if err != nil {
6565
f.logger.Warnf(ctx, "Failed to fetch jobs from Queue API: %v", err)
6666
data.Jobs = []*keboola.QueueJob{}
67-
} else {
68-
data.Jobs = jobs
6967
}
7068

7169
// Fetch transformation configs
72-
transformConfigs, err := f.FetchTransformationConfigs(ctx, branchID)
70+
data.TransformationConfigs, err = f.FetchTransformationConfigs(ctx, branchID)
7371
if err != nil {
7472
f.logger.Warnf(ctx, "Failed to fetch transformation configs: %v", err)
7573
data.TransformationConfigs = []*configparser.TransformationConfig{}
76-
} else {
77-
data.TransformationConfigs = transformConfigs
7874
}
7975

8076
// Fetch component configs
81-
componentConfigs, err := f.FetchComponentConfigs(ctx, branchID)
77+
data.ComponentConfigs, err = f.FetchComponentConfigs(ctx, branchID)
8278
if err != nil {
8379
f.logger.Warnf(ctx, "Failed to fetch component configs: %v", err)
8480
data.ComponentConfigs = []*configparser.ComponentConfig{}
85-
} else {
86-
data.ComponentConfigs = componentConfigs
8781
}
8882

8983
f.logger.Infof(ctx, "Fetched %d buckets, %d tables, %d jobs, %d transformations, %d components",
@@ -226,9 +220,10 @@ func (f *Fetcher) FetchComponentConfigs(ctx context.Context, branchID keboola.Br
226220

227221
for _, cfg := range comp.Configs {
228222
config := configparser.ParseComponentConfig(comp, cfg)
229-
if config != nil {
230-
configs = append(configs, config)
223+
if config == nil {
224+
continue
231225
}
226+
configs = append(configs, config)
232227
}
233228
}
234229

0 commit comments

Comments
 (0)