-
Notifications
You must be signed in to change notification settings - Fork 11
/
rule_description.go
30 lines (23 loc) · 1.02 KB
/
rule_description.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package naming
import (
"fmt"
"github.com/fdaines/arch-go/internal/config"
)
func resolveRuleDescription(rule *config.NamingRule) string {
var description string
if rule.InterfaceImplementationNamingRule != nil {
description = resolveInterfaceImplementationDescription(rule.InterfaceImplementationNamingRule)
}
ruleDescription := fmt.Sprintf("Packages matching pattern '%s' should comply with [%s]", rule.Package, description)
return ruleDescription
}
func resolveInterfaceImplementationDescription(rule *config.InterfaceImplementationRule) string {
description := ""
if rule.ShouldHaveSimpleNameStartingWith != "" {
description = fmt.Sprintf("structs that implement '%s' should have simple name starting with '%s'", rule.StructsThatImplement, rule.ShouldHaveSimpleNameStartingWith)
}
if rule.ShouldHaveSimpleNameEndingWith != "" {
description = fmt.Sprintf("structs that implement '%s' should have simple name ending with '%s'", rule.StructsThatImplement, rule.ShouldHaveSimpleNameEndingWith)
}
return description
}