All files / src/rules cloud_types.ts

85.36% Statements 70/82
19.35% Branches 6/31
85.71% Functions 6/7
85.36% Lines 70/82

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 821x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 9360x 9360x 9360x 9360x 9360x 27922x 27922x 27922x 27922x 27922x 27922x 27922x 9360x 9360x     9360x 9360x 8898x 8898x 9360x 9360x 216x 216x 9360x 9360x 216x 216x 216x 9360x 9360x 275x 275x 275x 275x 275x 275x 275x 275x 275x 275x 275x 275x 275x 275x 275x 275x 275x 275x 275x 275x 275x 275x 275x 275x 275x 275x 275x                     9360x 9360x
import {IRule, IRuleMetadata, RuleTag} from "./_irule";
import {Issue} from "../issue";
import {Version} from "../version";
import * as Objects from "../objects";
import {IObject} from "../objects/_iobject";
import {IRegistry} from "../_iregistry";
import {BasicRuleConfig} from "./_basic_rule_config";
import {Position} from "../position";
 
export class CloudTypesConf extends BasicRuleConfig {
}
 
export class CloudTypes implements IRule {
  private reg: IRegistry;
  private conf = new CloudTypesConf();
 
  public getMetadata(): IRuleMetadata {
    return {
      key: "cloud_types",
      title: "Check cloud types",
      shortDescription: `Checks that the package does not contain any object types unsupported in cloud ABAP.`,
      tags: [RuleTag.SingleFile],
    };
  }
 
  private getDescription(objectType: string): string {
    return "Object type " + objectType + " not supported in cloud";
  }
 
  public getConfig() {
    return this.conf;
  }
 
  public setConfig(conf: CloudTypesConf) {
    this.conf = conf;
  }
 
  public initialize(reg: IRegistry) {
    this.reg = reg;
    return this;
  }
 
  public run(obj: IObject): Issue[] {
    if (this.reg.getConfig().getVersion() !== Version.Cloud
        || obj instanceof Objects.AssignmentServiceToAuthorizationGroup
        || obj instanceof Objects.BehaviorDefinition
        || obj instanceof Objects.BusinessCatalog
        || obj instanceof Objects.BusinessCatalogAppAssignment
        || obj instanceof Objects.CDSMetadataExtension
        || obj instanceof Objects.Class
        || obj instanceof Objects.DataControl
        || obj instanceof Objects.DataDefinition
        || obj instanceof Objects.DataElement
        || obj instanceof Objects.Domain
        || obj instanceof Objects.FunctionGroup
        || obj instanceof Objects.HttpService
        || obj instanceof Objects.IAMApp
        || obj instanceof Objects.CommunicationScenario
        || obj instanceof Objects.InboundService
        || obj instanceof Objects.Interface
        || obj instanceof Objects.LockObject
        || obj instanceof Objects.MessageClass
        || obj instanceof Objects.Package
        || obj instanceof Objects.ServiceBinding
        || obj instanceof Objects.ServiceDefinition
        || obj instanceof Objects.Table
        || obj instanceof Objects.TableType
        || obj instanceof Objects.Transformation) {
      return [];
    }

    const position = new Position(1, 1);
    const issue = Issue.atPosition(
      obj.getFiles()[0],
      position,
      this.getDescription(obj.getType()),
      this.getMetadata().key,
      this.conf.severity);
    return [issue];
  }
 
}