From 89f108c22aa9ccc72f190c8622578e52ee615361 Mon Sep 17 00:00:00 2001 From: SalvadorC Date: Mon, 12 Jul 2021 06:31:46 +0200 Subject: [PATCH] fix issue #540 (#543) --- lint/file.go | 2 +- test/disable-annotations_test.go | 4 ++++ testdata/disable-annotations3.go | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 testdata/disable-annotations3.go diff --git a/lint/file.go b/lint/file.go index 8bef9c220..ee29c1dae 100644 --- a/lint/file.go +++ b/lint/file.go @@ -207,7 +207,7 @@ func (f *File) disabledIntervals(rules []Rule, mustSpecifyDisableReason bool, fa for _, c := range comments { match := re.FindStringSubmatch(c.Text) if len(match) == 0 { - return + continue } ruleNames := []string{} diff --git a/test/disable-annotations_test.go b/test/disable-annotations_test.go index b716734f9..afb88ef00 100644 --- a/test/disable-annotations_test.go +++ b/test/disable-annotations_test.go @@ -14,3 +14,7 @@ func TestDisabledAnnotations(t *testing.T) { func TestModifiedAnnotations(t *testing.T) { testRule(t, "disable-annotations2", &rule.VarNamingRule{}, &lint.RuleConfig{}) } + +func TestDisableNextLineAnnotations(t *testing.T) { + testRule(t, "disable-annotations3", &rule.VarNamingRule{}, &lint.RuleConfig{}) +} \ No newline at end of file diff --git a/testdata/disable-annotations3.go b/testdata/disable-annotations3.go new file mode 100644 index 000000000..95f239c9d --- /dev/null +++ b/testdata/disable-annotations3.go @@ -0,0 +1,14 @@ +// Package fix_tures is a testing package +// tests for issue #540 +//revive:disable-next-line:var-naming +package fix_tures + +func foo1() { + // something before the annotation + //revive:disable-next-line:var-naming + // something after + var invalid_name = 0 +} + +//revive:disable-next-line:var-naming +func (source Source) BaseApiURL() string {}