Topic
  • 2 replies
  • Latest Post - ‏2013-03-28T19:46:05Z by sumithar
sumithar
sumithar
115 Posts

Pinned topic Creating New Custom Rule

‏2013-03-26T20:55:39Z |
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?

Thanks!
Updated on 2013-03-28T19:46:05Z at 2013-03-28T19:46:05Z by sumithar
  • jgellin
    jgellin
    11 Posts
    ACCEPTED ANSWER

    Re: Creating New Custom Rule

    ‏2013-03-26T21:38:32Z  
    If you use the UPON clause in a DISPLAY statement the you must supply an environment or mnemonic. See the documentation:
    http://pic.dhe.ibm.com/infocenter/pdthelp/v1r1/topic/com.ibm.entcobol.doc_4.2/PGandLR/ref/rlpsdisp.htm

    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.
    http://pic.dhe.ibm.com/infocenter/ratdevz/v8r5/topic/com.ibm.rsar.analysis.codereview.cobol.doc/javadoc/cobmodelapi/com/ibm/etools/cobol/application/model/cobol/DisplayStmt.html

    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:
    http://pic.dhe.ibm.com/infocenter/ratdevz/v8r5/topic/com.ibm.rsar.analysis.codereview.cobol.doc/javadoc/cobmodelapi/com/ibm/etools/cobol/application/model/cobol/IfThenElseStmt.html

    Hope this helps,
    Jon
  • jgellin
    jgellin
    11 Posts

    Re: Creating New Custom Rule

    ‏2013-03-26T21:38:32Z  
    If you use the UPON clause in a DISPLAY statement the you must supply an environment or mnemonic. See the documentation:
    http://pic.dhe.ibm.com/infocenter/pdthelp/v1r1/topic/com.ibm.entcobol.doc_4.2/PGandLR/ref/rlpsdisp.htm

    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.
    http://pic.dhe.ibm.com/infocenter/ratdevz/v8r5/topic/com.ibm.rsar.analysis.codereview.cobol.doc/javadoc/cobmodelapi/com/ibm/etools/cobol/application/model/cobol/DisplayStmt.html

    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:
    http://pic.dhe.ibm.com/infocenter/ratdevz/v8r5/topic/com.ibm.rsar.analysis.codereview.cobol.doc/javadoc/cobmodelapi/com/ibm/etools/cobol/application/model/cobol/IfThenElseStmt.html

    Hope this helps,
    Jon
  • sumithar
    sumithar
    115 Posts

    Re: Creating New Custom Rule

    ‏2013-03-28T19:46:05Z  
    • jgellin
    • ‏2013-03-26T21:38:32Z
    If you use the UPON clause in a DISPLAY statement the you must supply an environment or mnemonic. See the documentation:
    http://pic.dhe.ibm.com/infocenter/pdthelp/v1r1/topic/com.ibm.entcobol.doc_4.2/PGandLR/ref/rlpsdisp.htm

    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.
    http://pic.dhe.ibm.com/infocenter/ratdevz/v8r5/topic/com.ibm.rsar.analysis.codereview.cobol.doc/javadoc/cobmodelapi/com/ibm/etools/cobol/application/model/cobol/DisplayStmt.html

    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:
    http://pic.dhe.ibm.com/infocenter/ratdevz/v8r5/topic/com.ibm.rsar.analysis.codereview.cobol.doc/javadoc/cobmodelapi/com/ibm/etools/cobol/application/model/cobol/IfThenElseStmt.html

    Hope this helps,
    Jon
    Hi Jon
    thanks for a detailed reply. this looks a bit more involved than I initially thought. I will take a look at those APIs and proceed from there.
    Regards