From 15668ee7b519e59c21e9fdf8996a78658100f4ad Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 27 Mar 2025 11:42:24 -0400 Subject: [PATCH] CI: Add codespell config and fix typos (#4506) More about codespell: https://github.com/codespell-project/codespell --- .codespellrc | 9 +++++++++ docker/demo/traefik.yaml | 2 +- internal/api/download_album.go | 2 +- internal/api/swagger.json | 2 +- internal/api/video.go | 2 +- internal/config/config.go | 2 +- internal/config/config_db.go | 4 ++-- internal/entity/album_yaml.go | 2 +- internal/entity/photo.go | 2 +- internal/entity/photo_title_test.go | 2 +- internal/entity/photos.go | 2 +- internal/entity/search/photos_filter_albums_test.go | 4 ++-- internal/entity/search/photos_filter_filename_test.go | 4 ++-- internal/entity/search/photos_filter_name_test.go | 4 ++-- internal/entity/search/photos_geo_filter_albums_test.go | 4 ++-- internal/entity/string_test.go | 4 ++-- internal/photoprism/backup/albums.go | 2 +- internal/photoprism/convert_image.go | 4 ++-- pkg/clean/gps_test.go | 2 +- pkg/clean/type_test.go | 4 ++-- pkg/clusters/README.md | 4 ++-- pkg/txt/country.go | 2 +- pkg/txt/datetime_year.go | 2 +- pkg/txt/is_test.go | 2 +- pkg/vector/values.go | 2 +- scripts/dist/convert/policy.xml | 2 +- setup/docker/cloud/traefik.yaml | 2 +- 27 files changed, 44 insertions(+), 35 deletions(-) create mode 100644 .codespellrc diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 000000000..6c65fe489 --- /dev/null +++ b/.codespellrc @@ -0,0 +1,9 @@ +[codespell] +# Ref: https://github.com/codespell-project/codespell#using-a-config-file +skip = .git*,*.svg,go.sum,package-lock.json,*.css,.codespellrc,locales,stopwords.*,shortwords.*,countries.*,keywords.json,smallwords.* +check-hidden = true +# ACRONYMS and generally mixed case/Capitalized words +# Also ignore some German +ignore-regex = ^(SMethod=shal|biuld: build)$|https://\S+|\b([A-Z][a-zA-Z]+|ist auf)\b|"(datin|alis|hel)"|\bfixe == false\b +# common variables or other tricky cases +ignore-words-list = renderd,nd,folde,crate,ue,fo,ist,alo,mot,te,admiraal diff --git a/docker/demo/traefik.yaml b/docker/demo/traefik.yaml index 41481fa8e..1906b6fac 100644 --- a/docker/demo/traefik.yaml +++ b/docker/demo/traefik.yaml @@ -6,7 +6,7 @@ serversTransport: # Required to proxy services with self-signed HTTPS certificates: insecureSkipVerify: true -# Open ports ond protocols (HTTP will be redirected to HTTPS): +# Open ports and protocols (HTTP will be redirected to HTTPS): entryPoints: web: address: ":80" diff --git a/internal/api/download_album.go b/internal/api/download_album.go index 027abefdf..7b79ff848 100644 --- a/internal/api/download_album.go +++ b/internal/api/download_album.go @@ -37,7 +37,7 @@ func AlbumDownloadName(c *gin.Context) customize.DownloadName { // DownloadAlbum streams the album contents as zip archive. // -// @Summary streams the album contents as zip archiv +// @Summary streams the album contents as zip archive // @Id DownloadAlbum // @Tags Images, Albums // @Produce application/zip diff --git a/internal/api/swagger.json b/internal/api/swagger.json index 862456173..5411754f2 100644 --- a/internal/api/swagger.json +++ b/internal/api/swagger.json @@ -405,7 +405,7 @@ "Images", "Albums" ], - "summary": "streams the album contents as zip archiv", + "summary": "streams the album contents as zip archive", "operationId": "DownloadAlbum", "parameters": [ { diff --git a/internal/api/video.go b/internal/api/video.go index 61f042692..14acf9071 100644 --- a/internal/api/video.go +++ b/internal/api/video.go @@ -67,7 +67,7 @@ func GetVideo(router *gin.RouterGroup) { return } - // If file is not a video, try to find the realted video file. + // If file is not a video, try to find the related video file. if !f.FileVideo { f, err = query.VideoByPhotoUID(f.PhotoUID) diff --git a/internal/config/config.go b/internal/config/config.go index 265b9f9e9..e060ef89e 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -450,7 +450,7 @@ func (c *Config) About() string { return c.options.About } -// Edition returns the edition nane. +// Edition returns the edition name. func (c *Config) Edition() string { if c.options.Edition == "" { return "ce" diff --git a/internal/config/config_db.go b/internal/config/config_db.go index de8c19850..2c53ced80 100644 --- a/internal/config/config_db.go +++ b/internal/config/config_db.go @@ -41,7 +41,7 @@ func (c *Config) DatabaseDriver() string { switch strings.ToLower(c.options.DatabaseDriver) { case MySQL, MariaDB: c.options.DatabaseDriver = MySQL - case SQLite3, "sqlite", "sqllite", "test", "file", "": + case SQLite3, "sqlite", "sqllite", "test", "file", "": # codespell:ignore sqllite c.options.DatabaseDriver = SQLite3 case "tidb": log.Warnf("config: database driver 'tidb' is deprecated, using sqlite") @@ -61,7 +61,7 @@ func (c *Config) DatabaseDriverName() string { switch c.DatabaseDriver() { case MySQL, MariaDB: return "MariaDB" - case SQLite3, "sqlite", "sqllite", "test", "file", "": + case SQLite3, "sqlite", "sqllite", "test", "file", "": # codespell:ignore sqllite return "SQLite" case "tidb": return "TiDB" diff --git a/internal/entity/album_yaml.go b/internal/entity/album_yaml.go index e799c93e3..52a1194f3 100644 --- a/internal/entity/album_yaml.go +++ b/internal/entity/album_yaml.go @@ -35,7 +35,7 @@ func (m *Album) SaveAsYaml(fileName string) error { } else if m.AlbumUID == "" { return fmt.Errorf("album uid is empty") } else if fileName == "" { - return fmt.Errorf("yaml filname is empty") + return fmt.Errorf("yaml filename is empty") } data, err := m.Yaml() diff --git a/internal/entity/photo.go b/internal/entity/photo.go index 97f657f65..28a220d7c 100644 --- a/internal/entity/photo.go +++ b/internal/entity/photo.go @@ -692,7 +692,7 @@ func (m *Photo) AddLabels(labels classify.Labels) { labelEntity := FirstOrCreateLabel(NewLabel(classifyLabel.Title(), classifyLabel.Priority)) if labelEntity == nil { - log.Errorf("index: label %s coud not be created (%s)", clean.Log(classifyLabel.Title()), m) + log.Errorf("index: label %s could not be created (%s)", clean.Log(classifyLabel.Title()), m) continue } diff --git a/internal/entity/photo_title_test.go b/internal/entity/photo_title_test.go index 7cd659842..3f1bec375 100644 --- a/internal/entity/photo_title_test.go +++ b/internal/entity/photo_title_test.go @@ -61,7 +61,7 @@ func TestPhoto_SetTitle(t *testing.T) { } func TestPhoto_GenerateTitle(t *testing.T) { - t.Run("wont update title was modified", func(t *testing.T) { + t.Run("won't update title was modified", func(t *testing.T) { m := PhotoFixtures.Get("Photo08") classifyLabels := &classify.Labels{} assert.Equal(t, "Black beach", m.PhotoTitle) diff --git a/internal/entity/photos.go b/internal/entity/photos.go index 2ca9ab19c..1fce48865 100644 --- a/internal/entity/photos.go +++ b/internal/entity/photos.go @@ -14,7 +14,7 @@ func (m Photos) Photos() []PhotoInterface { return result } -// UIDs returns tbe photo UIDs as string slice. +// UIDs returns the photo UIDs as string slice. func (m Photos) UIDs() []string { result := make([]string, len(m)) diff --git a/internal/entity/search/photos_filter_albums_test.go b/internal/entity/search/photos_filter_albums_test.go index 4f2af064b..4a390a45e 100644 --- a/internal/entity/search/photos_filter_albums_test.go +++ b/internal/entity/search/photos_filter_albums_test.go @@ -322,7 +322,7 @@ func TestPhotosFilterAlbums(t *testing.T) { } if len(photos) != 1 { - t.Logf("excactly one result expected, but %d photos with %d files found", len(photos), count) + t.Logf("exactly one result expected, but %d photos with %d files found", len(photos), count) t.Logf("query results: %#v", photos) } @@ -775,7 +775,7 @@ func TestPhotosQueryAlbums(t *testing.T) { } if len(photos) != 1 { - t.Logf("excactly one result expected, but %d photos with %d files found", len(photos), count) + t.Logf("exactly one result expected, but %d photos with %d files found", len(photos), count) t.Logf("query results: %#v", photos) } diff --git a/internal/entity/search/photos_filter_filename_test.go b/internal/entity/search/photos_filter_filename_test.go index ca72a7e67..e03fd395c 100644 --- a/internal/entity/search/photos_filter_filename_test.go +++ b/internal/entity/search/photos_filter_filename_test.go @@ -267,7 +267,7 @@ func TestPhotosFilterFilename(t *testing.T) { } if len(photos) != 1 { - t.Logf("excactly one result expected, but %d photos with %d files found", len(photos), count) + t.Logf("exactly one result expected, but %d photos with %d files found", len(photos), count) t.Logf("query results: %#v", photos) } @@ -753,7 +753,7 @@ func TestPhotosQueryFilename(t *testing.T) { } if len(photos) != 1 { - t.Logf("excactly one result expected, but %d photos with %d files found", len(photos), count) + t.Logf("exactly one result expected, but %d photos with %d files found", len(photos), count) t.Logf("query results: %#v", photos) } diff --git a/internal/entity/search/photos_filter_name_test.go b/internal/entity/search/photos_filter_name_test.go index 0e46c01a7..3a8be6b65 100644 --- a/internal/entity/search/photos_filter_name_test.go +++ b/internal/entity/search/photos_filter_name_test.go @@ -267,7 +267,7 @@ func TestPhotosFilterName(t *testing.T) { } if len(photos) != 1 { - t.Logf("excactly one result expected, but %d photos with %d files found", len(photos), count) + t.Logf("exactly one result expected, but %d photos with %d files found", len(photos), count) t.Logf("query results: %#v", photos) } @@ -744,7 +744,7 @@ func TestPhotosQueryName(t *testing.T) { } if len(photos) != 1 { - t.Logf("excactly one result expected, but %d photos with %d files found", len(photos), count) + t.Logf("exactly one result expected, but %d photos with %d files found", len(photos), count) t.Logf("query results: %#v", photos) } diff --git a/internal/entity/search/photos_geo_filter_albums_test.go b/internal/entity/search/photos_geo_filter_albums_test.go index 5c6299f98..77c903e33 100644 --- a/internal/entity/search/photos_geo_filter_albums_test.go +++ b/internal/entity/search/photos_geo_filter_albums_test.go @@ -738,7 +738,7 @@ func TestPhotosGeoFilterAlbums(t *testing.T) { } if len(photos) != 1 { - t.Logf("excactly one result expected, but %d photos with %d files found", len(photos), count) + t.Logf("exactly one result expected, but %d photos with %d files found", len(photos), count) t.Logf("query results: %#v", photos) } @@ -1773,7 +1773,7 @@ func TestPhotosGeoQueryAlbums(t *testing.T) { } if len(photos) != 1 { - t.Logf("excactly one result expected, but %d photos with %d files found", len(photos), count) + t.Logf("exactly one result expected, but %d photos with %d files found", len(photos), count) t.Logf("query results: %#v", photos) } diff --git a/internal/entity/string_test.go b/internal/entity/string_test.go index 413dfcfed..ad24b3676 100644 --- a/internal/entity/string_test.go +++ b/internal/entity/string_test.go @@ -30,7 +30,7 @@ func TestClip(t *testing.T) { }) t.Run("ToASCII", func(t *testing.T) { result := Clip(ToASCII(strings.ToLower(" 幸福 Hanzi are logograms developed for the writing of Chinese! Expressions in an index may not ...!")), ClipStringType) - assert.Equal(t, "hanzi are logograms developed for the writing of chinese! expres", result) + assert.Equal(t, "hanzi are logograms developed for the writing of chinese! express", result) assert.Equal(t, 64, len(result)) }) t.Run("Empty", func(t *testing.T) { @@ -48,6 +48,6 @@ func TestSanitizeStringType(t *testing.T) { func TestSanitizeStringTypeLower(t *testing.T) { result := SanitizeStringTypeLower(" 幸福 Hanzi are logograms developed for the writing of Chinese! Expressions in an index may not ...!") - assert.Equal(t, "hanzi are logograms developed for the writing of chinese! expres", result) + assert.Equal(t, "hanzi are logograms developed for the writing of chinese! express", result) assert.Equal(t, ClipStringType, len(result)) } diff --git a/internal/photoprism/backup/albums.go b/internal/photoprism/backup/albums.go index a72b34999..e1c554b6d 100644 --- a/internal/photoprism/backup/albums.go +++ b/internal/photoprism/backup/albums.go @@ -49,7 +49,7 @@ func Albums(backupPath string, force bool) (count int, err error) { continue } - // Remember the lastest modification timestamp. + // Remember the latest modification timestamp. if changed.After(latest) { latest = changed } diff --git a/internal/photoprism/convert_image.go b/internal/photoprism/convert_image.go index 355bccde2..7e51566e8 100644 --- a/internal/photoprism/convert_image.go +++ b/internal/photoprism/convert_image.go @@ -94,7 +94,7 @@ func (w *Convert) ToImage(f *MediaFile, force bool) (result *MediaFile, err erro case fs.ExtJpeg: _, err = thumb.Jpeg(f.FileName(), imageName, f.Orientation()) default: - return nil, fmt.Errorf("convert: unspported target format %s (%s)", fs.LowerExt(imageName), clean.Log(f.RootRelName())) + return nil, fmt.Errorf("convert: unsupported target format %s (%s)", fs.LowerExt(imageName), clean.Log(f.RootRelName())) } // Check result. @@ -121,7 +121,7 @@ func (w *Convert) ToImage(f *MediaFile, force bool) (result *MediaFile, err erro cmds, useMutex, err = w.JpegConvertCmds(f, imageName, xmpName) expectedMime = header.ContentTypeJpeg default: - return nil, fmt.Errorf("convert: unspported target format %s (%s)", fs.LowerExt(imageName), clean.Log(f.RootRelName())) + return nil, fmt.Errorf("convert: unsupported target format %s (%s)", fs.LowerExt(imageName), clean.Log(f.RootRelName())) } if err != nil { diff --git a/pkg/clean/gps_test.go b/pkg/clean/gps_test.go index 08d2b6c54..fe4daac0c 100644 --- a/pkg/clean/gps_test.go +++ b/pkg/clean/gps_test.go @@ -27,7 +27,7 @@ func TestGPSBounds(t *testing.T) { assert.NoError(t, err) }) t.Run("China", func(t *testing.T) { - // Actual postion: Lat 39.8922, Lng 116.315 + // Actual position: Lat 39.8922, Lng 116.315 latNorth, lngEast, latSouth, lngWest, err := GPSBounds("39.8922004699707,116.31500244140625,39.8922004699707,116.31500244140625") assert.InEpsilon(t, 39.8924, latNorth, 0.00001) assert.InEpsilon(t, 116.3152, lngEast, 0.00001) diff --git a/pkg/clean/type_test.go b/pkg/clean/type_test.go index 1bc99f36a..c91b33920 100644 --- a/pkg/clean/type_test.go +++ b/pkg/clean/type_test.go @@ -32,7 +32,7 @@ func TestClip(t *testing.T) { }) t.Run("ToASCII", func(t *testing.T) { result := clip.Chars(ASCII(strings.ToLower(" 幸福 Hanzi are logograms developed for the writing of Chinese! Expressions in an index may not ...!")), LengthType) - assert.Equal(t, "hanzi are logograms developed for the writing of chinese! expres", result) + assert.Equal(t, "hanzi are logograms developed for the writing of chinese! expres", result) # codespell:ignore assert.Equal(t, 64, len(result)) }) t.Run("Empty", func(t *testing.T) { @@ -56,7 +56,7 @@ func TestType(t *testing.T) { func TestTypeLower(t *testing.T) { t.Run("Clip", func(t *testing.T) { result := TypeLower(" 幸福 Hanzi are logograms developed for the writing of Chinese! Expressions in an index may not ...!") - assert.Equal(t, "hanzi are logograms developed for the writing of chinese! expres", result) + assert.Equal(t, "hanzi are logograms developed for the writing of chinese! expres", result) # codespell:ignore assert.Equal(t, LengthType, len(result)) }) t.Run("Empty", func(t *testing.T) { diff --git a/pkg/clusters/README.md b/pkg/clusters/README.md index 498e15a55..05586ac25 100644 --- a/pkg/clusters/README.md +++ b/pkg/clusters/README.md @@ -15,7 +15,7 @@ This package also provides utilities for importing data and estimating the optim ## About -This library was built out of necessity for a collection of performant cluster analysis utilities for Golang. Go, thanks to its numerous advantages (single binary distrubution, relative performance, growing community) seems to become an attractive alternative to languages commonly used in statistical computations and machine learning, yet it still lacks crucial tools and libraries. I use the [*floats* package](https://github.com/gonum/gonum/tree/master/floats) from the robust Gonum library to perform optimized vector calculations in tight loops. +This library was built out of necessity for a collection of performant cluster analysis utilities for Golang. Go, thanks to its numerous advantages (single binary distribution, relative performance, growing community) seems to become an attractive alternative to languages commonly used in statistical computations and machine learning, yet it still lacks crucial tools and libraries. I use the [*floats* package](https://github.com/gonum/gonum/tree/master/floats) from the robust Gonum library to perform optimized vector calculations in tight loops. ## Installation @@ -54,7 +54,7 @@ for index, number := range c.Guesses() { } ``` -Algorithms currenly supported are KMeans++, DBSCAN and OPTICS. +Algorithms currently supported are KMeans++, DBSCAN and OPTICS. Algorithms which support online learning can be trained this way using Online() function, which relies on channel communication to coordinate the process: diff --git a/pkg/txt/country.go b/pkg/txt/country.go index 4b9974e2f..fb0a5372d 100644 --- a/pkg/txt/country.go +++ b/pkg/txt/country.go @@ -9,7 +9,7 @@ var UnknownStateCode = "zz" var UnknownCountryCode = "zz" var CountryWordsRegexp = regexp.MustCompile("[\\p{L}]{2,}") -// CountryCode tries to find a matching country code for a given string e.g. from a file oder directory name. +// CountryCode tries to find a matching country code for a given string e.g. from a file or directory name. func CountryCode(s string) (code string) { code = UnknownCountryCode diff --git a/pkg/txt/datetime_year.go b/pkg/txt/datetime_year.go index 21f944e9c..4671c0ee2 100644 --- a/pkg/txt/datetime_year.go +++ b/pkg/txt/datetime_year.go @@ -1,6 +1,6 @@ package txt -// Year tries to find a matching year for a given string e.g. from a file oder directory name. +// Year tries to find a matching year for a given string e.g. from a file or directory name. func Year(s string) int { b := []byte(s) diff --git a/pkg/txt/is_test.go b/pkg/txt/is_test.go index 928a054c1..d51c93dfd 100644 --- a/pkg/txt/is_test.go +++ b/pkg/txt/is_test.go @@ -133,7 +133,7 @@ func TestIsNumeral(t *testing.T) { assert.True(t, IsNumeral("1st")) }) t.Run("2ND", func(t *testing.T) { - assert.True(t, IsNumeral("1ND")) + assert.True(t, IsNumeral("1ND")) # codespell:ignore }) t.Run("40th", func(t *testing.T) { assert.True(t, IsNumeral("40th")) diff --git a/pkg/vector/values.go b/pkg/vector/values.go index 83c9552e2..7e59a2999 100644 --- a/pkg/vector/values.go +++ b/pkg/vector/values.go @@ -125,7 +125,7 @@ func (v Vector) variance(mean float64) float64 { // Product returns a vector of element-wise products of two input vectors. func Product(a, b Vector) (Vector, error) { if len(a) != len(b) { - return nil, fmt.Errorf("vector dimentions do not match (%d, %d)", len(a), len(b)) + return nil, fmt.Errorf("vector dimensions do not match (%d, %d)", len(a), len(b)) } p := make(Vector, len(a)) diff --git a/scripts/dist/convert/policy.xml b/scripts/dist/convert/policy.xml index 328037f1c..7a1482094 100644 --- a/scripts/dist/convert/policy.xml +++ b/scripts/dist/convert/policy.xml @@ -38,7 +38,7 @@ - Use the default system font unless overwridden by the application: + Use the default system font unless overridden by the application: diff --git a/setup/docker/cloud/traefik.yaml b/setup/docker/cloud/traefik.yaml index d36f8f431..740c40c83 100644 --- a/setup/docker/cloud/traefik.yaml +++ b/setup/docker/cloud/traefik.yaml @@ -30,7 +30,7 @@ serversTransport: rootCAs: - "/certs/ca.crt" -# open ports ond protocols (HTTP will be redirected to HTTPS) +# open ports and protocols (HTTP will be redirected to HTTPS) entryPoints: web: address: ":80"