From bf70397358da80ce587f8f68d9d77814d2195bf0 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Sat, 20 Dec 2025 15:58:34 +1100 Subject: [PATCH] Setting golangci to UK english (that's what we use in AU) --- .golangci.yml | 7 +++++++ cmd/evaluate_all_command.go | 2 +- cmd/evaluate_sequence_command.go | 2 +- cmd/root.go | 2 +- cmd/utils_test.go | 4 ++-- pkg/yqlib/decoder_ini.go | 2 +- pkg/yqlib/decoder_yaml.go | 2 +- pkg/yqlib/encoder_hcl.go | 14 +++++++------- pkg/yqlib/operator_anchors_aliases_test.go | 12 ++++++------ pkg/yqlib/printer.go | 2 +- pkg/yqlib/printer_test.go | 2 +- project-words.txt | 5 +++-- 12 files changed, 32 insertions(+), 24 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 2a303b8f..77753a70 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -14,6 +14,13 @@ linters: - unconvert - unparam settings: + misspell: + locale: UK + ignore-rules: + - color + - colors + - COLOR + - github.com/fatih/color depguard: rules: prevent_unmaintained_packages: diff --git a/cmd/evaluate_all_command.go b/cmd/evaluate_all_command.go index ea82abef..8bc5ac9b 100644 --- a/cmd/evaluate_all_command.go +++ b/cmd/evaluate_all_command.go @@ -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() diff --git a/cmd/evaluate_sequence_command.go b/cmd/evaluate_sequence_command.go index 8bba7677..efa9dfa5 100644 --- a/cmd/evaluate_sequence_command.go +++ b/cmd/evaluate_sequence_command.go @@ -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() diff --git a/cmd/root.go b/cmd/root.go index b66d1cf9..ffbf55cb 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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.") diff --git a/cmd/utils_test.go b/cmd/utils_test.go index 67d45110..e2255e6b 100644 --- a/cmd/utils_test.go +++ b/cmd/utils_test.go @@ -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, diff --git a/pkg/yqlib/decoder_ini.go b/pkg/yqlib/decoder_ini.go index eb64b53e..159ca8b4 100644 --- a/pkg/yqlib/decoder_ini.go +++ b/pkg/yqlib/decoder_ini.go @@ -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 } } diff --git a/pkg/yqlib/decoder_yaml.go b/pkg/yqlib/decoder_yaml.go index 85906b36..98ddf263 100644 --- a/pkg/yqlib/decoder_yaml.go +++ b/pkg/yqlib/decoder_yaml.go @@ -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" diff --git a/pkg/yqlib/encoder_hcl.go b/pkg/yqlib/encoder_hcl.go index 2ba34e06..19560953 100644 --- a/pkg/yqlib/encoder_hcl.go +++ b/pkg/yqlib/encoder_hcl.go @@ -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,19 @@ func (he *hclEncoder) injectComments(output []byte, commentMap map[string]string return []byte(result) } -// colorizeHcl applies syntax highlighting to HCL output using fatih/color +// colorizeHcl applies syntax highlighting to HCL output using fatih/color //nolint:misspell 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 +476,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 diff --git a/pkg/yqlib/operator_anchors_aliases_test.go b/pkg/yqlib/operator_anchors_aliases_test.go index 4b4832e6..56eb4bdf 100644 --- a/pkg/yqlib/operator_anchors_aliases_test.go +++ b/pkg/yqlib/operator_anchors_aliases_test.go @@ -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}, }, diff --git a/pkg/yqlib/printer.go b/pkg/yqlib/printer.go index 5c11e39d..55af72ba 100644 --- a/pkg/yqlib/printer.go +++ b/pkg/yqlib/printer.go @@ -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 { diff --git a/pkg/yqlib/printer_test.go b/pkg/yqlib/printer_test.go index d55c9b41..89f4ae44 100644 --- a/pkg/yqlib/printer_test.go +++ b/pkg/yqlib/printer_test.go @@ -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()) } diff --git a/project-words.txt b/project-words.txt index 3c2ddda9..d5dc035c 100644 --- a/project-words.txt +++ b/project-words.txt @@ -38,7 +38,8 @@ cleanup cmlu colorise colors -coloring +Colors +colourize compinit coolioo coverprofile @@ -276,4 +277,4 @@ nohcl zclconf cty go-cty -unlabeled \ No newline at end of file +unlabelled \ No newline at end of file