From 407ad519442e1ffcc06daaa1ea29b83d3a9f8eb6 Mon Sep 17 00:00:00 2001 From: Reuven Harrison Date: Sat, 7 Sep 2024 15:08:37 +0300 Subject: [PATCH] added without deprecation --- checker/generator/data.go | 5 +++++ checker/generator/{checks.go => generator.go} | 20 +++++++++++++------ checker/generator/messages.yaml | 4 ++++ checker/generator/value_set.go | 7 ++++--- 4 files changed, 27 insertions(+), 9 deletions(-) rename checker/generator/{checks.go => generator.go} (90%) diff --git a/checker/generator/data.go b/checker/generator/data.go index 33757432..013a3583 100644 --- a/checker/generator/data.go +++ b/checker/generator/data.go @@ -60,6 +60,11 @@ var endpointValueSets = ValueSets{ nouns: []string{"stability"}, // /Paths/PathItem/Operation actions: []string{"decrease"}, }, + ValueSetA{ + nouns: []string{"api path", "api"}, + actions: []string{"add", "remove"}, + adverb: "without deprecation", + }, ValueSetB{ nouns: []string{"endpoint"}, // /Paths/PathItem actions: []string{"add", "remove", "deprecate", "reactivate"}, diff --git a/checker/generator/checks.go b/checker/generator/generator.go similarity index 90% rename from checker/generator/checks.go rename to checker/generator/generator.go index fe9a24b7..3831d168 100644 --- a/checker/generator/checks.go +++ b/checker/generator/generator.go @@ -92,18 +92,26 @@ func standardizeSpaces(s string) string { } func getActionMessage(action string) string { - if isUnary(action) { - return conjugate(action) + " to %s" + switch getArity(action) { + case 0: + return "" + case 1: + return " to %s" + case 2: + return " from %s to %s" + default: + return "" } - return conjugate(action) + " from %s to %s" } -func isUnary(action string) bool { +func getArity(action string) int { switch action { + case "add", "remove": + return 0 case "set": - return true + return 1 } - return false + return 2 } func conjugate(verb string) string { diff --git a/checker/generator/messages.yaml b/checker/generator/messages.yaml index d47f1fa7..834c5952 100644 --- a/checker/generator/messages.yaml +++ b/checker/generator/messages.yaml @@ -1,4 +1,8 @@ stability-decreased: stability was decreased from %s to %s +api-path-added: api path was added without deprecation +api-path-removed: api path was removed without deprecation +api-added: api was added without deprecation +api-removed: api was removed without deprecation endpoint-added: added endpoint endpoint-removed: removed endpoint endpoint-deprecated: deprecated endpoint diff --git a/checker/generator/value_set.go b/checker/generator/value_set.go index de7a96f4..c740037c 100644 --- a/checker/generator/value_set.go +++ b/checker/generator/value_set.go @@ -37,6 +37,7 @@ type ValueSet struct { hierarchy []string nouns []string actions []string + adverb string } func (v ValueSet) setHierarchy(hierarchy []string) ValueSet { @@ -57,19 +58,19 @@ func (v ValueSetA) setHierarchy(hierarchy []string) IValueSet { } func (v ValueSetA) generate(out io.Writer) { - generateMessage := func(hierarchy []string, noun, attributiveAdjective, predicativeAdjective, action string) string { + generateMessage := func(hierarchy []string, noun, attributiveAdjective, predicativeAdjective, action, adverb string) string { prefix := addAttribute(noun, attributiveAdjective, predicativeAdjective) if hierarchyMessage := getHierarchyMessage(hierarchy); hierarchyMessage != "" { prefix += " of " + hierarchyMessage } - return standardizeSpaces(fmt.Sprintf("%s was %s", prefix, getActionMessage(action))) + return standardizeSpaces(fmt.Sprintf("%s was %s %s %s", prefix, conjugate(action), getActionMessage(action), adverb)) } for _, noun := range v.nouns { for _, action := range v.actions { id := generateId(v.hierarchy, noun, action) - message := generateMessage(v.hierarchy, noun, v.attributiveAdjective, v.predicativeAdjective, action) + message := generateMessage(v.hierarchy, noun, v.attributiveAdjective, v.predicativeAdjective, action, v.adverb) fmt.Fprintln(out, fmt.Sprintf("%s: %s", id, message)) } }