All files / src/rules form_tables_obsolete.ts

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

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 561x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 11393x 11393x 11393x 11393x 11393x 34024x 34024x 34024x 34024x 34024x 34024x 34024x 34024x 11393x 11393x 2x 2x 11393x 11393x 10896x 10896x 11393x 11393x 233x 233x 11393x 11393x 246x 246x 246x 246x 63x 63x 183x 246x 2x 2x 2x 2x 183x 183x 183x 11393x 11393x
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_751_index_htm/7.51/en-US/abapform_tables.htm`,
      tags: [RuleTag.SingleFile],
    };
  }
 
  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;
  }
 
}