Switch to uk (#2557)

* Setting golangci to UK english (that's what we use in AU)

* Fixing more spelling

* Fixing

* Include MD files in spell checker
This commit is contained in:
Mike Farah 2025-12-20 19:11:48 +11:00 committed by GitHub
parent 37e48cea44
commit 4a06cce376
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 70 additions and 66 deletions

View File

@ -14,6 +14,11 @@ linters:
- unconvert
- unparam
settings:
misspell:
locale: UK
ignore-rules:
- color
- colors
depguard:
rules:
prevent_unmaintained_packages:

View File

@ -11,7 +11,7 @@ appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
Examples of behaviour that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
@ -20,7 +20,7 @@ include:
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
Examples of unacceptable behaviour by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
@ -34,13 +34,13 @@ Examples of unacceptable behavior by participants include:
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
behaviour and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behaviour.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
permanently any contributor for other behaviours that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
@ -54,7 +54,7 @@ further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
Instances of abusive, harassing, or otherwise unacceptable behaviour may be
reported by contacting the project team at mikefarah@gmail.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is

View File

@ -4,10 +4,11 @@
- run ./scripts/format.sh to format the code; then ./scripts/check.sh lint and finally ./scripts/spelling.sh to check spelling.
- Add comprehensive tests to cover the changes
- Run test suite to ensure there is no regression
- Use UK english spelling (e.g. Colorisation not Colorization)
- Use UK english spelling
❌ **DON'T:**
- Git add or commit
- Add comments to functions that are self-explanatory
@ -196,14 +197,6 @@ Tests must be implemented in `<format>_test.go` following the `formatScenario` p
## Common Patterns
### Scalar-Only Formats
Some formats only work with scalars (like base64, uri):
```go
if node.guessTagFromCustomType() != "!!str" {
return fmt.Errorf("cannot encode %v as <format>, can only operate on strings", node.Tag)
}
```
### Format with Indentation
Use preferences to control output formatting:
```go

View File

@ -60,7 +60,7 @@ func evaluateAll(cmd *cobra.Command, args []string) (cmdError error) {
out := cmd.OutOrStdout()
if writeInplace {
// only use colors if its forced
// only use colours if its forced
colorsEnabled = forceColor
writeInPlaceHandler := yqlib.NewWriteInPlaceHandler(args[0])
out, err = writeInPlaceHandler.CreateTempFile()

View File

@ -74,7 +74,7 @@ func evaluateSequence(cmd *cobra.Command, args []string) (cmdError error) {
}
if writeInplace {
// only use colors if its forced
// only use colours if its forced
colorsEnabled = forceColor
writeInPlaceHandler := yqlib.NewWriteInPlaceHandler(args[0])
out, err = writeInPlaceHandler.CreateTempFile()

View File

@ -184,7 +184,7 @@ yq -P -oy sample.json
}
rootCmd.Flags().BoolVarP(&version, "version", "V", false, "Print version information and quit")
rootCmd.PersistentFlags().BoolVarP(&writeInplace, "inplace", "i", false, "update the file in place of first file given.")
rootCmd.PersistentFlags().VarP(unwrapScalarFlag, "unwrapScalar", "r", "unwrap scalar, print the value with no quotes, colors or comments. Defaults to true for yaml")
rootCmd.PersistentFlags().VarP(unwrapScalarFlag, "unwrapScalar", "r", "unwrap scalar, print the value with no quotes, colours or comments. Defaults to true for yaml")
rootCmd.PersistentFlags().Lookup("unwrapScalar").NoOptDefVal = "true"
rootCmd.PersistentFlags().BoolVarP(&nulSepOutput, "nul-output", "0", false, "Use NUL char to separate values. If unwrap scalar is also set, fail if unwrapped scalar contains NUL char.")

View File

@ -926,13 +926,13 @@ func TestSetupColors(t *testing.T) {
expectColors bool
}{
{
name: "force color enabled",
name: "force colour enabled",
forceColor: true,
forceNoColor: false,
expectColors: true,
},
{
name: "force no color enabled",
name: "force no colour enabled",
forceColor: false,
forceNoColor: true,
expectColors: false,

View File

@ -16,7 +16,7 @@ type iniDecoder struct {
func NewINIDecoder() Decoder {
return &iniDecoder{
finished: false, // Initialize the flag as false
finished: false, // Initialise the flag as false
}
}

View File

@ -78,7 +78,7 @@ func (dec *yamlDecoder) processReadStream(reader *bufio.Reader) (io.Reader, stri
if separatorPrefixRe.MatchString(line) {
match := separatorPrefixRe.FindString(line)
remainder := line[len(match):]
// normalize separator newline: if original had none, default to LF
// normalise separator newline: if original had none, default to LF
sepNewline := newline
if sepNewline == "" {
sepNewline = "\n"

View File

@ -22,7 +22,7 @@ see https://yaml.org/type/merge.html
Given a sample.yml file of:
```yaml
- &CENTER
- &CENTRE
x: 1
y: 2
- &LEFT
@ -32,7 +32,7 @@ Given a sample.yml file of:
r: 10
- &SMALL
r: 1
- !!merge <<: *CENTER
- !!merge <<: *CENTRE
r: 10
```
then
@ -288,7 +288,7 @@ see https://yaml.org/type/merge.html. This has the correct data, but the wrong k
Given a sample.yml file of:
```yaml
- &CENTER
- &CENTRE
x: 1
y: 2
- &LEFT
@ -299,7 +299,7 @@ Given a sample.yml file of:
- &SMALL
r: 1
- !!merge <<:
- *CENTER
- *CENTRE
- *BIG
```
then
@ -318,7 +318,7 @@ see https://yaml.org/type/merge.html. This has the correct data, but the wrong k
Given a sample.yml file of:
```yaml
- &CENTER
- &CENTRE
x: 1
y: 2
- &LEFT
@ -401,7 +401,7 @@ Taken from https://yaml.org/type/merge.html. Same values as legacy, but with the
Given a sample.yml file of:
```yaml
- &CENTER
- &CENTRE
x: 1
y: 2
- &LEFT
@ -412,7 +412,7 @@ Given a sample.yml file of:
- &SMALL
r: 1
- !!merge <<:
- *CENTER
- *CENTRE
- *BIG
```
then
@ -432,7 +432,7 @@ Taken from https://yaml.org/type/merge.html. Same values as legacy, but with the
Given a sample.yml file of:
```yaml
- &CENTER
- &CENTRE
x: 1
y: 2
- &LEFT

View File

@ -2,7 +2,7 @@
Various operators for parsing and manipulating dates.
## Date time formattings
## Date time formatting
This uses Golang's built in time library for parsing and formatting date times.
When not specified, the RFC3339 standard is assumed `2006-01-02T15:04:05Z07:00` for parsing.

View File

@ -2,7 +2,7 @@
Various operators for parsing and manipulating dates.
## Date time formattings
## Date time formatting
This uses Golang's built in time library for parsing and formatting date times.
When not specified, the RFC3339 standard is assumed `2006-01-02T15:04:05Z07:00` for parsing.

View File

@ -66,8 +66,8 @@ func (he *hclEncoder) Encode(writer io.Writer, node *CandidateNode) error {
finalOutput := he.injectComments(compactOutput, commentMap)
if he.prefs.ColorsEnabled {
colorized := he.colorizeHcl(finalOutput)
_, err := writer.Write(colorized)
colourized := he.colorizeHcl(finalOutput)
_, err := writer.Write(colourized)
return err
}
@ -173,19 +173,18 @@ func (he *hclEncoder) injectComments(output []byte, commentMap map[string]string
return []byte(result)
}
// colorizeHcl applies syntax highlighting to HCL output using fatih/color
func (he *hclEncoder) colorizeHcl(input []byte) []byte {
hcl := string(input)
result := strings.Builder{}
// Create color functions for different token types
// Create colour functions for different token types
commentColor := color.New(color.FgHiBlack).SprintFunc()
stringColor := color.New(color.FgGreen).SprintFunc()
numberColor := color.New(color.FgHiMagenta).SprintFunc()
keyColor := color.New(color.FgCyan).SprintFunc()
boolColor := color.New(color.FgHiMagenta).SprintFunc()
// Simple tokenization for HCL coloring
// Simple tokenization for HCL colouring
i := 0
for i < len(hcl) {
ch := hcl[i]
@ -476,12 +475,12 @@ func (he *hclEncoder) encodeBlockIfMapping(body *hclwrite.Body, key string, valu
}
}
// If all child values are mappings, treat each child key as a labeled instance of this block type
// If all child values are mappings, treat each child key as a labelled instance of this block type
if handled, _ := he.encodeMappingChildrenAsBlocks(body, key, valueNode); handled {
return true
}
// No labels detected, render as unlabeled block
// No labels detected, render as unlabelled block
block := body.AppendNewBlock(key, nil)
if err := he.encodeNodeAttributes(block.Body(), valueNode); err == nil {
return true

View File

@ -45,8 +45,8 @@ func (te *tomlEncoder) Encode(writer io.Writer, node *CandidateNode) error {
}
if te.prefs.ColorsEnabled {
colorized := te.colorizeToml(buf.Bytes())
_, err := writer.Write(colorized)
colourised := te.colorizeToml(buf.Bytes())
_, err := writer.Write(colourised)
return err
}
@ -547,7 +547,7 @@ func (te *tomlEncoder) colorizeToml(input []byte) []byte {
boolColor := color.New(color.FgHiMagenta).SprintFunc()
sectionColor := color.New(color.FgYellow, color.Bold).SprintFunc()
// Simple tokenization for TOML coloring
// Simple tokenization for TOML colouring
i := 0
for i < len(toml) {
ch := toml[i]

View File

@ -4,7 +4,7 @@ import (
"testing"
)
var specDocument = `- &CENTER { x: 1, y: 2 }
var specDocument = `- &CENTRE { x: 1, y: 2 }
- &LEFT { x: 0, y: 2 }
- &BIG { r: 10 }
- &SMALL { r: 1 }
@ -139,7 +139,7 @@ var fixedAnchorOperatorScenarios = []expressionScenario{
{
description: "FIXED: Merge multiple maps",
subdescription: "Taken from https://yaml.org/type/merge.html. Same values as legacy, but with the correct key order.",
document: specDocument + "- << : [ *CENTER, *BIG ]\n",
document: specDocument + "- << : [ *CENTRE, *BIG ]\n",
expression: ".[4] | explode(.)",
expected: []string{"D0, P[4], (!!map)::x: 1\ny: 2\nr: 10\n"},
},
@ -171,7 +171,7 @@ var fixedAnchorOperatorScenarios = []expressionScenario{
},
{
skipDoc: true,
description: "Exploding merge anchor should not explode neighbors",
description: "Exploding merge anchor should not explode neighbours",
subdescription: "b must not be exploded, as `r: *a` will become invalid",
document: `{b: &b {a: &a 42}, r: *a, c: {<<: *b}}`,
expression: `explode(.c)`,
@ -181,7 +181,7 @@ var fixedAnchorOperatorScenarios = []expressionScenario{
},
{
skipDoc: true,
description: "Exploding sequence merge anchor should not explode neighbors",
description: "Exploding sequence merge anchor should not explode neighbours",
subdescription: "b must not be exploded, as `r: *a` will become invalid",
document: `{b: &b {a: &a 42}, r: *a, c: {<<: [*b]}}`,
expression: `explode(.c)`,
@ -265,7 +265,7 @@ var badAnchorOperatorScenarios = []expressionScenario{
{
description: "LEGACY: Merge multiple maps",
subdescription: "see https://yaml.org/type/merge.html. This has the correct data, but the wrong key order; set --yaml-fix-merge-anchor-to-spec=true to fix the key order.",
document: specDocument + "- << : [ *CENTER, *BIG ]\n",
document: specDocument + "- << : [ *CENTRE, *BIG ]\n",
expression: ".[4] | explode(.)",
expected: []string{"D0, P[4], (!!map)::r: 10\nx: 1\ny: 2\n"},
},
@ -297,7 +297,7 @@ var anchorOperatorScenarios = []expressionScenario{
{
description: "Merge one map",
subdescription: "see https://yaml.org/type/merge.html",
document: specDocument + "- << : *CENTER\n r: 10\n",
document: specDocument + "- << : *CENTRE\n r: 10\n",
expression: ".[4] | explode(.)",
expected: []string{expectedSpecResult},
},

View File

@ -132,7 +132,7 @@ func (p *resultsPrinter) PrintResults(matchingNodes *list.List) error {
tempBufferBytes := tempBuffer.Bytes()
if bytes.IndexByte(tempBufferBytes, 0) != -1 {
return fmt.Errorf(
"can't serialize value because it contains NUL char and you are using NUL separated output",
"can't serialise value because it contains NUL char and you are using NUL separated output",
)
}
if _, err := writer.Write(tempBufferBytes); err != nil {

View File

@ -481,7 +481,7 @@ func TestPrinterNulSeparatorWithNullChar(t *testing.T) {
t.Fatal("Expected error for null character in NUL separated output")
}
expectedError := "can't serialize value because it contains NUL char and you are using NUL separated output"
expectedError := "can't serialise value because it contains NUL char and you are using NUL separated output"
if err.Error() != expectedError {
t.Fatalf("Expected error '%s', got '%s'", expectedError, err.Error())
}

View File

@ -695,14 +695,14 @@ func TestTomlColorisationNumberBug(t *testing.T) {
encoder := NewTomlEncoder()
tomlEncoder := encoder.(*tomlEncoder)
// Test case that exposes the bug: "123-+-45" should NOT be colorized as a single number
// Test case that exposes the bug: "123-+-45" should NOT be colourised as a single number
input := "A = 123-+-45\n"
result := string(tomlEncoder.colorizeToml([]byte(input)))
// The bug causes "123-+-45" to be colorized as one token
// The bug causes "123-+-45" to be colourised as one token
// It should stop at "123" because the next character '-' is not valid in this position
if strings.Contains(result, "123-+-45") {
// Check if it's colorized as a single token (no color codes in the middle)
// Check if it's colourised as a single token (no color codes in the middle)
idx := strings.Index(result, "123-+-45")
// Look backwards for color code
beforeIdx := idx - 1
@ -722,8 +722,8 @@ func TestTomlColorisationNumberBug(t *testing.T) {
if beforeIdx >= 0 && hasResetAfter {
// The entire "123-+-45" is wrapped in color codes - this is the bug!
t.Errorf("BUG DETECTED: '123-+-45' is incorrectly colorized as a single number")
t.Errorf("Expected only '123' to be colorized as a number, but got the entire '123-+-45'")
t.Errorf("BUG DETECTED: '123-+-45' is incorrectly colourised as a single number")
t.Errorf("Expected only '123' to be colourised as a number, but got the entire '123-+-45'")
t.Logf("Full output: %q", result)
t.Fail()
}
@ -740,13 +740,13 @@ func TestTomlColorisationNumberBug(t *testing.T) {
name: "consecutive minuses",
input: "A = 123--45\n",
invalidSequence: "123--45",
description: "'123--45' should not be colorized as a single number",
description: "'123--45' should not be colourised as a single number",
},
{
name: "plus in middle",
input: "A = 123+45\n",
invalidSequence: "123+45",
description: "'123+45' should not be colorized as a single number",
description: "'123+45' should not be colourised as a single number",
},
}
@ -791,7 +791,7 @@ func TestTomlColorisationNumberBug(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
result := tomlEncoder.colorizeToml([]byte(tt.input))
if len(result) == 0 {
t.Error("Expected non-empty colorized output")
t.Error("Expected non-empty colourised output")
}
})
}
@ -816,7 +816,7 @@ func TestTomlStringEscapeColourization(t *testing.T) {
{
name: "escaped quote at end",
input: `A = "test\""` + "\n",
description: "String ending with escaped quote should be colorized correctly",
description: "String ending with escaped quote should be colourised correctly",
},
{
name: "escaped backslash then quote",
@ -826,7 +826,7 @@ func TestTomlStringEscapeColourization(t *testing.T) {
{
name: "escaped quote in middle",
input: `A = "test\"middle"` + "\n",
description: "String with escaped quote in the middle should be colorized correctly",
description: "String with escaped quote in the middle should be colourised correctly",
},
{
name: "multiple escaped quotes",
@ -836,7 +836,7 @@ func TestTomlStringEscapeColourization(t *testing.T) {
{
name: "escaped newline",
input: `A = "test\n"` + "\n",
description: "String with escaped newline should be colorized correctly",
description: "String with escaped newline should be colourised correctly",
},
{
name: "single quote with escaped single quote",
@ -850,7 +850,7 @@ func TestTomlStringEscapeColourization(t *testing.T) {
// The test should not panic and should return some output
result := tomlEncoder.colorizeToml([]byte(tt.input))
if len(result) == 0 {
t.Error("Expected non-empty colorized output")
t.Error("Expected non-empty colourised output")
}
// Check that the result contains the input string (with color codes)

View File

@ -38,7 +38,8 @@ cleanup
cmlu
colorise
colors
coloring
Colors
colourize
compinit
coolioo
coverprofile
@ -276,5 +277,11 @@ nohcl
zclconf
cty
go-cty
unlabeled
colorisation
Colorisation
goimports
errorlint
RDBMS
expeñded
bananabananabananabanana
edwinjhlee
flox

View File

@ -1,3 +1,3 @@
#!/bin/bash
npx cspell --no-progress "**/*.{sh,go}"
npx cspell --no-progress "**/*.{sh,go,md}"