From 0510c59085ffe5d83c45853a90cedc89076d019d Mon Sep 17 00:00:00 2001 From: jensilo <k@jensheise.com> Date: Wed, 27 Dec 2023 15:25:23 +0100 Subject: [PATCH] remove unnecessary interface --- src/app/eiffel/parser.go | 4 ++-- src/app/template/parser/parser.go | 8 -------- src/app/template/service.go | 9 +++------ 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/app/eiffel/parser.go b/src/app/eiffel/parser.go index ccda7b2..c0bbc2e 100644 --- a/src/app/eiffel/parser.go +++ b/src/app/eiffel/parser.go @@ -23,7 +23,7 @@ var ( ErrNotAString = errors.New("eiffel.parser.error.not-a-string") ) -// BasicTemplate is the basic EIFFEL template. It is parsable by implementing the template.ParsableTemplate interface. +// BasicTemplate is the basic EIFFEL template. // // A basic template is a template that defines a set of rules and a set of variants. // Each variant contains rules that are to be applied to a requirement in the parsing step to validate the requirement. @@ -182,7 +182,7 @@ func RuleParsers() *RuleParserProvider { } } -// Parse implements the template.ParsableTemplate interface for the BasicTemplate. It is used to parse requirements in the form of segments. +// Parse is used to parse requirements in the form of segments. // Each segment is a part of the requirement that is to be parsed. For the EIFFEL basic template (EBT), each segment is an input from auto-generated // input field based on the rules defined in the template. Therefore, each segment will be validated by the corresponding rule. // It is recommended to validate the template before parsing requirements. diff --git a/src/app/template/parser/parser.go b/src/app/template/parser/parser.go index d8c3f66..93adefb 100644 --- a/src/app/template/parser/parser.go +++ b/src/app/template/parser/parser.go @@ -1,9 +1,7 @@ package parser import ( - "context" "github.com/org-harmony/harmony/src/core/trans" - "github.com/org-harmony/harmony/src/core/validation" ) const ( @@ -54,12 +52,6 @@ type ParsingLog struct { Downgrade bool } -// ParsableTemplate is a template that can be validated and parsed. -type ParsableTemplate interface { - Validate(v validation.V) []error - Parse(ctx context.Context, variation string, segments ...ParsingSegment) (ParsingResult, error) -} - // String on ParsingLog returns the message of the log. func (l ParsingLog) String() string { return l.Message diff --git a/src/app/template/service.go b/src/app/template/service.go index 3c07772..1020998 100644 --- a/src/app/template/service.go +++ b/src/app/template/service.go @@ -18,8 +18,7 @@ var ( ) // ValidateTemplateConfigEvent is published to validate a template config. It allows for other modules to validate -// specific parts or entire templates based on their own rules. This is helpful if a module defines a template.ParsableTemplate -// and the template should be validated against the rules of the parser. +// specific parts or entire templates based on their own rules. This is helpful if a template should be validated against the rules of the parser. type ValidateTemplateConfigEvent struct { Config string TemplateType string @@ -29,8 +28,7 @@ type ValidateTemplateConfigEvent struct { // ValidateTemplateToCreate validates the template to create against the template set's rules and publishes an event // to validate the template config. The event allows for other modules to validate specific parts or entire templates -// based on their own rules. This is helpful if a module defines a template.ParsableTemplate and the template should be -// validated against the rules of the parser. +// based on their own rules. This is helpful if a template should be validated against the rules of the parser. func ValidateTemplateToCreate(toCreate *ToCreate, validator validation.V, em event.Manager, logger trace.Logger) ([]error, error) { err, validationErrs := validator.ValidateStruct(toCreate) if err != nil { @@ -52,8 +50,7 @@ func ValidateTemplateToCreate(toCreate *ToCreate, validator validation.V, em eve // ValidateTemplateToUpdate validates the template to update against the template set's rules and publishes an event // to validate the template config. The event allows for other modules to validate specific parts or entire templates -// based on their own rules. This is helpful if a module defines a template.ParsableTemplate and the template should be -// validated against the rules of the parser. +// based on their own rules. This is helpful if a template should be validated against the rules of the parser. func ValidateTemplateToUpdate(toUpdate *ToUpdate, validator validation.V, em event.Manager, logger trace.Logger) ([]error, error) { err, validationErrs := validator.ValidateStruct(toUpdate) if err != nil { -- GitLab