From 92e5465987eb72907f608e16f32f6f2ec9aab197 Mon Sep 17 00:00:00 2001 From: Collin Kreklow Date: Thu, 7 May 2020 20:55:41 -0500 Subject: [PATCH 1/3] Add *println to exception EXC0001 Exception EXC0001 ignores errors on functions like Sprint and Sprintf, but not Sprintln. Update the exception to include *println as well. --- pkg/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 2315f308c1c0..9e701d715db2 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", }, From f7cde96043483a9bcf6a893020fe8b3c61fe5623 Mon Sep 17 00:00:00 2001 From: Collin Kreklow Date: Thu, 7 May 2020 21:12:20 -0500 Subject: [PATCH 2/3] Update errcheck test case Adding *println to EXC0001 breaks TestErrcheckNoIgnoreFmt. Updated the config file to explicitly include EXC0001. --- test/testdata/errcheck/ignore_config.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 From d25c8129343df157096df83a82599176e2abbaa0 Mon Sep 17 00:00:00 2001 From: Collin Kreklow Date: Thu, 7 May 2020 21:32:22 -0500 Subject: [PATCH 3/3] Update generated README for EXC0001 Regenerate README with updated EXC0001 pattern. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 22053bbbc8ce..0419a2f1d16a 100644 --- a/README.md +++ b/README.md @@ -554,7 +554,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)