Rules File Example for Rule Based Analysis

Following is an example of how a file that contains rules for Rule Based Analysis must look like.

##for comments, use # at the beginning of the line. Lines with comments are ignored
##<number>: positive integer
##<identifier>: alphanumeric_text_with_0_spaces
##<path>: absolute path to a file on disk
##<class>: qualified class name for a rule
##<text>: any string of characters on one line. Line continuation (single backslash at the end of line) can be used for multiple lines
##{key}: the value of the key as found in the file.
##[] in key names means optional


##includes are optional
#include.id = <number : larger than 0>
#include.key = <identifier>
#include.path = <path : an include file>

##input definition
##inputs are optional

#<input.id>.input.key = <identifier>
#<input.id>.input.name = <text : param name in gui>
#<input.id>.input.query = <path : to query file>
#<input.id>.input.firstColumnType = <numeric|string>

1.input.key = CobolPrograms
1.input.name = Cobol Programs
1.input.query = C:\\Rules\\CobolPrograms.txt
1.input.firstColumnType = numeric

##param definition
##parameters are optional
##if .query exists, .pattern is not used
##if .pattern not exists, default is unbound text

#<param.id>.param.key = <identifier>
#<param.id>.param.name = <text : param name in gui>
#<param.id>.param.default.value = <value>
#<param.id>.param.[pattern] = <pattern>
#<param.id>.param.[length] = <number>
#<param.id>.param.[value.lessThan] = <number>
#<param.id>.param.[value.greaterThan] = <number>
#<param.id>.param.[prefix] = <text : prefix for the chosen value>
#<param.id>.param.[suffix] = <text : suffix for the chosen value>

1.param.key = MaxINITIALIZESize
1.param.name = Max INITIALIZE record size
1.param.default.value = 3000

##group definition
##groups are optional

#<group.id>.group.name = <text : group name in gui>
#<group.id>.group.[parent] = [(0|{include.key}):]{group.id}
#<group.id>.group.[description] = <text : group description in gui>


##rule definition
##at least one of .class or .query must exist
##.query and .selectiveQuery can be used together for efficiency reasons. 
##     Only one is executed depending on user selection

#<rule.id>.rule.name = <identifier: rule name>
#<rule.id>.rule.[sourceBased] = true|false (default true)
#<rule.id>.rule.[weight] = <number> (default 1)
#<rule.id>.rule.[query] = <path : to query file> (default none)
#<rule.id>.rule.[selectiveQuery] = <path : to selective query file> (default none)
#<rule.id>.rule.[class] = <class> (default none)
#<rule.id>.rule.[groups] = [(0|{include.key}):]{group.id}[, [(0|{include.key}):]{group.id}]* (default none)
#<rule.id>.rule.[description] = <text: rule description> (default none)
#<rule.id>.rule.[params] = [(0|{include.key}):]{param.key}[, [(0|{include.key}):]{param.key}]* (default none)
#<rule.id>.rule.[inputs] = [(0|{include.key}):]{param.key}[, [(0|{include.key}):]{param.key}]* (default none)

# Groups

10.group.name=Performance Rules
10.group.description=These rules look up potential performance issues in the code
 
100.rule.groups=10
100.rule.name=INITIALIZE of large records
100.rule.description=INITIALIZE of very large records consumes a lot of CPU, consider the alternative of using a direct MOVE
100.rule.sourceBased=true
100.rule.query=C:\\Rules\\InitializeRule.txt
100.rule.weight=1
100.rule.inputs=CobolPrograms
100.rule.params=MaxINITIALIZESize

Following are two examples of how the files that contain SQL queries must look like.

The query in the following example brings data for the rule "INITIALIZE of large records" from previous the example.

SQL Query Example:

SELECT DISTINCT TOP (100) PERCENT dbo.Programs.ProgramID, dbo.Programs.ProgramName, dbo.Paths.PathStr, 
                           dbo.OccurrencesStmt.StartRow, ISNULL
                          ((SELECT     0 AS Expr1
                              WHERE     (dbo.OccurrencesStmt.SourceType < 4)), - 1) AS IsCopy
FROM         dbo.StatementReference INNER JOIN
                      dbo.OccurrencesStmt ON dbo.StatementReference.OccurID = dbo.OccurrencesStmt.OccurID INNER JOIN
                      dbo.Programs ON dbo.OccurrencesStmt.ProgID = dbo.Programs.ProgramID INNER JOIN
                      dbo.Variables ON dbo.StatementReference.ResourceID = dbo.Variables.VarID INNER JOIN
                      dbo.Paths ON dbo.OccurrencesStmt.PathID = dbo.Paths.PathID
WHERE     (dbo.StatementReference.StatementType = 24) AND (dbo.StatementReference.ResourceType = 4) AND 
                      (dbo.Variables.VarSize > {MaxINITIALIZESize}) AND 
                      (dbo.Programs.ProgramID in ({CobolPrograms:-1}))
ORDER BY dbo.Programs.ProgramName, dbo.Paths.PathStr, dbo.OccurrencesStmt.StartRow

Following is an example of an input query for AllPrograms, as it is defined in the .properties file.

Input query for AllPrograms Example.

SELECT     TOP (100) PERCENT ProgramID, ProgramName
FROM         dbo.Programs
WHERE     (OccurID > 0) AND (ProgramTypeID = 1)
ORDER BY ProgramName
Following is an example of the sample files to be used to test the Rule Based Analysis in the Analyze Client.
  1. Create a text file by copying and pasting the content of the above first example, and name it RuleBasedAnalsis.properties.
  2. Create a text file by copying and pasting the content of the above second example, and name it InitializeRule.txt.
  3. Create a text file by copying and pasting the content of the above third example, and name it CobolPrograms.txt.
  4. Create a folder C:\Rules, and put the above three files to this folder.
  5. Open the Eclipse, and click Window > Preferences > Application Discovery > Local settings > Rules Based Analysis. Check the Overwrite global configuration, and enter for the Rules: C:\Rules\RuleBasedAnalsis.properties. Then, select your File encoding to be UTF-8 or else, press Apply, and close the page.
  6. In the Analyze Client, select a project, and run Mainframe Reports > Miscellaneous Reports > Rule Based Analysis. The wizard will be opened, and one rule "INITIALIZE of large records." can be displayed. Select the rule, and you can change the parameter values. Then, move it to the Selected rules box, press Next, and select some or all of the COBOL programs. Finally, press Finish, and the report will be created.