From dab52b490febb19ded356c298eb1f59ed2f2b73e Mon Sep 17 00:00:00 2001 From: Max Leske <250711+theseion@users.noreply.github.com> Date: Sun, 7 Jul 2024 08:39:42 +0200 Subject: [PATCH 1/2] chore: remove unused function parameters --- cmd/regex_compare.go | 8 ++++---- cmd/regex_update.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/regex_compare.go b/cmd/regex_compare.go index 12c7bef..ebd2fa2 100644 --- a/cmd/regex_compare.go +++ b/cmd/regex_compare.go @@ -132,7 +132,7 @@ func performCompare(processAll bool, ctx *processors.Context) error { if err != nil && len(chainOffsetString) > 0 { return errors.New("failed to match chain offset. Value must not be larger than 255") } - regex := runAssemble(filePath, ctx) + regex := runAssemble(filePath) err = processRegexForCompare(id, uint8(chainOffset), regex, ctx) if err != nil && errors.Is(err, &ComparisonError{}) { failed = true @@ -154,7 +154,7 @@ func performCompare(processAll bool, ctx *processors.Context) error { return &ComparisonError{} } } else { - regex := runAssemble(path.Join(ctx.RootContext().AssemblyDir(), ruleValues.fileName), ctx) + regex := runAssemble(path.Join(ctx.RootContext().AssemblyDir(), ruleValues.fileName)) return processRegexForCompare(ruleValues.id, ruleValues.chainOffset, regex, ctx) } return nil @@ -177,7 +177,7 @@ func processRegexForCompare(ruleId string, chainOffset uint8, regex string, ctxt logger.Debug().Msgf("Processing regex-assembly file %s", filePath) currentRegex := readCurrentRegex(filePath, ruleId, chainOffset) - return compareRegex(filePath, ruleId, chainOffset, regex, currentRegex) + return compareRegex(ruleId, regex, currentRegex) } func readCurrentRegex(filePath string, ruleId string, chainOffset uint8) string { @@ -220,7 +220,7 @@ func readCurrentRegex(filePath string, ruleId string, chainOffset uint8) string return found[0][2] } -func compareRegex(filePath string, ruleId string, chainOffset uint8, generatedRegex string, currentRegex string) error { +func compareRegex(ruleId string, generatedRegex string, currentRegex string) error { if currentRegex == generatedRegex { fmt.Println("Regex of", ruleId, "has not changed") return nil diff --git a/cmd/regex_update.go b/cmd/regex_update.go index cad06cf..fa355af 100644 --- a/cmd/regex_update.go +++ b/cmd/regex_update.go @@ -129,7 +129,7 @@ func performUpdate(processAll bool, ctx *processors.Context) { } } -func runAssemble(filePath string, ctx *processors.Context) string { +func runAssemble(filePath string) string { // FIXME: duplicated in generate.go rootContext := context.New(rootValues.workingDirectory.String(), rootValues.configurationFileName.String()) ctxt := processors.NewContext(rootContext) @@ -158,7 +158,7 @@ func runAssemble(filePath string, ctx *processors.Context) string { func processRule(ruleId string, chainOffset uint8, dataFilePath string, ctxt *processors.Context) { logger.Info().Msgf("Processing %s, chain offset %d", ruleId, chainOffset) - regex := runAssemble(dataFilePath, ctxt) + regex := runAssemble(dataFilePath) rulePrefix := ruleId[:3] matches, err := filepath.Glob(fmt.Sprintf("%s/*-%s-*", ctxt.RootContext().RulesDir(), rulePrefix)) From fd46195e96ebb7e25438ae8b3cfc6986c616f330 Mon Sep 17 00:00:00 2001 From: Max Leske <250711+theseion@users.noreply.github.com> Date: Sun, 7 Jul 2024 15:53:00 +0200 Subject: [PATCH 2/2] chore: remove obsolete comment --- cmd/regex_update.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/regex_update.go b/cmd/regex_update.go index 7b751f0..5a60a36 100644 --- a/cmd/regex_update.go +++ b/cmd/regex_update.go @@ -130,7 +130,6 @@ func performUpdate(processAll bool, ctx *processors.Context) { } func runAssemble(filePath string) string { - // FIXME: duplicated in generate.go rootContext := context.New(rootValues.workingDirectory.String(), rootValues.configurationFileName.String()) ctxt := processors.NewContext(rootContext) assembler := operators.NewAssembler(ctxt)