[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 14/28] qapi: Enforce type naming rules
From: |
Markus Armbruster |
Subject: |
Re: [PATCH 14/28] qapi: Enforce type naming rules |
Date: |
Tue, 23 Mar 2021 17:27:43 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
Eric Blake <eblake@redhat.com> writes:
> On 3/23/21 4:40 AM, Markus Armbruster wrote:
>> Type names should be CamelCase. Enforce this. The only offenders are
>> in tests/. Fix them. Add test type-case to cover the new error.
>>
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>
>> +++ b/scripts/qapi/expr.py
>> @@ -61,7 +61,8 @@ def check_name_lower(name, info, source,
>>
>> def check_name_camel(name, info, source):
>> stem = check_name_str(name, info, source)
>> - # TODO reject '[_-]' in stem, require CamelCase
>> + if not re.match(r'[A-Z]+[A-Za-z0-9]*[a-z][A-Za-z0-9]*$', stem):
>
> Requires one or more leading capital, and at least one lowercase. This
> permits oddballs like PCIELinkSpeed in common.json that are eventually
> camel case but with a rather long all-caps start.
>
> As written, the + isn't necessary, you'd match the same set of strings
> with it omitted. But leaving it doesn't hurt.
I'll drop it.
>> +++ b/tests/qapi-schema/doc-bad-union-member.json
>> @@ -11,9 +11,9 @@
>> 'data': { 'nothing': 'Empty' } }
>>
>> { 'struct': 'Base',
>> - 'data': { 'type': 'T' } }
>> + 'data': { 'type': 'FrobType' } }
>
> No single-character type names is fallout from the tighter rules, but is
> fine with me.
I was unsure whether to complicate the regexp slightly so
single-character type names keep working. Then I decided against it.
>> +++ b/tests/qapi-schema/type-case.json
>> @@ -0,0 +1,2 @@
>> +# Type names should use CamelCase
>> +{ 'struct': 'not-a-camel' }
>
> You should probably include a 'data':{...} here, to ensure that we
> aren't rejecting this for missing data (yes, the .err file does test our
> actual error message, but no reason to not be otherwise compliant to
> what we normally expect).
Yes, that's prudent.
> Such a tweak is minor enough that I'm fine with
>
> Reviewed-by: Eric Blake <eblake@redhat.com>
Thanks!
- Re: [PATCH 03/28] tests/qapi-schema: Rework comments on longhand member definitions, (continued)
Re: [PATCH 03/28] tests/qapi-schema: Rework comments on longhand member definitions, Eric Blake, 2021/03/23
Re: [PATCH 03/28] tests/qapi-schema: Rework comments on longhand member definitions, John Snow, 2021/03/23
[PATCH 02/28] tests/qapi-schema: Drop redundant flat-union-inline test, Markus Armbruster, 2021/03/23
[PATCH 09/28] qapi: Lift enum-specific code out of check_name_str(), Markus Armbruster, 2021/03/23
[PATCH 14/28] qapi: Enforce type naming rules, Markus Armbruster, 2021/03/23
[PATCH 20/28] qapi/pragma: Streamline comments on member-name-exceptions, Markus Armbruster, 2021/03/23
[PATCH 06/28] tests/qapi-schema: Tweak to demonstrate buggy member name check, Markus Armbruster, 2021/03/23
[PATCH 05/28] tests/qapi-schema: Drop TODO comment on simple unions, Markus Armbruster, 2021/03/23
[PATCH 04/28] tests/qapi-schema: Belatedly update comment on alternate clash, Markus Armbruster, 2021/03/23