@abaplint/core
Version:
abaplint - Core API
78 lines • 3.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RFCErrorHandling = exports.RFCErrorHandlingConf = void 0;
const issue_1 = require("../issue");
const _abap_rule_1 = require("./_abap_rule");
const _basic_rule_config_1 = require("./_basic_rule_config");
const Statements = require("../abap/2_statements/statements");
const Expressions = require("../abap/2_statements/expressions");
const _irule_1 = require("./_irule");
class RFCErrorHandlingConf extends _basic_rule_config_1.BasicRuleConfig {
}
exports.RFCErrorHandlingConf = RFCErrorHandlingConf;
class RFCErrorHandling extends _abap_rule_1.ABAPRule {
constructor() {
super(...arguments);
this.conf = new RFCErrorHandlingConf();
}
getMetadata() {
return {
key: "rfc_error_handling",
title: "RFC error handling",
tags: [_irule_1.RuleTag.SingleFile],
shortDescription: `Checks that exceptions 'system_failure' and 'communication_failure' are handled in RFC calls`,
extendedInformation: `https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abenrfc_exception.htm`,
badExample: `CALL FUNCTION 'ZRFC'
DESTINATION lv_rfc.`,
goodExample: `CALL FUNCTION 'ZRFC'
DESTINATION lv_rfc
EXCEPTIONS
system_failure = 1 MESSAGE msg
communication_failure = 2 MESSAGE msg
resource_failure = 3
OTHERS = 4.`,
};
}
getMessage() {
return "RFC error handling: At least one unhandled exception from SYSTEM_FAILURE, COMMUNICATION_FAILURE, RESOURCE_FAILURE";
}
getConfig() {
return this.conf;
}
setConfig(conf) {
this.conf = conf;
}
runParsed(file) {
const output = [];
for (const stat of file.getStatements()) {
const token = stat.getFirstToken();
if (!(stat.get() instanceof Statements.CallFunction)) {
continue;
}
if (!stat.findFirstExpression(Expressions.Destination)) {
continue;
}
const list = stat.findFirstExpression(Expressions.ParameterListExceptions);
if (list === undefined) {
const issue = issue_1.Issue.atToken(file, token, this.getMessage(), this.getMetadata().key, this.conf.severity);
output.push(issue);
continue;
}
const parameters = list.findAllExpressions(Expressions.ParameterName);
const names = [];
for (const par of parameters) {
names.push(par.getFirstToken().getStr().toUpperCase());
}
if (names.indexOf("SYSTEM_FAILURE") < 0
|| names.indexOf("COMMUNICATION_FAILURE") < 0
|| names.indexOf("RESOURCE_FAILURE") < 0) {
const issue = issue_1.Issue.atToken(file, token, this.getMessage(), this.getMetadata().key, this.conf.severity);
output.push(issue);
continue;
}
}
return output;
}
}
exports.RFCErrorHandling = RFCErrorHandling;
//# sourceMappingURL=rfc_error_handling.js.map