Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move errcheck package out of internal #185

Merged
merged 25 commits into from Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ea6ea2f
Move errcheck package out of internal
echlebek Aug 2, 2020
ee8ff30
Merge branch 'master' into publish-api
echlebek Aug 4, 2020
b03026b
Fix up the docs a bit
echlebek Aug 4, 2020
5665fc9
CheckPackage function
Aug 18, 2020
b4ad18c
Start factoring out exclusion flags into separate struct.
dtcaciuc Aug 19, 2020
f1024b1
Move Checker.exclude to Checker.Exclusions.Symbols
dtcaciuc Aug 19, 2020
b694f8e
Move Checker.Blank and Checker.Asserts to Exclusions
dtcaciuc Aug 19, 2020
5c4c914
Move Checker.Ignore to Exclusions.Packages, remove NewChecker
dtcaciuc Aug 19, 2020
f394fab
Clarify -ignore deprecation message
dtcaciuc Aug 19, 2020
7c04f7d
Merge pull request #188 from SVilgelm/publish-api
echlebek Aug 31, 2020
3c3d64d
Merge remote-tracking branch 'origin/publish-api' into exclusions
echlebek Aug 31, 2020
181d1bd
Simplify vendored package resolution.
dtcaciuc Oct 10, 2020
672a183
Merge pull request #1 from dtcaciuc/rm-mod-check
dtcaciuc Oct 10, 2020
bd31643
Restore legacy ignore functionality; fix docstrings
dtcaciuc Oct 10, 2020
bf59cbd
Clean up comments; add future improvement TODO
dtcaciuc Oct 10, 2020
720fbcb
Merge pull request #189 from dtcaciuc/exclusions
echlebek Oct 23, 2020
677f1d6
Remove CheckPaths
echlebek Oct 25, 2020
8d25d8e
Refactor main.checkPaths a bit
echlebek Oct 25, 2020
beb76a6
Remove mutex, Errors->UncheckedErrors
echlebek Oct 25, 2020
53abe15
Implement locking in main
echlebek Oct 25, 2020
cfa64d0
Remove sort.Interface from Result
echlebek Nov 10, 2020
c4c6bdd
Don't mutate Result on Unique()
echlebek Nov 10, 2020
c1c14fd
Merge pull request #193 from kisielk/no-check-path
kisielk Nov 13, 2020
6afc191
Clarify Result docs
echlebek Dec 10, 2020
97c82e3
Make API less pointery. Get rid of error interface.
echlebek Dec 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
File renamed without changes.
21 changes: 13 additions & 8 deletions internal/errcheck/errcheck.go → errcheck/errcheck.go
@@ -1,6 +1,4 @@
// Package errcheck is the library used to implement the errcheck command-line tool.
//
// Note: The API of this package has not been finalized and may change at any point.
package errcheck

import (
Expand Down Expand Up @@ -87,6 +85,7 @@ type UncheckedErrors struct {
Errors []UncheckedError
}

// Append appends errors to e. It is goroutine-safe.
func (e *UncheckedErrors) Append(errors ...UncheckedError) {
e.mu.Lock()
defer e.mu.Unlock()
Expand Down Expand Up @@ -124,28 +123,33 @@ func (e byName) Less(i, j int) bool {
return ei.Line < ej.Line
}

// Checker checks that you checked errors.
type Checker struct {
dtcaciuc marked this conversation as resolved.
Show resolved Hide resolved
// ignore is a map of package names to regular expressions. Identifiers from a package are
// Ignore is a map of package names to regular expressions. Identifiers from a package are
// checked against its regular expressions and if any of the expressions match the call
// is not checked.
Ignore map[string]*regexp.Regexp

// If blank is true then assignments to the blank identifier are also considered to be
// Blank, if true, means assignments to the blank identifier are also considered to be
// ignored errors.
Blank bool

// If asserts is true then ignored type assertion results are also checked
// Asserts causes ignored type assertion results to also be checked.
Asserts bool

// build tags
// Tags are a list of build tags to use.
Tags []string

// Verbose causes extra information to be output to stdout.
Verbose bool

// If true, checking of _test.go files is disabled
// WithoutTests disables checking of _test.go files.
WithoutTests bool

// If true, checking of files with generated code is disabled
// WithoutGeneratedCode disables checking of files with generated code.
// It behaves according to the following regular expression:
//
// ^// Code generated .* DO NOT EDIT\\.$
WithoutGeneratedCode bool

exclude map[string]bool
Expand All @@ -155,6 +159,7 @@ func NewChecker() *Checker {
return &Checker{exclude: map[string]bool{}}
}

// AddExcludes adds expressions to exclude from checking.
func (c *Checker) AddExcludes(excludes []string) {
for _, k := range excludes {
c.logf("Excluding %v", k)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion main.go
Expand Up @@ -11,7 +11,7 @@ import (
"regexp"
"strings"

"github.com/kisielk/errcheck/internal/errcheck"
"github.com/kisielk/errcheck/errcheck"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion main_test.go
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
"testing"

"github.com/kisielk/errcheck/internal/errcheck"
"github.com/kisielk/errcheck/errcheck"
)

func TestMain(t *testing.T) {
Expand Down