Menu

Fixing a XML schema for Cppcheck's analysis results output

2018-10-19
2018-10-20
  • Markus Elfring

    Markus Elfring - 2018-10-19

    A code review increased the software development attention for the comparison of key attributes in error information which is described to some degree by a XML schema.
    I find this data format specification questionable after the discussed details.
    Should the attribute “file0” become mandatory?

    @@ -41,7 +41,5 @@ adjustment possibility
                                <element name="location">
    -                               <optional>
    -                                   <attribute name="file0">
    -                                       <data type="string"/>
    -                                   </attribute>
    -                               </optional>
    +                               <attribute name="file0">
    +                                   <data type="string"/>
    +                               </attribute>
                                    <attribute name="file">
    

    Will further improvements be needed for the involved data types?

     
    • Markus Elfring

      Markus Elfring - 2018-10-20

      The Cppcheck software can offer data format descriptions for different files.

      • Programming interface information (configurations)
      • List of available checks (option “--errorlist”)
      • Output of analysis results (option “--xml”)

      Will these areas be improved any further?

       
  • Daniel Marjamäki

    It is optional by intention. we can avoid writing redundant information.

     
    • Markus Elfring

      Markus Elfring - 2018-10-20
      • Why do you find such information redundant?
      • Is a start point for a data analysis needed?
       
  • Daniel Marjamäki

    file1.cpp

    #include "file1.h"
    void f(int x)
    {
    }
    

    file1.h

    void f(int data);
    

    Cppcheck will write:

            <error id="funcArgNamesDifferent" severity="style" msg="Function &apos;f&apos; argument 1 names different: declaration &apos;data&apos; definition &apos;x&apos;." verbose="Function &apos;f&apos; argument 1 names different: declaration &apos;data&apos; definition &apos;x&apos;." cwe="628" inconclusive="true">
                <location file="file1.cpp" line="2"/>
                <location file0="file1.cpp" file="file1.h" line="1"/>
                <symbol>f</symbol>
            </error>
    

    We only need to write file0="file1.cpp" once in one <location>. I see no reason to write it on every location because for a single <error> it's always the same.</error></location>

     
    • Markus Elfring

      Markus Elfring - 2018-10-20

      I see no reason to write it on every location because for a single <error> it's always the same.

      I suggest to reconsider your data model design once more here.
      Would you like to introduce a case distinction?

      • If you know that only a single file was analysed (so that also a single error type was detected for this example), you can avoid a bit of data repetition.
      • But the provided data structures need to be consistent for the safe general usage.
       
  • Daniel Marjamäki

    I don't want to waste more time on this debate.

     
    • Markus Elfring

      Markus Elfring - 2018-10-20

      Why do you think that anything would be wasted by this software design clarification?

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.