CodingGuidelines: instruct to name arrays in singular

Arrays should be named in the singular form, ensuring that when accessing an element within an array (e.g. dog[0]) it's clear that we're referring to an element instead of a collection. Add a new rule to CodingGuidelines asking for arrays to be named in singular instead of plural. Helped-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Lucas Seiki Oshiro committed Feb 25, 2026 at 13:32 UTC c63e64e04d43ebdc04204a052858c4801c018e1e
1 file changed +13
Documentation/CodingGuidelines
+13
@@ -656,6 +656,19 @@ For C programs:
656 unsigned other_field:1;
657 unsigned field_with_longer_name:1;
658
659 + - Array names should be named in the singular form if the individual items are
660 + subject of use. E.g.:
661 +
662 + char *dog[] = ...;
663 + walk_dog(dog[0]);
664 + walk_dog(dog[1]);
665 +
666 + Cases where the array is employed as a whole rather than as its unit parts,
667 + the plural forms is preferable. E.g:
668 +
669 + char *dogs[] = ...;
670 + walk_all_dogs(dogs);
671 +
672 For Perl programs:
673
674 - Most of the C guidelines above apply.