NaturalONE is an Eclipse-based IDE for the language NATURAL by Software AG. It contains an utility called NATstyle which can check for coding standards in your programs. You can use this utility to define and check the coding standards.
Usage in NaturalONE
Also see Eclipse/NaturalONE help topic Checking Natural Code with NATstyle.
NATstyle is an Eclipse plugin inside NaturalONE. In my edition it is in
C:\ Natural-CE\ Designer\ eclipse\ plugins\ com.softwareag.naturalone.natural.natstyle_8.3.5.0000-0242.
Invoking NATstyle from Outside Eclipse
See my detailed article Using NATstyle from the commandline for more information.
Help output from invoking
Usage: com.softwareag.naturalone.natural.natstyle.NATstyle [-options] where options include: -projectpath <directory> Specify where to find the Natural project. -rootfolder Library root folder support enabled. -c <file> Specify the configuration file. -o <file> Specify the output file. -sourcefiles <srcList> Specify list of source files to be loaded. separated with ; -libraries <libList> Specify list of libraries to be loaded. separated with ; -exclude <libList> Specify a list of libraries to exclude. separated with ; -p <directory> Specify where to find additional packages. -help Display command line options and exit. It is important that the following classes can be found in your class path: com.softwareag.naturalone.natural.auxiliary com.softwareag.naturalone.natural.common com.softwareag.naturalone.natural.parser
To have all needed classes available you need the following entries on the Classpath
There might be other classes needed by components of NATstyle, the following Jars seem not to be needed:
run_natstyle_direct.bat for an example
how to set the Classpath when NaturalONE is installed. Copying the needed folders
and Jars to another machine works as well.
Invoking NATstyle from Ant
NaturalONE supports Ant for some automation tasks. There
is no specific NATstyle Ant task, but calling it from Ant is straight forward. See
ant_NatStyle.xml for an example how to do that. A new
JVM needs to be forked because NATstyle calls
System.exit at the end. All
parameters are the same as for the command-line invocation.
See my detailed article Creating your own NATstyle rules for more information.
In the preferences the settings for NATstyle can be configured. Custom
configurations are saved as
NATstyle.xml and used when you run NATstyle
from the popup menu. The existing rules are described in NaturalONE help topic
Overview of NATstyle Rules, Error Messages and Solutions. My version
8.3 has 42 rules.
Some rules like Source/Regular expression for single source lines only allows
a single regular expression. Using groups is a way to fix that. Also the element
can be duplicated in the
NATstyle.xml and executed from command line. See
sameRuleTwice.xml and natstyle_sameRuleTwice.bat
Defining your own rules
There is no way to create new rules for NATstyle. All rules' classes are
defined inside the NATstyle plugin. The configuration contains a
attribute, but that is just the short name, e.g.
class lives in the package
source is the group of the rules defined in the
<checks> element. (The
reads the configuration from
NATstyle.xml. It gets passed in the base
package and determines the sub package for the rule depending on its type.
NatStyle main uses
so all rules must be defined inside this name space.) Such rules cannot be configured
in NaturalONE, but probably used when added to
Parser rules extend
NATstyleCheckerParserImpl. The parser traverses
the AST of the NATURAL code. This is done using a visitor, the
The visitor is called for each node in the AST tree. (This is similar to PMD checks.)
NATstyle writes an XML reports of all found files and their rule violations.
<NATstyle> <file> <error /> ... </file> ... </NATstyle>
See the provided sample result which comes with NATstyle.
Using the provided
NATstyleSimple.xsl this XML can be transformed in a human-readable
NATstyleSimple.html. XSLT transformation is
part of Ant and converting the XML to HTML is easy. See
for an example build script.
See my detailed article NATstyle Custom Reports for more information how to convert the result XML to a suitable report, e.g. PMD's format.
New BSD License, see
license.txt in repository.
All NATURAL and NaturalONE content is Copyright (c) 2009-2015 Software AG, Darmstadt, Germany.