Skip to content

Commit d0f8c76

Browse files
committed
Fixed linter errors
1 parent 9936e45 commit d0f8c76

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

cmd/soarca-conversion/main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ func main() {
6868
log.Error(err)
6969
return
7070
}
71-
os.WriteFile(target_filename, output_str, 0644)
71+
if err := os.WriteFile(target_filename, output_str, 0644); err != nil {
72+
log.Error(err)
73+
return
74+
}
7275

7376
}

pkg/conversion/bpmn_conversion.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (converter BpmnConverter) Convert(input []byte, filename string) (*cacao.Pl
7777
return nil, err
7878
}
7979
if len(definitions.Processes) > 1 {
80-
return nil, errors.New("Unsupported: BPMN file with multiple processes")
80+
return nil, errors.New("unsupported: BPMN file with multiple processes")
8181
}
8282
if len(definitions.Processes) == 0 {
8383
return nil, errors.New("BPMN file does not have any processes")
@@ -249,9 +249,9 @@ func (p *BpmnProcess) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
249249
}
250250
p.annotations = append(p.annotations, *annotation)
251251
case "intermediateThrowEvent", "intermediateCatchEvent":
252-
return fmt.Errorf("Throw/catch mechanism is currently not implemented in SOARCA")
252+
return fmt.Errorf("throw/catch mechanism is currently not implemented in SOARCA")
253253
default:
254-
return fmt.Errorf("Unsupported element: %s", item_type.Name.Local)
254+
return fmt.Errorf("unsupported element: %s", item_type.Name.Local)
255255
}
256256
case xml.EndElement:
257257
if item_type.Name == start_name {
@@ -313,12 +313,12 @@ func (flow BpmnFlow) implement(playbook *cacao.Playbook, converter *BpmnConverte
313313
func (flow BpmnFlow) implement_association(playbook *cacao.Playbook, converter *BpmnConverter) error {
314314
source_name, ok := converter.translation[flow.SourceRef]
315315
if !ok {
316-
return fmt.Errorf("Could not translate source of flow: %s", flow.SourceRef)
316+
return fmt.Errorf("could not translate source of flow: %s", flow.SourceRef)
317317
}
318318
source := playbook.Workflow[source_name]
319319
target_index := slices.IndexFunc(converter.process.annotations, func(annot BpmnAnnotation) bool { return annot.Id == flow.TargetRef })
320320
if target_index < 0 {
321-
return fmt.Errorf("Could not find text annotation %s", flow.TargetRef)
321+
return fmt.Errorf("could not find text annotation %s", flow.TargetRef)
322322
}
323323
target := converter.process.annotations[target_index]
324324
source.Condition = target.Text
@@ -328,16 +328,16 @@ func (flow BpmnFlow) implement_association(playbook *cacao.Playbook, converter *
328328
func (flow BpmnFlow) implement_flow(playbook *cacao.Playbook, converter *BpmnConverter) error {
329329
source_name, ok := converter.translation[flow.SourceRef]
330330
if !ok {
331-
return fmt.Errorf("Could not translate source of flow: %s", flow.SourceRef)
331+
return fmt.Errorf("could not translate source of flow: %s", flow.SourceRef)
332332
}
333333
target_name, ok := converter.translation[flow.TargetRef]
334334
if !ok {
335-
return fmt.Errorf("Could not translate target of flow: %s", flow.TargetRef)
335+
return fmt.Errorf("could not translate target of flow: %s", flow.TargetRef)
336336
}
337337
log.Infof("Flow from %s(%s) to %s(%s)", source_name, flow.SourceRef, target_name, flow.TargetRef)
338338
entry, ok := playbook.Workflow[source_name]
339339
if !ok {
340-
return fmt.Errorf("Could not get source of flow: %s", source_name)
340+
return fmt.Errorf("could not get source of flow: %s", source_name)
341341
}
342342
switch entry.Type {
343343
case cacao.StepTypeIfCondition:
@@ -353,7 +353,7 @@ func (flow BpmnFlow) implement_flow(playbook *cacao.Playbook, converter *BpmnCon
353353
} else if entry.OnFalse == "" {
354354
entry.OnTrue = target_name
355355
} else {
356-
return fmt.Errorf("Branch out of exclusive gateway with more than two branches: not supported")
356+
return fmt.Errorf("branch out of exclusive gateway with more than two branches: not supported")
357357
}
358358
}
359359
case cacao.StepTypeParallel:

pkg/conversion/conversion.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import (
66
)
77

88
func PerformConversion(input_filename string, input []byte, format_string string) (*cacao.Playbook, error) {
9-
format := FormatUnknown
9+
var format TargetFormat
1010
if format_string == "" {
1111
format = guess_format(input_filename)
1212
} else {
1313
format = read_format(format_string)
1414
}
1515
if format == FormatUnknown {
16-
return nil, errors.New("Could not deduce input file type")
16+
return nil, errors.New("could not deduce input file type")
1717
}
1818
var converter IConverter
1919
switch format {

pkg/conversion/conversion_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"soarca/pkg/models/validator"
77
"testing"
88

9-
"github.com/go-playground/assert/v2"
9+
"github.com/stretchr/testify/assert"
1010
)
1111

1212
func Test_read_format(t *testing.T) {
@@ -28,6 +28,7 @@ func Test_bpmn_format(t *testing.T) {
2828
converted, err := PerformConversion("../../test/conversion/simple_ssh.bpmn", content, "bpmn")
2929
assert.Equal(t, err, nil)
3030
converted_json, err := json.Marshal(converted)
31+
assert.Nil(t, err)
3132
err = validator.IsValidCacaoJson(converted_json)
3233
assert.Equal(t, err, nil)
3334
assert.NotEqual(t, converted, nil)

0 commit comments

Comments
 (0)