From ccb38cfed985c24dad9055704103583a2d8ff326 Mon Sep 17 00:00:00 2001 From: Noah Dietz Date: Fri, 11 Aug 2023 11:43:52 -0700 Subject: [PATCH] feat(AIP-156): allow singleton list (#1230) --- docs/rules/0156/forbidden-methods.md | 10 +++++----- rules/aip0156/forbidden_methods.go | 4 ++-- rules/aip0156/forbidden_methods_test.go | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/rules/0156/forbidden-methods.md b/docs/rules/0156/forbidden-methods.md index 0963b9f30..14d3dbfd5 100644 --- a/docs/rules/0156/forbidden-methods.md +++ b/docs/rules/0156/forbidden-methods.md @@ -2,7 +2,7 @@ rule: aip: 156 name: [core, '0156', forbidden-methods] - summary: Singletons must not define List, Create, or Delete methods. + summary: Singletons must not define Create, or Delete methods. permalink: /156/forbidden-methods redirect_from: - /0156/forbidden-methods @@ -10,15 +10,15 @@ redirect_from: # Singletons: Forbidden methods -This rule enforces that singleton resources do not define `List`, `Create`, or -`Delete` methods, as mandated in [AIP-156][]. +This rule enforces that singleton resources do not define `Create`, or `Delete` +methods, as mandated in [AIP-156][]. ## Details This rule looks at any message with a `name` variable in the URI where the name ends in anything other than `*`. It assumes that this is a method operating on -a singleton resource, and complains if the method is a `List`, `Create`, or -`Delete` standard method. +a singleton resource, and complains if the method is a `Create`, or `Delete` +standard method. ## Examples diff --git a/rules/aip0156/forbidden_methods.go b/rules/aip0156/forbidden_methods.go index eb1caed59..56f109c67 100644 --- a/rules/aip0156/forbidden_methods.go +++ b/rules/aip0156/forbidden_methods.go @@ -42,8 +42,8 @@ var forbiddenMethods = &lint.MethodRule{ return false }, LintMethod: func(m *desc.MethodDescriptor) []lint.Problem { - // Singletons should not use Create, List, or Delete. - for _, badPrefix := range []string{"Create", "List", "Delete"} { + // Singletons should not use Create, or Delete. + for _, badPrefix := range []string{"Create", "Delete"} { if strings.HasPrefix(m.GetName(), badPrefix) { return []lint.Problem{{ Message: fmt.Sprintf("Singletons must not define %q methods.", badPrefix), diff --git a/rules/aip0156/forbidden_methods_test.go b/rules/aip0156/forbidden_methods_test.go index 15423655a..8b3e1443a 100644 --- a/rules/aip0156/forbidden_methods_test.go +++ b/rules/aip0156/forbidden_methods_test.go @@ -29,8 +29,8 @@ func TestForbiddenMethods(t *testing.T) { }{ {"ValidGet", "GetPublisherSettings", "/settings", testutils.Problems{}}, {"ValidUpdate", "UpdatePublisherSettings", "/settings", testutils.Problems{}}, + {"ValidList", "ListPublisherSettings", "/settings", testutils.Problems{}}, {"InvalidCreate", "CreatePublisherSettings", "/settings", testutils.Problems{{Message: "Create"}}}, - {"InvalidList", "ListPublisherSettings", "/settings", testutils.Problems{{Message: "List"}}}, {"InvalidDelete", "DeletePublisherSettings", "/settings", testutils.Problems{{Message: "Delete"}}}, {"Irrelevant", "CreatePublisher", "", testutils.Problems{}}, } {