Open AHaumer opened 5 years ago
I have recently implemented an initial support of Modelica in PMD static code analyzer. For now, it is experimental (but already merged into master
) and has only demo rules, but:
PMD has language-agnostic "XPath rule" built-in, so you can write some XPath queries that mark matched nodes as violations - without any Java coding at all, just external XMLs with rules
one of these demo rules is
//ClassSpecifier/*[SimpleName[1]/@Image != SimpleName[last()]/@Image]
it basically checks for model Name end OtherName;
mistakes
It is still not published as part of the released Binary Distribution (the next release is planned at the end of January), so manual build of master
branch is required. Also, it is still experimental, so some API still may change.
Last but not least: sometimes Modelica compilers crash with Internal compiler error
or something like this. There exist many different tools to minimize source code that crash the compiler. I have implemented yet another as a tool for PMD that should support any "fully-featured" (that is, not CPD-only) PMD language (including Modelica). Its maintainers placed it to separate repo pmd/pmd-scm as another experimental feature.
PS: On "coding and formattig": generally, PMD cannot check formatting, since it works with AST. On the other hand, it can trivially check some assertions about coding style such as "every package name starts with p
letter".
@atrosinenko This is very good news and I will give PMD a try once the new version is available. (I already watched the PMD releases, so I will get notified when it is released.)
I also addressed the 180-line copy&paste by #3296. Thanks again for reporting.
I have published a preview build in my fork. But it is quite simple to build it on Linux (at least, on a fresh Ubuntu) provided you have OpenJDK installed: you just have to clone pmd/pmd and run ./mvnw clean verify
- you will get pmd-bin-<...>.zip
in the pmd-dist/target
directory.
It may be worth testing it before the official release because now it has very few rules (basically, these are more demos) and it would be great if some actual rules be implemented (or just suggested) by real Modelica developers.
Modelica support for PMD was released as part of version 6.21.0. Meanwhile, it may be worth adding to https://modelica.org/tools (with the experimantal
note).
Modelica support for PMD was released as part of version 6.21.0. Meanwhile, it may be worth adding to https://modelica.org/tools (with the
experimantal
note).
@sjoelund Can you please add PMD to https://modelica.org/tools as suggested. Thanks.
Pinging @adeas31 who does most of the webmaster tasks
Pinging @adeas31 who does most of the webmaster tasks
Did not happen so far. See also https://github.com/modelica/BackOffice/issues/35.
Added PMD to the tools page.
In a discussion the idea came up to have tool independent checker for coding and formatting. I know that some parts of such a thing exist in some tools, but it would be nice to have a tool independent solution (like the regression check!). Let the tool run through all models of a library, getting a list of things to improve, like: parameter description missing, icon color is wrong, name in icon layer has wrong size and color and many more - fortunately we have guidelines in the UsersGuide.