[libvirt] [PATCH] syntax-check: Add sc_prohibit_space_in_label rule

This guards against code such as cleanup : which is happily accepted by the compiler but does not conform to our style guidelines. --- cfg.mk | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cfg.mk b/cfg.mk index a9bba38..8462051 100644 --- a/cfg.mk +++ b/cfg.mk @@ -919,6 +919,12 @@ sc_require_space_before_label: halt="Top-level labels should be indented by one space" \ $(_sc_search_regexp) +sc_prohibit_space_in_label: + @prohibit='^[_a-zA-Z0-9]+ +:$$' \ + in_vc_files='\.[ch]$$' \ + halt="There should be no space between label name and colon" \ + $(_sc_search_regexp) + # Doesn't catch all cases of mismatched braces across if-else, but it helps sc_require_if_else_matching_braces: @prohibit='( else( if .*\))? {|} else( if .*\))?$$)' \ -- 2.4.3

On Mon, Nov 02, 2015 at 10:34:35 +0100, Andrea Bolognani wrote:
This guards against code such as
cleanup :
which is happily accepted by the compiler but does not conform to our style guidelines. --- cfg.mk | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/cfg.mk b/cfg.mk index a9bba38..8462051 100644 --- a/cfg.mk +++ b/cfg.mk @@ -919,6 +919,12 @@ sc_require_space_before_label: halt="Top-level labels should be indented by one space" \ $(_sc_search_regexp)
+sc_prohibit_space_in_label: + @prohibit='^[_a-zA-Z0-9]+ +:$$' \
Our labels enforce at least one space before a label so I don't think this will work. If you will be adding a multi-space match, please make sure that "case" is not matched in that case. Peter

On Mon, 2015-11-02 at 10:49 +0100, Peter Krempa wrote:
On Mon, Nov 02, 2015 at 10:34:35 +0100, Andrea Bolognani wrote:
This guards against code such as
cleanup :
which is happily accepted by the compiler but does not conform to our style guidelines. --- cfg.mk | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/cfg.mk b/cfg.mk index a9bba38..8462051 100644 --- a/cfg.mk +++ b/cfg.mk @@ -919,6 +919,12 @@ sc_require_space_before_label: halt="Top-level labels should be indented by one space" \ $(_sc_search_regexp)
+sc_prohibit_space_in_label: + @prohibit='^[_a-zA-Z0-9]+ +:$$' \
Our labels enforce at least one space before a label so I don't think this will work.
You are of course absolutely right. I was trying to catch the case where two mistakes are present in the same line, eg. myfancylabel : but my implementation was flawed. v2 on its way.
If you will be adding a multi-space match, please make sure that "case" is not matched in that case.
That shouldn't happen as there will always be some other token between the whitespace after 'case' and the colon, right? Cheers. -- Andrea Bolognani Software Engineer - Virtualization Team
participants (2)
-
Andrea Bolognani
-
Peter Krempa