Static Analysis Naming Warnings

  • DavidCozens

    DavidCozens - 2016-03-28

    I am in the process of cleaning up an IO driver to make it available in the codesys store. As part of this process all libraries are supposed to comply with a pre-defined set of static analysis rules including naming conventions.
    There are standard interfaces that do not comply with the naming conventions and so give static analysis failures. e.g. from IoDrvUpdateConfiguration I get:

    NC0015: Invalid variable name 'nCount'. Expected prefix 'di'

    Looking at the documentation for static analysis I find that I can suppress this warning using

    {attribute 'naming' := 'omit'}

    This does suppress the warning, however I now get a compiler warning

    C0351: The attribute naming is unknown and will be ignored by the compiler.

    I have tried disabling the compiler warning using

    {warning disable C0351}

    however this has no effect.
    Please advise how I can write code that fulfils this standard interface, satisfies your standard static analysis rules, and does not throw compiler warnings?
    To be honest I would prefer it if static analysis didn't complain at all about function blocks implementing an interface. It is a waste of time going and adding suppressions in the implementing function block. Raising the static analysis warning where the interface is defined makes sense, but not where it is implemented. Perhaps a JIRA entry could be raised to make this improvement. This may seem a trivial request, static analysis can be a great tool to improve readability and quality, but not if it wastes time on code that the developer cannot fix.

  • timvh

    timvh - 2016-04-26

    Hi David,

    I had a similar problem.
    The attribute "naming" should be recognized, but isn't. This is a bug in 3.5 SP8 and hasn't been fixed yet.

    The jira issue is CDS-47159.


Log in to post a comment.