Skip to content

Commit 685188a

Browse files
authored
⚙️ Enforce misspell linter (#532)
<!-- Copyright (C) 2020-2022 Arm Limited or its affiliates and Contributors. All rights reserved. SPDX-License-Identifier: Apache-2.0 --> ### Description - add a golangci linter ### Test Coverage <!-- Please put an `x` in the correct box e.g. `[x]` to indicate the testing coverage of this change. --> - [x] This change is covered by existing or additional automated tests. - [ ] Manual testing has been performed (and evidence provided) as automated testing was not feasible. - [ ] Additional tests are not required for this change (e.g. documentation update).
1 parent 9e4096d commit 685188a

File tree

15 files changed

+45
-32
lines changed

15 files changed

+45
-32
lines changed

.golangci.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ linters:
2323
- revive
2424
- gocritic
2525
- unconvert
26+
- misspell
2627

2728
linters-settings:
2829
goimports:
@@ -39,3 +40,12 @@ linters-settings:
3940
disabled: false
4041
arguments:
4142
- "disableStutteringCheck"
43+
misspell:
44+
locale: UK
45+
extra-words:
46+
- typo: "sanetisation"
47+
correction: "sanitisation"
48+
- typo: "sanetise"
49+
correction: "sanitise"
50+
- typo: "sanetising"
51+
correction: "sanitising"

.pre-commit-config.yaml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
minimum_pre_commit_version: 1.7.0
2-
repos:
3-
- repo: local
4-
hooks:
5-
- id: golangci-lint
6-
name: golangci-lint
7-
description: Fast linters runner for Go.
8-
# Disabling Go module support is necessary to avoid it complaining about a missing go.mod file in the root
9-
entry: env GO111MODULE=off golangci-lint run --config=.golangci.pre-commit.yaml ./...
10-
language: system
11-
types: [go]
12-
pass_filenames: false
13-
14-
- repo: https://github.com/ARMmbed/continuous-delivery-scripts.git
15-
rev: 2.5.0
16-
hooks:
1+
minimum_pre_commit_version: 1.7.0
2+
repos:
3+
- repo: local
4+
hooks:
5+
- id: golangci-lint
6+
name: golangci-lint
7+
description: Fast linters runner for Go.
8+
# Disabling Go module support is necessary to avoid it complaining about a missing go.mod file in the root
9+
entry: env GO111MODULE=off golangci-lint run --config=.golangci.pre-commit.yaml ./...
10+
language: system
11+
types: [go]
12+
pass_filenames: false
13+
14+
- repo: https://github.com/golangci/misspell
15+
rev: v0.6.0
16+
hooks:
17+
- id: misspell
18+
19+
- repo: https://github.com/ARMmbed/continuous-delivery-scripts.git
20+
rev: 2.5.0
21+
hooks:
1722
- id: licensing

changes/202412161019.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:gear: Enforce [misspell](https://pkg.go.dev/github.com/golangci/misspell) linter

utils/config/service_configuration.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func convertViperError(vErr error) (err error) {
115115
err = fmt.Errorf("%w: %v", commonerrors.ErrUnsupported, vErr.Error())
116116
case commonerrors.CorrespondTo(vErr, "not found"):
117117
err = fmt.Errorf("%w: %v", commonerrors.ErrNotFound, vErr.Error())
118-
case commonerrors.CorrespondTo(vErr, "parsing", "marshaling", "decoding"):
118+
case commonerrors.CorrespondTo(vErr, "parsing", "marshaling", "decoding"): //nolint: misspell // errors are written in American English
119119
err = fmt.Errorf("%w: %v", commonerrors.ErrMarshalling, vErr.Error())
120120
default:
121121
err = fmt.Errorf("%w: %v", commonerrors.ErrUnexpected, vErr.Error())
@@ -335,9 +335,6 @@ func DetermineConfigurationEnvironmentVariables(appName string, configurationToD
335335
return
336336
}
337337
withoutPrefix = flattenDefaultsMap(withoutPrefix)
338-
if err != nil {
339-
return
340-
}
341338

342339
defaults = make(map[string]interface{})
343340
for key, value := range withoutPrefix {

utils/config/service_configuration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ func TestGenerateEnvFile_Defaults(t *testing.T) {
495495

496496
// Test that you can load the struct with viper then generate the env file
497497
func TestGenerateEnvFile_Populated(t *testing.T) {
498-
// Load configuartion using viper
498+
// Load configuration using viper
499499
os.Clearenv()
500500
configTest := &DummyConfiguration{}
501501
defaults := DefaultDummyConfiguration()

utils/environment/envvar_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func TestParseEnvironmentVariable(t *testing.T) {
154154

155155
func TestEnvVar_ParseEnvironmentVariables(t *testing.T) {
156156
username := faker.Username()
157-
entries := []string{"DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/65357/bus", "HOME=/home/josjen01", faker.UUIDHyphenated(), "EDITOR=hx", "LOGNAME=josjen01", "DISPLAY=:0", "SSH_AUTH_SOCK=/tmp/ssh-eBrdhiWnaFYp/agent.4969", "KRB5CCNAME=FILE:/tmp/krb5cc_65357_XLwjEE", "GPG_AGENT_INFO=/run/user/65357/gnupg/S.gpg-agent:0:1", "LANGUAGE=en_US:", "USER=" + username, "XDG_RUNTIME_DIR=/run/user/65357", "WINDOWID=54525966", "KITTY_PID=151539", "CMSIS_PACK_ROOT=/home/josjen01/.cache/arm/packs", "XDG_SESSION_ID=4", "XDG_CONFIG_DIRS=/etc/xdg/xdg-i3:/etc/xdg", faker.Name(), "GDMSESSION=i3", "WINDOWPATH=2", "SHLVL=1", "DESKTOP_SESSION=i3", "GTK_MODULES=gail:atk-bridge", "LANG=en_US.UTF-8", "FZF_DEFAULT_OPTS=--color dark,hl:#d65d08,hl+:#d65d08,fg+:#282828,bg+:#282828,fg+:#b58900,info:#ebdbb2,prompt:#268bd2,pointer:#2aa198,marker:#d33682,spinner:#268bd2 -m", "XDG_SESSION_DESKTOP=i3", "XDG_SESSION_TYPE=x11", "KITTY_PUBLIC_KEY=1:^1R-7)Aw|}io+D^KqaYVJF0R&a!f&dpX}gSSEIH&", "XDG_SEAT=seat0", "TERM=xterm-kitty", "XDG_DATA_DIRS=/usr/share/i3:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop", "DESKTOP_STARTUP_ID=i3/kitty/4969-5-e126332_TIME31895328", "SHELL=/bin/bash", "KITTY_WINDOW_ID=6", "QT_ACCESSIBILITY=1", "COLORTERM=truecolor", "TERMINFO=/home/josjen01/.local/kitty.app/lib/kitty/terminfo", "SSH_AGENT_PID=5033", "XDG_SESSION_CLASS=user", "KITTY_INSTALLATION_DIR=/home/josjen01/.local/kitty.app/lib/kitty", "XDG_CURRENT_DESKTOP=i3", "MANPATH=:/home/josjen01/.local/kitty.app/share/man::/opt/puppetlabs/puppet/share/man", "XAUTHORITY=/run/user/65357/gdm/Xauthority", "CMSIS_COMPILER_ROOT=/etc/cmsis-build", "XDG_VTNR=2", "I3SOCK=/run/user/65357/i3/ipc-socket.4969", "USERNAME=josjen01", "PATH=/usr/local/go/bin:/bin:/home/josjen01/.local/bin:/home/josjen01/go/bin:/home/josjen01/.cargo/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/usr/games:/usr/local/games:/snap/bin:/opt/puppetlabs/bin", "PWD=/home/josjen01/Git/golang-utils/utils/environment", "GOCOVERDIR=/tmp/go-build1026478377/b001/gocoverdir", "test1=Accusantium voluptatem aut sit perferendis consequatur", "test2=Perferendis aut accusantium voluptatem sit consequatur.", faker.Word()}
157+
entries := []string{"DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/65357/bus", "HOME=/home/josjen01", faker.UUIDHyphenated(), "EDITOR=hx", "LOGNAME=josjen01", "DISPLAY=:0", "SSH_AUTH_SOCK=/tmp/ssh-eBrdhiWnaFYp/agent.4969", "KRB5CCNAME=FILE:/tmp/krb5cc_65357_XLwjEE", "GPG_AGENT_INFO=/run/user/65357/gnupg/S.gpg-agent:0:1", "LANGUAGE=en_US:", "USER=" + username, "XDG_RUNTIME_DIR=/run/user/65357", "WINDOWID=54525966", "KITTY_PID=151539", "CMSIS_PACK_ROOT=/home/josjen01/.cache/arm/packs", "XDG_SESSION_ID=4", "XDG_CONFIG_DIRS=/etc/xdg/xdg-i3:/etc/xdg", faker.Name(), "GDMSESSION=i3", "WINDOWPATH=2", "SHLVL=1", "DESKTOP_SESSION=i3", "GTK_MODULES=gail:atk-bridge", "LANG=en_US.UTF-8", "FZF_DEFAULT_OPTS=--colour dark,hl:#d65d08,hl+:#d65d08,fg+:#282828,bg+:#282828,fg+:#b58900,info:#ebdbb2,prompt:#268bd2,pointer:#2aa198,marker:#d33682,spinner:#268bd2 -m", "XDG_SESSION_DESKTOP=i3", "XDG_SESSION_TYPE=x11", "KITTY_PUBLIC_KEY=1:^1R-7)Aw|}io+D^KqaYVJF0R&a!f&dpX}gSSEIH&", "XDG_SEAT=seat0", "TERM=xterm-kitty", "XDG_DATA_DIRS=/usr/share/i3:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop", "DESKTOP_STARTUP_ID=i3/kitty/4969-5-e126332_TIME31895328", "SHELL=/bin/bash", "KITTY_WINDOW_ID=6", "QT_ACCESSIBILITY=1", "COLOURTERM=truecolour", "TERMINFO=/home/josjen01/.local/kitty.app/lib/kitty/terminfo", "SSH_AGENT_PID=5033", "XDG_SESSION_CLASS=user", "KITTY_INSTALLATION_DIR=/home/josjen01/.local/kitty.app/lib/kitty", "XDG_CURRENT_DESKTOP=i3", "MANPATH=:/home/josjen01/.local/kitty.app/share/man::/opt/puppetlabs/puppet/share/man", "XAUTHORITY=/run/user/65357/gdm/Xauthority", "CMSIS_COMPILER_ROOT=/etc/cmsis-build", "XDG_VTNR=2", "I3SOCK=/run/user/65357/i3/ipc-socket.4969", "USERNAME=josjen01", "PATH=/usr/local/go/bin:/bin:/home/josjen01/.local/bin:/home/josjen01/go/bin:/home/josjen01/.cargo/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/usr/games:/usr/local/games:/snap/bin:/opt/puppetlabs/bin", "PWD=/home/josjen01/Git/golang-utils/utils/environment", "GOCOVERDIR=/tmp/go-build1026478377/b001/gocoverdir", "test1=Accusantium voluptatem aut sit perferendis consequatur", "test2=Perferendis aut accusantium voluptatem sit consequatur.", faker.Word()}
158158
environmentVariables := ParseEnvironmentVariables(entries...)
159159
assert.NotEmpty(t, environmentVariables)
160160
assert.Len(t, environmentVariables, len(entries)-3)

utils/filesystem/files_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ func TestStatTimes(t *testing.T) {
595595
for _, fsType := range FileSystemTypes {
596596
t.Run(fmt.Sprintf("%v_for_fs_%v", t.Name(), fsType), func(t *testing.T) {
597597
fs := NewFs(fsType)
598-
tmpFile, err := fs.TouchTempFileInTempDir("test-filetimes-*.txt")
598+
tmpFile, err := fs.TouchTempFileInTempDir("test-file-times-*.txt")
599599
require.NoError(t, err)
600600
defer func() { _ = fs.Rm(tmpFile) }()
601601

utils/filesystem/interfaces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ type FS interface {
141141
// See os.Open()
142142
GenericOpen(name string) (File, error)
143143
// OpenFile opens a file using the given flags and the given mode.
144-
// OpenFile is the generalized open call
144+
// OpenFile is the generalised open call
145145
// most users will use GenericOpen or Create instead.
146146
// See os.OpenFile
147147
OpenFile(name string, flag int, perm os.FileMode) (File, error)

utils/git/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type GitActionConfig struct {
1818
Depth int `mapstructure:"depth"`
1919
// Regerence can be a hash, a branch, or a tag
2020
Reference string `mapstructure:"ref"`
21-
// RecurseSubmodules after the clone is created, initialize all submodules
21+
// RecurseSubmodules after the clone is created, initialise all submodules
2222
// within, using their default settings. This option is ignored if the
2323
// cloned repository does not have a worktree.
2424
RecurseSubmodules bool `mapstructure:"recursive_submodules"`

utils/http/configuration.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ import (
1414
)
1515

1616
// HTTPClientConfiguration defines the client configuration. It can be used to tweak low level transport
17-
// parameters in order to adapt the client to your usecase.
17+
// parameters in order to adapt the client to your use case.
1818
// If unsure about the values to set, use the DefaultHTTPClientConfiguration or FastHTTPClientConfiguration depending on
1919
// what flow you are dealing with.
2020
type HTTPClientConfiguration struct {
2121
// MaxConnsPerHost optionally limits the total number of
22-
// connections per host, including connections in the dialing,
22+
// connections per host, including connections in the dialling,
2323
// active, and idle states. On limit violation, dials will block.
2424
//
2525
// Zero means no limit.

0 commit comments

Comments
 (0)