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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 11514x 11514x 11514x 11514x 34383x 34383x 34383x 34383x 34383x 34383x 34383x 34383x 11514x 11514x 237x 237x 11514x 11514x 11014x 11014x 11514x 11514x 235x 235x 11514x 11514x 307x 307x 307x 139x 139x 168x 168x 307x 162x 162x 6x 307x 2x 5x 1x 1x 1x 5x 2x 2x 2x 6x 6x 6x 11514x 11514x 2x 2x 2x 5x 5x 2x 2x 3x 5x 4x 4x 3x 3x 1x 1x 1x 1x 3x 2x 2x 2x 11514x 11514x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 11514x 11514x | import {Issue} from "../issue";
import {IFile} from "../files/_ifile";
import {DynproField, DynproHeader} from "../objects/_dynpros";
import {IObject} from "../objects/_iobject";
import {IRule, IRuleMetadata, RuleTag} from "./_irule";
import {BasicRuleConfig} from "./_basic_rule_config";
import {IRegistry} from "../_iregistry";
import {Program} from "../objects";
import {Position} from "../position";
export class DynproChecksConf extends BasicRuleConfig {
}
export class DynproChecks implements IRule {
private conf = new DynproChecksConf();
public getMetadata(): IRuleMetadata {
return {
key: "dynpro_checks",
title: "Dynpro Checks",
shortDescription: `Various Dynpro checks`,
extendedInformation: `* Check length of PUSH elements less than 132\n* Check for overlapping screen elements`,
tags: [RuleTag.Syntax],
};
}
public initialize(_reg: IRegistry) {
return this;
}
public getConfig(): DynproChecksConf {
return this.conf;
}
public setConfig(conf: DynproChecksConf) {
this.conf = conf;
}
public run(obj: IObject): Issue[] {
const ret: Issue[] = [];
if (!(obj instanceof Program)) {
return [];
}
const file = obj.getXMLFile();
if (file === undefined) {
return [];
}
for (const dynpro of obj.getDynpros()) {
for (const field of dynpro.fields) {
if (field.type === "PUSH" && field.length > 132) {
const message = `Screen ${dynpro.number}, field ${field.name} LENGTH longer than 132`;
ret.push(Issue.atPosition(file, new Position(1, 1), message, this.getMetadata().key, this.getConfig().severity));
}
}
ret.push(...this.findOverlappingFields(dynpro, file));
}
return ret;
}
private findOverlappingFields(dynpro: DynproHeader, file: IFile): Issue[] {
const ret: Issue[] = [];
for (let index = 0; index < dynpro.fields.length; index++) {
const current = dynpro.fields[index];
if (current.name === undefined || current.type === "FRAME") {
continue;
}
for (let compare = index + 1; compare < dynpro.fields.length; compare++) {
const other = dynpro.fields[compare];
if (other.name === undefined || other.type === "FRAME" || this.overlaps(current, other) === false) {
continue;
}
const message = `Screen ${dynpro.number}, ${current.type} ${current.name} and ${other.type} ${other.name} are overlapping`;
ret.push(Issue.atPosition(file, new Position(1, 1), message, this.getMetadata().key, this.getConfig().severity));
}
}
return ret;
}
private overlaps(first: DynproField, second: DynproField): boolean {
if (first.line === 0 || second.line === 0 || first.column === 0 || second.column === 0) {
return false;
}
const firstHeight = Math.max(first.height, 1);
const secondHeight = Math.max(second.height, 1);
const firstLastLine = first.line + firstHeight - 1;
const secondLastLine = second.line + secondHeight - 1;
if (firstLastLine < second.line || secondLastLine < first.line) {
return false;
}
const firstLastColumn = first.column + Math.max(first.vislength || first.length, 1) - 1;
const secondLastColumn = second.column + Math.max(second.vislength || second.length, 1) - 1;
return first.column <= secondLastColumn && second.column <= firstLastColumn;
}
}
|