lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] How to work around an annoying coding rules test false positive?


From: Vadim Zeitlin
Subject: [lmi] How to work around an annoying coding rules test false positive?
Date: Sun, 16 Jun 2019 18:08:08 +0200

 Hello,

 The md5sum-related PR adds a new unit test which checks that computing MD5
sums products the expected output, which is defined like this:

        std::string const md5sums_text =
        R"(#
        00112233445566778899aabbccddeeff  test1
        ffeeddccbbaa99887766554433221100 *test2
        )"
            ;

 Unfortunately this results in the following warning when running "make
check_concinnity":

File 'md5sum_test.cpp' should fuse '*' with type: 
'ffeeddccbbaa99887766554433221100 *2test'.

 The warning is understandable, but clearly not useful in this context. The
trouble is that I don't know what would be the best way to fix it. The 2
broad options are either working around it in the test itself or modifying
test_coding_rules.cpp to avoid it. It doesn't seem very appealing to make
the test code longer and/or less clear just because of this style test, so
I'd prefer to do the latter, but it's not really obvious how to do it
exactly because the line with test2 above does look like a variable
declaration (at least if you have the habit of naming your types with
random sequences of 32 hex digits).

 The real solution would be to not check the contents of strings, including
the raw string literals, but this would require major changes to the
test_coding_rules.cpp code. I'd actually like to make them because changing
the structure of this code to process files line by line and apply checks
on per-line basis would solve 2 long-standing and relatively serious
problems with it: first it should become much faster and second it would be
able to show the line number at which the problem appears, which is
something I, at least, sorely miss right now (I regularly run into messages
such as "has misindented label 'public:'" in a file with a dozen of
'public:' lines and finding the right one always take some time). But I'm
not really sure if you're eager to do this.

 And we don't want to modify test_coding_rules.cpp, the least unpleasant
change to the test code I see would be to add bogus extensions to the
test[12] files, e.g. use test1.txt and test2.bin for them.

 Would you prefer to go with the latter hack, consider changing
test_coding_rules.cpp (perhaps in some more minor way if you see it) or do
something else entirely?

 Thanks in advance,
VZ

Attachment: pgpNH2pZIBlO1.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]