All files / src/rules form_tables_obsolete.ts

100% Statements 60/60
100% Branches 11/11
100% Functions 6/6
100% Lines 60/60

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 611x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 11452x 11452x 11452x 11452x 11452x 34215x 34215x 34215x 34215x 34215x 34215x 34215x 34215x 34215x 34215x 34215x 34215x 11452x 11452x 2x 2x 11452x 11452x 10927x 10927x 11452x 11452x 247x 247x 11452x 11452x 270x 270x 270x 270x 63x 63x 207x 270x 2x 2x 2x 2x 207x 207x 207x 11452x 11452x  
import {Issue} from "../issue";
import {Class} from "../objects";
import {BasicRuleConfig} from "./_basic_rule_config";
import {ABAPRule} from "./_abap_rule";
import * as Expressions from "../abap/2_statements/expressions";
import {ABAPObject} from "../objects/_abap_object";
import {IRuleMetadata, RuleTag} from "./_irule";
import {ABAPFile} from "../abap/abap_file";
 
export class FormTablesObsoleteConf extends BasicRuleConfig {
}
 
export class FormTablesObsolete extends ABAPRule {
 
  private conf = new FormTablesObsoleteConf();
 
  public getMetadata(): IRuleMetadata {
    return {
      key: "form_tables_obsolete",
      title: "TABLES parameters are obsolete",
      shortDescription: `Checks for TABLES parameters in forms.`,
      extendedInformation: `https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abapform_tables.html`,
      tags: [RuleTag.SingleFile],
      badExample: `FORM update_items TABLES items.
ENDFORM.`,
      goodExample: `FORM update_items CHANGING items TYPE ty_items.
ENDFORM.`,
    };
  }
 
  private getMessage(): string {
    return "FORM TABLES parameters are obsolete";
  }
 
  public getConfig() {
    return this.conf;
  }
 
  public setConfig(conf: FormTablesObsoleteConf) {
    this.conf = conf;
  }
 
  public runParsed(file: ABAPFile, obj: ABAPObject) {
    const ret: Issue[] = [];
 
    const stru = file.getStructure();
    if (obj instanceof Class || stru === undefined) {
      return ret;
    }
 
    for (const form of stru.findAllExpressions(Expressions.FormTables)) {
      const token = form.getFirstToken();
      const issue = Issue.atToken(file, token, this.getMessage(), this.getMetadata().key, this.conf.severity);
      ret.push(issue);
    }
 
    return ret;
  }
 
}