mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-04 19:35:38 +00:00
Setting golangci to UK english (that's what we use in AU)
This commit is contained in:
parent
9fa353b123
commit
bf70397358
@ -14,6 +14,13 @@ linters:
|
|||||||
- unconvert
|
- unconvert
|
||||||
- unparam
|
- unparam
|
||||||
settings:
|
settings:
|
||||||
|
misspell:
|
||||||
|
locale: UK
|
||||||
|
ignore-rules:
|
||||||
|
- color
|
||||||
|
- colors
|
||||||
|
- COLOR
|
||||||
|
- github.com/fatih/color
|
||||||
depguard:
|
depguard:
|
||||||
rules:
|
rules:
|
||||||
prevent_unmaintained_packages:
|
prevent_unmaintained_packages:
|
||||||
|
|||||||
@ -60,7 +60,7 @@ func evaluateAll(cmd *cobra.Command, args []string) (cmdError error) {
|
|||||||
out := cmd.OutOrStdout()
|
out := cmd.OutOrStdout()
|
||||||
|
|
||||||
if writeInplace {
|
if writeInplace {
|
||||||
// only use colors if its forced
|
// only use colours if its forced
|
||||||
colorsEnabled = forceColor
|
colorsEnabled = forceColor
|
||||||
writeInPlaceHandler := yqlib.NewWriteInPlaceHandler(args[0])
|
writeInPlaceHandler := yqlib.NewWriteInPlaceHandler(args[0])
|
||||||
out, err = writeInPlaceHandler.CreateTempFile()
|
out, err = writeInPlaceHandler.CreateTempFile()
|
||||||
|
|||||||
@ -74,7 +74,7 @@ func evaluateSequence(cmd *cobra.Command, args []string) (cmdError error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if writeInplace {
|
if writeInplace {
|
||||||
// only use colors if its forced
|
// only use colours if its forced
|
||||||
colorsEnabled = forceColor
|
colorsEnabled = forceColor
|
||||||
writeInPlaceHandler := yqlib.NewWriteInPlaceHandler(args[0])
|
writeInPlaceHandler := yqlib.NewWriteInPlaceHandler(args[0])
|
||||||
out, err = writeInPlaceHandler.CreateTempFile()
|
out, err = writeInPlaceHandler.CreateTempFile()
|
||||||
|
|||||||
@ -184,7 +184,7 @@ yq -P -oy sample.json
|
|||||||
}
|
}
|
||||||
rootCmd.Flags().BoolVarP(&version, "version", "V", false, "Print version information and quit")
|
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().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().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.")
|
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.")
|
||||||
|
|
||||||
|
|||||||
@ -926,13 +926,13 @@ func TestSetupColors(t *testing.T) {
|
|||||||
expectColors bool
|
expectColors bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "force color enabled",
|
name: "force colour enabled",
|
||||||
forceColor: true,
|
forceColor: true,
|
||||||
forceNoColor: false,
|
forceNoColor: false,
|
||||||
expectColors: true,
|
expectColors: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "force no color enabled",
|
name: "force no colour enabled",
|
||||||
forceColor: false,
|
forceColor: false,
|
||||||
forceNoColor: true,
|
forceNoColor: true,
|
||||||
expectColors: false,
|
expectColors: false,
|
||||||
|
|||||||
@ -16,7 +16,7 @@ type iniDecoder struct {
|
|||||||
|
|
||||||
func NewINIDecoder() Decoder {
|
func NewINIDecoder() Decoder {
|
||||||
return &iniDecoder{
|
return &iniDecoder{
|
||||||
finished: false, // Initialize the flag as false
|
finished: false, // Initialise the flag as false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -78,7 +78,7 @@ func (dec *yamlDecoder) processReadStream(reader *bufio.Reader) (io.Reader, stri
|
|||||||
if separatorPrefixRe.MatchString(line) {
|
if separatorPrefixRe.MatchString(line) {
|
||||||
match := separatorPrefixRe.FindString(line)
|
match := separatorPrefixRe.FindString(line)
|
||||||
remainder := line[len(match):]
|
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
|
sepNewline := newline
|
||||||
if sepNewline == "" {
|
if sepNewline == "" {
|
||||||
sepNewline = "\n"
|
sepNewline = "\n"
|
||||||
|
|||||||
@ -66,8 +66,8 @@ func (he *hclEncoder) Encode(writer io.Writer, node *CandidateNode) error {
|
|||||||
finalOutput := he.injectComments(compactOutput, commentMap)
|
finalOutput := he.injectComments(compactOutput, commentMap)
|
||||||
|
|
||||||
if he.prefs.ColorsEnabled {
|
if he.prefs.ColorsEnabled {
|
||||||
colorized := he.colorizeHcl(finalOutput)
|
colourized := he.colorizeHcl(finalOutput)
|
||||||
_, err := writer.Write(colorized)
|
_, err := writer.Write(colourized)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,19 +173,19 @@ func (he *hclEncoder) injectComments(output []byte, commentMap map[string]string
|
|||||||
return []byte(result)
|
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 {
|
func (he *hclEncoder) colorizeHcl(input []byte) []byte {
|
||||||
hcl := string(input)
|
hcl := string(input)
|
||||||
result := strings.Builder{}
|
result := strings.Builder{}
|
||||||
|
|
||||||
// Create color functions for different token types
|
// Create colour functions for different token types
|
||||||
commentColor := color.New(color.FgHiBlack).SprintFunc()
|
commentColor := color.New(color.FgHiBlack).SprintFunc()
|
||||||
stringColor := color.New(color.FgGreen).SprintFunc()
|
stringColor := color.New(color.FgGreen).SprintFunc()
|
||||||
numberColor := color.New(color.FgHiMagenta).SprintFunc()
|
numberColor := color.New(color.FgHiMagenta).SprintFunc()
|
||||||
keyColor := color.New(color.FgCyan).SprintFunc()
|
keyColor := color.New(color.FgCyan).SprintFunc()
|
||||||
boolColor := color.New(color.FgHiMagenta).SprintFunc()
|
boolColor := color.New(color.FgHiMagenta).SprintFunc()
|
||||||
|
|
||||||
// Simple tokenization for HCL coloring
|
// Simple tokenization for HCL colouring
|
||||||
i := 0
|
i := 0
|
||||||
for i < len(hcl) {
|
for i < len(hcl) {
|
||||||
ch := hcl[i]
|
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 {
|
if handled, _ := he.encodeMappingChildrenAsBlocks(body, key, valueNode); handled {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// No labels detected, render as unlabeled block
|
// No labels detected, render as unlabelled block
|
||||||
block := body.AppendNewBlock(key, nil)
|
block := body.AppendNewBlock(key, nil)
|
||||||
if err := he.encodeNodeAttributes(block.Body(), valueNode); err == nil {
|
if err := he.encodeNodeAttributes(block.Body(), valueNode); err == nil {
|
||||||
return true
|
return true
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
var specDocument = `- &CENTER { x: 1, y: 2 }
|
var specDocument = `- &CENTRE { x: 1, y: 2 }
|
||||||
- &LEFT { x: 0, y: 2 }
|
- &LEFT { x: 0, y: 2 }
|
||||||
- &BIG { r: 10 }
|
- &BIG { r: 10 }
|
||||||
- &SMALL { r: 1 }
|
- &SMALL { r: 1 }
|
||||||
@ -139,7 +139,7 @@ var fixedAnchorOperatorScenarios = []expressionScenario{
|
|||||||
{
|
{
|
||||||
description: "FIXED: Merge multiple maps",
|
description: "FIXED: Merge multiple maps",
|
||||||
subdescription: "Taken from https://yaml.org/type/merge.html. Same values as legacy, but with the correct key order.",
|
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(.)",
|
expression: ".[4] | explode(.)",
|
||||||
expected: []string{"D0, P[4], (!!map)::x: 1\ny: 2\nr: 10\n"},
|
expected: []string{"D0, P[4], (!!map)::x: 1\ny: 2\nr: 10\n"},
|
||||||
},
|
},
|
||||||
@ -171,7 +171,7 @@ var fixedAnchorOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
skipDoc: true,
|
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",
|
subdescription: "b must not be exploded, as `r: *a` will become invalid",
|
||||||
document: `{b: &b {a: &a 42}, r: *a, c: {<<: *b}}`,
|
document: `{b: &b {a: &a 42}, r: *a, c: {<<: *b}}`,
|
||||||
expression: `explode(.c)`,
|
expression: `explode(.c)`,
|
||||||
@ -181,7 +181,7 @@ var fixedAnchorOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
skipDoc: true,
|
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",
|
subdescription: "b must not be exploded, as `r: *a` will become invalid",
|
||||||
document: `{b: &b {a: &a 42}, r: *a, c: {<<: [*b]}}`,
|
document: `{b: &b {a: &a 42}, r: *a, c: {<<: [*b]}}`,
|
||||||
expression: `explode(.c)`,
|
expression: `explode(.c)`,
|
||||||
@ -265,7 +265,7 @@ var badAnchorOperatorScenarios = []expressionScenario{
|
|||||||
{
|
{
|
||||||
description: "LEGACY: Merge multiple maps",
|
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.",
|
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(.)",
|
expression: ".[4] | explode(.)",
|
||||||
expected: []string{"D0, P[4], (!!map)::r: 10\nx: 1\ny: 2\n"},
|
expected: []string{"D0, P[4], (!!map)::r: 10\nx: 1\ny: 2\n"},
|
||||||
},
|
},
|
||||||
@ -297,7 +297,7 @@ var anchorOperatorScenarios = []expressionScenario{
|
|||||||
{
|
{
|
||||||
description: "Merge one map",
|
description: "Merge one map",
|
||||||
subdescription: "see https://yaml.org/type/merge.html",
|
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(.)",
|
expression: ".[4] | explode(.)",
|
||||||
expected: []string{expectedSpecResult},
|
expected: []string{expectedSpecResult},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -132,7 +132,7 @@ func (p *resultsPrinter) PrintResults(matchingNodes *list.List) error {
|
|||||||
tempBufferBytes := tempBuffer.Bytes()
|
tempBufferBytes := tempBuffer.Bytes()
|
||||||
if bytes.IndexByte(tempBufferBytes, 0) != -1 {
|
if bytes.IndexByte(tempBufferBytes, 0) != -1 {
|
||||||
return fmt.Errorf(
|
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 {
|
if _, err := writer.Write(tempBufferBytes); err != nil {
|
||||||
|
|||||||
@ -481,7 +481,7 @@ func TestPrinterNulSeparatorWithNullChar(t *testing.T) {
|
|||||||
t.Fatal("Expected error for null character in NUL separated output")
|
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 {
|
if err.Error() != expectedError {
|
||||||
t.Fatalf("Expected error '%s', got '%s'", expectedError, err.Error())
|
t.Fatalf("Expected error '%s', got '%s'", expectedError, err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,8 @@ cleanup
|
|||||||
cmlu
|
cmlu
|
||||||
colorise
|
colorise
|
||||||
colors
|
colors
|
||||||
coloring
|
Colors
|
||||||
|
colourize
|
||||||
compinit
|
compinit
|
||||||
coolioo
|
coolioo
|
||||||
coverprofile
|
coverprofile
|
||||||
@ -276,4 +277,4 @@ nohcl
|
|||||||
zclconf
|
zclconf
|
||||||
cty
|
cty
|
||||||
go-cty
|
go-cty
|
||||||
unlabeled
|
unlabelled
|
||||||
Loading…
Reference in New Issue
Block a user