diff options
author | Abhinav Gupta <mail@abhinavg.net> | 2021-12-04 15:16:09 -0800 |
---|---|---|
committer | Abhinav Gupta <mail@abhinavg.net> | 2021-12-04 15:40:53 -0800 |
commit | 0dcebfb72bbdaf01554f938402e699d67937c5a0 (patch) | |
tree | 512b1d1651109b3008ff610cf2abfa8adc1c211b | |
parent | e4fcd078d42e945581616855ab78d8b7ed12df6c (diff) | |
download | go-git-0dcebfb72bbdaf01554f938402e699d67937c5a0.tar.gz |
error strings: Don't capitalize, use periods, or newlines
Per [Go Code Review Comments][1],
> Error strings should not be capitalized (unless beginning with proper
> nouns or acronyms) or end with punctuation
staticcheck's [ST1005][2] also complains about these. For example,
```
object_walker.go:63:10: error strings should not be capitalized (ST1005)
object_walker.go:101:10: error strings should not be capitalized (ST1005)
object_walker.go:101:10: error strings should not end with punctuation or a newline (ST1005)
plumbing/format/commitgraph/file.go:17:26: error strings should not be capitalized (ST1005)
```
This fixes all instances of this issue reported by staticcheck.
[1]: https://github.com/golang/go/wiki/CodeReviewComments#error-strings
[2]: https://staticcheck.io/docs/checks/#ST1005
-rw-r--r-- | config/config.go | 2 | ||||
-rw-r--r-- | object_walker.go | 4 | ||||
-rw-r--r-- | plumbing/format/commitgraph/file.go | 6 | ||||
-rw-r--r-- | plumbing/format/gitattributes/attributes.go | 2 | ||||
-rw-r--r-- | plumbing/format/idxfile/decoder.go | 4 | ||||
-rw-r--r-- | plumbing/object/change_adaptor.go | 4 | ||||
-rw-r--r-- | prune.go | 2 | ||||
-rw-r--r-- | remote.go | 4 | ||||
-rw-r--r-- | repository.go | 4 | ||||
-rw-r--r-- | storage/filesystem/dotgit/reader.go | 2 | ||||
-rw-r--r-- | storage/memory/storage.go | 2 |
11 files changed, 18 insertions, 18 deletions
diff --git a/config/config.go b/config/config.go index 1aee25a..1462c0c 100644 --- a/config/config.go +++ b/config/config.go @@ -150,7 +150,7 @@ func ReadConfig(r io.Reader) (*Config, error) { // config file to the given scope, a empty one is returned. func LoadConfig(scope Scope) (*Config, error) { if scope == LocalScope { - return nil, fmt.Errorf("LocalScope should be read from the a ConfigStorer.") + return nil, fmt.Errorf("LocalScope should be read from the a ConfigStorer") } files, err := Paths(scope) diff --git a/object_walker.go b/object_walker.go index 3fcdd29..3a537bd 100644 --- a/object_walker.go +++ b/object_walker.go @@ -60,7 +60,7 @@ func (p *objectWalker) walkObjectTree(hash plumbing.Hash) error { // Fetch the object. obj, err := object.GetObject(p.Storer, hash) if err != nil { - return fmt.Errorf("Getting object %s failed: %v", hash, err) + return fmt.Errorf("getting object %s failed: %v", hash, err) } // Walk all children depending on object type. switch obj := obj.(type) { @@ -98,7 +98,7 @@ func (p *objectWalker) walkObjectTree(hash plumbing.Hash) error { return p.walkObjectTree(obj.Target) default: // Error out on unhandled object types. - return fmt.Errorf("Unknown object %X %s %T\n", obj.ID(), obj.Type(), obj) + return fmt.Errorf("unknown object %X %s %T", obj.ID(), obj.Type(), obj) } return nil } diff --git a/plumbing/format/commitgraph/file.go b/plumbing/format/commitgraph/file.go index 0ce7198..1d25238 100644 --- a/plumbing/format/commitgraph/file.go +++ b/plumbing/format/commitgraph/file.go @@ -14,14 +14,14 @@ import ( var (
// ErrUnsupportedVersion is returned by OpenFileIndex when the commit graph
// file version is not supported.
- ErrUnsupportedVersion = errors.New("Unsupported version")
+ ErrUnsupportedVersion = errors.New("unsupported version")
// ErrUnsupportedHash is returned by OpenFileIndex when the commit graph
// hash function is not supported. Currently only SHA-1 is defined and
// supported
- ErrUnsupportedHash = errors.New("Unsupported hash algorithm")
+ ErrUnsupportedHash = errors.New("unsupported hash algorithm")
// ErrMalformedCommitGraphFile is returned by OpenFileIndex when the commit
// graph file is corrupted.
- ErrMalformedCommitGraphFile = errors.New("Malformed commit graph file")
+ ErrMalformedCommitGraphFile = errors.New("malformed commit graph file")
commitFileSignature = []byte{'C', 'G', 'P', 'H'}
oidFanoutSignature = []byte{'O', 'I', 'D', 'F'}
diff --git a/plumbing/format/gitattributes/attributes.go b/plumbing/format/gitattributes/attributes.go index d13c2a9..329e667 100644 --- a/plumbing/format/gitattributes/attributes.go +++ b/plumbing/format/gitattributes/attributes.go @@ -15,7 +15,7 @@ const ( var ( ErrMacroNotAllowed = errors.New("macro not allowed") - ErrInvalidAttributeName = errors.New("Invalid attribute name") + ErrInvalidAttributeName = errors.New("invalid attribute name") ) type MatchAttribute struct { diff --git a/plumbing/format/idxfile/decoder.go b/plumbing/format/idxfile/decoder.go index 7768bd6..51a3904 100644 --- a/plumbing/format/idxfile/decoder.go +++ b/plumbing/format/idxfile/decoder.go @@ -12,9 +12,9 @@ import ( var ( // ErrUnsupportedVersion is returned by Decode when the idx file version // is not supported. - ErrUnsupportedVersion = errors.New("Unsupported version") + ErrUnsupportedVersion = errors.New("unsupported version") // ErrMalformedIdxFile is returned by Decode when the idx file is corrupted. - ErrMalformedIdxFile = errors.New("Malformed IDX file") + ErrMalformedIdxFile = errors.New("malformed IDX file") ) const ( diff --git a/plumbing/object/change_adaptor.go b/plumbing/object/change_adaptor.go index f701188..b96ee84 100644 --- a/plumbing/object/change_adaptor.go +++ b/plumbing/object/change_adaptor.go @@ -16,11 +16,11 @@ func newChange(c merkletrie.Change) (*Change, error) { var err error if ret.From, err = newChangeEntry(c.From); err != nil { - return nil, fmt.Errorf("From field: %s", err) + return nil, fmt.Errorf("from field: %s", err) } if ret.To, err = newChangeEntry(c.To); err != nil { - return nil, fmt.Errorf("To field: %s", err) + return nil, fmt.Errorf("to field: %s", err) } return ret, nil @@ -17,7 +17,7 @@ type PruneOptions struct { Handler PruneHandler } -var ErrLooseObjectsNotSupported = errors.New("Loose objects not supported") +var ErrLooseObjectsNotSupported = errors.New("loose objects not supported") // DeleteObject deletes an object from a repository. // The type conveniently matches PruneHandler. @@ -260,7 +260,7 @@ func (r *Remote) addReachableTags(localRefs []*plumbing.Reference, remoteRefs st tagObject, err := object.GetObject(r.s, tag.Hash()) var tagCommit *object.Commit if err != nil { - return fmt.Errorf("get tag object: %w\n", err) + return fmt.Errorf("get tag object: %w", err) } if tagObject.Type() != plumbing.TagObject { @@ -274,7 +274,7 @@ func (r *Remote) addReachableTags(localRefs []*plumbing.Reference, remoteRefs st tagCommit, err = object.GetCommit(r.s, annotatedTag.Target) if err != nil { - return fmt.Errorf("get annotated tag commit: %w\n", err) + return fmt.Errorf("get annotated tag commit: %w", err) } // only include tags that are reachable from one of the refs diff --git a/repository.go b/repository.go index d3fbf97..e8eb53f 100644 --- a/repository.go +++ b/repository.go @@ -56,7 +56,7 @@ var ( ErrWorktreeNotProvided = errors.New("worktree should be provided") ErrIsBareRepository = errors.New("worktree not available in a bare repository") ErrUnableToResolveCommit = errors.New("unable to resolve commit") - ErrPackedObjectsNotSupported = errors.New("Packed objects not supported") + ErrPackedObjectsNotSupported = errors.New("packed objects not supported") ) // Repository represents a git repository @@ -1547,7 +1547,7 @@ func (r *Repository) ResolveRevision(rev plumbing.Revision) (*plumbing.Hash, err } if c == nil { - return &plumbing.ZeroHash, fmt.Errorf(`No commit message match regexp : "%s"`, re.String()) + return &plumbing.ZeroHash, fmt.Errorf("no commit message match regexp: %q", re.String()) } commit = c diff --git a/storage/filesystem/dotgit/reader.go b/storage/filesystem/dotgit/reader.go index a82ac94..975f92a 100644 --- a/storage/filesystem/dotgit/reader.go +++ b/storage/filesystem/dotgit/reader.go @@ -66,7 +66,7 @@ func (e *EncodedObject) Size() int64 { func (e *EncodedObject) SetSize(int64) {} func (e *EncodedObject) Writer() (io.WriteCloser, error) { - return nil, fmt.Errorf("Not supported") + return nil, fmt.Errorf("not supported") } func NewEncodedObject(dir *DotGit, h plumbing.Hash, t plumbing.ObjectType, size int64) *EncodedObject { diff --git a/storage/memory/storage.go b/storage/memory/storage.go index a8e5669..ef6a445 100644 --- a/storage/memory/storage.go +++ b/storage/memory/storage.go @@ -193,7 +193,7 @@ func (o *ObjectStorage) DeleteOldObjectPackAndIndex(plumbing.Hash, time.Time) er return nil } -var errNotSupported = fmt.Errorf("Not supported") +var errNotSupported = fmt.Errorf("not supported") func (o *ObjectStorage) LooseObjectTime(hash plumbing.Hash) (time.Time, error) { return time.Time{}, errNotSupported |