From 3c2aa58dc5f97227379781bf1f6b872b816e7e4b Mon Sep 17 00:00:00 2001 From: Collin Kreklow Date: Sat, 9 May 2020 07:18:17 -0500 Subject: [PATCH] Add *println to exception EXC0001 (#1074) Exception EXC0001 ignores errors on functions like Sprint and Sprintf, but not Sprintln. Update the exception to include *println as well. --- README.md | 2 +- pkg/config/config.go | 2 +- test/testdata/errcheck/ignore_config.yml | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4c82541c845b..bcb862afd6a2 100644 --- a/README.md +++ b/README.md @@ -555,7 +555,7 @@ Flags: -e, --exclude strings Exclude issue by regexp --exclude-use-default Use or not use default excludes: # EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok - - Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked + - Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked # EXC0002 golint: Annoying issue about not having a comment. The rare codebase has such comments - (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form) diff --git a/pkg/config/config.go b/pkg/config/config.go index 021af5684a98..89e3559c1702 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -40,7 +40,7 @@ var DefaultExcludePatterns = []ExcludePattern{ { ID: "EXC0001", Pattern: "Error return value of .((os\\.)?std(out|err)\\..*|.*Close" + - "|.*Flush|os\\.Remove(All)?|.*printf?|os\\.(Un)?Setenv). is not checked", + "|.*Flush|os\\.Remove(All)?|.*print(f|ln)?|os\\.(Un)?Setenv). is not checked", Linter: "errcheck", Why: "Almost all programs ignore errors on these functions and in most cases it's ok", }, diff --git a/test/testdata/errcheck/ignore_config.yml b/test/testdata/errcheck/ignore_config.yml index 279a2d11732e..94fdcd166cdd 100644 --- a/test/testdata/errcheck/ignore_config.yml +++ b/test/testdata/errcheck/ignore_config.yml @@ -1,4 +1,7 @@ linters-settings: errcheck: check-blank: true - ignore: os:.*,io/ioutil:^ReadF.* \ No newline at end of file + ignore: os:.*,io/ioutil:^ReadF.* +issues: + include: + - EXC0001