I watched the youtube video on creating custom rules for code review. I have a disconnect, and am hoping that someone can explain.
In the exercise we're creating a rule to flag any DISPLAY UPON CONSOLE statements.
At one point we've to modify some java code to do this. And the instructions say "to mark all display upon console statements as violations, you need to get the Environment and see if its type is Console"
I'm lost at this point...what is this environment and what does it have to do with the statement?
If I want to create a custom rule that says each IF should be terminated by an END-IF, what would this environment business be?
This topic has been locked.
2 replies Latest Post - 2013-03-28T19:46:05Z by sumithar
Pinned topic Creating New Custom Rule
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2013-03-28T19:46:05Z at 2013-03-28T19:46:05Z by sumithar
jgellin 270001B3GU5 PostsACCEPTED ANSWER
Re: Creating New Custom Rule2013-03-26T21:38:32Z in response to sumitharIf you use the UPON clause in a DISPLAY statement the you must supply an environment or mnemonic. See the documentation:
When writing a rule, the Java you need to modify deals with the COBOL Application Model API, which is an API that models the COBOL language. If you take a look at the model object for DisplayStmt, you will see that there are methods for getting the environment, etc.
So the question about environment is specific to the DISPLAY statement.
As for IF and END-IF, you would want to create a rule that visits IfThenElseStmt objects, and uses the isEndIfUsed() method to determine whether END-IF is used. Here is a link to the API documentation for IfThenElseStmt:
Hope this helps,