Add codespell support with configuration and fixes (#21807)

Co-authored-by: Claude Code 2.1.142 / Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Yaroslav Halchenko
2026-05-30 16:15:13 -04:00
committed by GitHub
parent c221cd06ad
commit 451cc6c048
13 changed files with 63 additions and 11 deletions
+25
View File
@@ -0,0 +1,25 @@
[codespell]
# Ref: https://github.com/codespell-project/codespell#using-a-config-file
# Skip historical content (CHANGELOG, release notes archive), auto-generated
# man pages (which contain troff macros like \(bu that look like typos), and
# files we don't want to modify (go.sum, css with vendor prefixes).
skip = .git*,.gitignore,.gitattributes,go.sum,*.css,.codespellrc,CHANGELOG.md,changelog,*.1
check-hidden = true
# Protect URLs from corrections (URLs may contain words flagged as typos and
# must not be changed); also ignore camelCase/PascalCase identifiers like
# AtLeast which are valid Go identifiers, not typos.
ignore-regex = https?://\S+|\b[a-z]+[A-Z]\w*\b|\b[A-Z][a-z]+[A-Z]\w*\b
ignore-words-list =
# variable name short for "serialized", also matches [uU]ser glob pattern
ser,
# German word "ist" appearing in test data string
ist,
# intentional truncated test string in format truncation tests
fo,
# CLI flag name (--iinclude, case-insensitive include)
iinclude,
# intentional in fake test path /doesnt/exist
doesnt
+1 -1
View File
@@ -1,6 +1,6 @@
# Actual layer caching is impossible due to .git, but
# that must be included for provenance reasons. These ignores
# are strictly for hygenic build.
# are strictly for hygienic build.
*
!/*.go
!/go.*
+27
View File
@@ -0,0 +1,27 @@
# Codespell configuration is within .codespellrc
---
name: Codespell
on:
# run checks on push to master, but not when other branches are pushed to
push:
branches:
- master
# run checks for all pull requests
pull_request:
merge_group:
permissions:
contents: read
jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Codespell
uses: codespell-project/actions-codespell@8f01853be192eb0f849a5c7d721450e7a467c579 # v2.2
+1 -1
View File
@@ -55,7 +55,7 @@ linters:
- "-ST1021"
- "-ST1022"
# extra disables
- "-QF1008" # don't warn about specifing name of embedded field on access
- "-QF1008" # don't warn about specifying name of embedded field on access
exclusions:
rules:
# revive: ignore unused parameters in tests
+1 -1
View File
@@ -90,7 +90,7 @@ func TestCopy(t *testing.T) {
_, _, countBlobs := testPackAndBlobCounts(t, env.gopts)
countTreePacksDst, countDataPacksDst, countBlobsDst := testPackAndBlobCounts(t, env2.gopts)
rtest.Equals(t, countBlobs, countBlobsDst, "expected blob count in boths repos to be equal")
rtest.Equals(t, countBlobs, countBlobsDst, "expected blob count in both repos to be equal")
rtest.Equals(t, countTreePacksDst, 1, "expected 1 tree packfile")
rtest.Equals(t, countDataPacksDst, 1, "expected 1 data packfile")
}
+1 -1
View File
@@ -145,7 +145,7 @@ func runMount(ctx context.Context, opts MountOptions, gopts global.Options, args
err = unix.Access(mountpoint, unix.W_OK|unix.X_OK)
if err != nil {
printer.P("Mountpoint %s is not writeable or not excutable", mountpoint)
printer.P("Mountpoint %s is not writeable or not executable", mountpoint)
return errors.Fatal("inaccessible mountpoint")
}
+1 -1
View File
@@ -137,7 +137,7 @@ var (
// Cached uid lookup by user name. Returns 0 when no id can be found.
//
//nolint:revive // captialization is correct as is
//nolint:revive // capitalization is correct as is
func lookupUid(userName string) uint32 {
userNameLookupCacheMutex.RLock()
uid, ok := userNameLookupCache[userName]
+1 -1
View File
@@ -74,7 +74,7 @@ func (r *packerManager) Flush(ctx context.Context) error {
// mergePackers merges small pack files before those are uploaded by Flush(). The main
// purpose of this method is to reduce information leaks if a small file is backed up
// and the blobs end up in spearate pack files. If the file only consists of two blobs
// and the blobs end up in separate pack files. If the file only consists of two blobs
// this would leak the size of the individual blobs.
func (r *packerManager) mergePackers() ([]*packer, error) {
pendingPackers := []*packer{}
+1 -1
View File
@@ -342,7 +342,7 @@ func calculateTargetPacksize(opts PruneOptions, indexPack map[restic.ID]packInfo
return cmp.Compare(a.size, b.size)
})
// Using the approximatelly 3rd percentile is just a heuristic and may not always be the optimal choice.
// Using the approximately 3rd percentile is just a heuristic and may not always be the optimal choice.
// However, using a low percentile ensures that only a small fraction of the repository
// may end up being repacked. By using 80% of that perecentile or the minimum pack size,
// we ensure that no repacking happens if the repository already has no small pack files.
+1 -1
View File
@@ -133,7 +133,7 @@ func TestPruneSmall(t *testing.T) {
keep := restic.NewBlobSet()
rtest.OK(t, repo.WithBlobUploader(context.TODO(), func(ctx context.Context, uploader restic.BlobSaverWithAsync) error {
// we need a minum of 11 packfiles, each packfile will be about 5 Mb long
// we need a minimum of 11 packfiles, each packfile will be about 5 Mb long
for i := 0; i < numBlobsCreated; i++ {
buf := make([]byte, blobSize)
random.Read(buf)
+1 -1
View File
@@ -14,7 +14,7 @@ import (
// UidGidInt returns uid, gid of the user as a number.
//
//nolint:revive // captialization is correct as is
//nolint:revive // capitalization is correct as is
func UidGidInt(u *user.User) (uid, gid uint32, err error) {
ui, err := strconv.ParseUint(u.Uid, 10, 32)
if err != nil {
+1 -1
View File
@@ -185,7 +185,7 @@ func (r *fileRestorer) restoreFiles(ctx context.Context) error {
file.sparse = false
}
// empty file or one with already uptodate content. Make sure that the file size is correct
// empty file or one with already up-to-date content. Make sure that the file size is correct
if !restoredBlobs {
err := r.truncateFileToSize(file.location, file.size)
if errFile := r.sanitizeError(file, err); errFile != nil {
+1 -1
View File
@@ -232,7 +232,7 @@ func (w *filesWriter) writeToFile(path string, blob []byte, offset int64, create
bucket.files[path].users--
if bucket.files[path].users == 0 {
delete(bucket.files, path)
// Add to cache to allow re-use. Cache will close files on overflow.
// Add to cache to allow reuse. Cache will close files on overflow.
w.cacheMu.Lock()
w.cache.Add(path, wr)
w.cacheMu.Unlock()