func()

in rules/terraform_output_order.go [78:92]


func (r *TerraformOutputOrderRule) suggestedOrder(runner tflint.Runner, file *hcl.File, blocks hclsyntax.Blocks, firstOutputBlockRange *hcl.Range) error {
	sort.Slice(blocks, func(i, j int) bool {
		return blocks[i].Labels[0] < blocks[j].Labels[0]
	})
	var sortedOutputHclTxts []string
	for _, b := range blocks {
		sortedOutputHclTxts = append(sortedOutputHclTxts, string(b.Range().SliceBytes(file.Bytes)))
	}
	sortedOutputHclBytes := hclwrite.Format([]byte(strings.Join(sortedOutputHclTxts, "\n\n")))
	return runner.EmitIssue(
		r,
		fmt.Sprintf("Recommended output order:\n%s", sortedOutputHclBytes),
		*firstOutputBlockRange,
	)
}