@abaplint/cli 2.120.90 → 2.120.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/build/cli.js +278 -8
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -34757,6 +34757,8 @@ class NewObject {
34757
34757
  }
34758
34758
  }
34759
34759
  else if (typeName === "#" && targetType) {
34760
+ const tid = new _typed_identifier_1.TypedIdentifier(typeToken, input.filename, targetType);
34761
+ input.scope.addReference(typeToken, tid, _reference_1.ReferenceType.InferredType, input.filename);
34760
34762
  ret = targetType;
34761
34763
  }
34762
34764
  else if (typeName === "#") {
@@ -72777,7 +72779,7 @@ class Registry {
72777
72779
  }
72778
72780
  static abaplintVersion() {
72779
72781
  // magic, see build script "version.js"
72780
- return "2.120.90";
72782
+ return "2.120.91";
72781
72783
  }
72782
72784
  getDDICReferences() {
72783
72785
  return this.ddicReferences;
@@ -75434,6 +75436,149 @@ exports.AbapdocParameterNames = AbapdocParameterNames;
75434
75436
 
75435
75437
  /***/ },
75436
75438
 
75439
+ /***/ "../core/build/src/rules/abapdoc_short_link.js"
75440
+ /*!*****************************************************!*\
75441
+ !*** ../core/build/src/rules/abapdoc_short_link.js ***!
75442
+ \*****************************************************/
75443
+ (__unused_webpack_module, exports, __webpack_require__) {
75444
+
75445
+ "use strict";
75446
+
75447
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
75448
+ if (k2 === undefined) k2 = k;
75449
+ var desc = Object.getOwnPropertyDescriptor(m, k);
75450
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
75451
+ desc = { enumerable: true, get: function() { return m[k]; } };
75452
+ }
75453
+ Object.defineProperty(o, k2, desc);
75454
+ }) : (function(o, m, k, k2) {
75455
+ if (k2 === undefined) k2 = k;
75456
+ o[k2] = m[k];
75457
+ }));
75458
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
75459
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
75460
+ }) : function(o, v) {
75461
+ o["default"] = v;
75462
+ });
75463
+ var __importStar = (this && this.__importStar) || (function () {
75464
+ var ownKeys = function(o) {
75465
+ ownKeys = Object.getOwnPropertyNames || function (o) {
75466
+ var ar = [];
75467
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
75468
+ return ar;
75469
+ };
75470
+ return ownKeys(o);
75471
+ };
75472
+ return function (mod) {
75473
+ if (mod && mod.__esModule) return mod;
75474
+ var result = {};
75475
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
75476
+ __setModuleDefault(result, mod);
75477
+ return result;
75478
+ };
75479
+ })();
75480
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
75481
+ exports.AbapdocShortLink = exports.AbapdocShortLinkConf = void 0;
75482
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
75483
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
75484
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
75485
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
75486
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
75487
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
75488
+ const _statement_1 = __webpack_require__(/*! ../abap/2_statements/statements/_statement */ "../core/build/src/abap/2_statements/statements/_statement.js");
75489
+ const position_1 = __webpack_require__(/*! ../position */ "../core/build/src/position.js");
75490
+ const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
75491
+ class AbapdocShortLinkConf extends _basic_rule_config_1.BasicRuleConfig {
75492
+ }
75493
+ exports.AbapdocShortLinkConf = AbapdocShortLinkConf;
75494
+ class AbapdocShortLink extends _abap_rule_1.ABAPRule {
75495
+ constructor() {
75496
+ super(...arguments);
75497
+ this.conf = new AbapdocShortLinkConf();
75498
+ }
75499
+ getMetadata() {
75500
+ return {
75501
+ key: "abapdoc_short_link",
75502
+ title: "Use short form of ABAP Doc links",
75503
+ shortDescription: `Reports ABAP Doc links to components of the current global class or interface which repeat the object name.`,
75504
+ extendedInformation: `Links to components of the same repository object can omit the object name and start with a period,
75505
+ {@link zif_foo.data:field} can be written as {@link .data:field}.
75506
+
75507
+ Only checks ABAP Doc inside the definition of the global class or interface.
75508
+
75509
+ https://github.com/SAP/abap-file-formats/issues/880`,
75510
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
75511
+ badExample: `INTERFACE zif_foo PUBLIC.
75512
+ "! Same as {@link zif_foo.data:bar}
75513
+ DATA foo TYPE string.
75514
+ DATA bar TYPE string.
75515
+ ENDINTERFACE.`,
75516
+ goodExample: `INTERFACE zif_foo PUBLIC.
75517
+ "! Same as {@link .data:bar}
75518
+ DATA foo TYPE string.
75519
+ DATA bar TYPE string.
75520
+ ENDINTERFACE.`,
75521
+ };
75522
+ }
75523
+ getConfig() {
75524
+ return this.conf;
75525
+ }
75526
+ setConfig(conf) {
75527
+ this.conf = conf;
75528
+ }
75529
+ runParsed(file, obj) {
75530
+ var _a;
75531
+ const issues = [];
75532
+ const objectType = obj.getType();
75533
+ if (objectType !== "CLAS" && objectType !== "INTF") {
75534
+ return [];
75535
+ }
75536
+ const objectName = obj.getName().toLowerCase();
75537
+ let definition = false;
75538
+ for (const statement of file.getStatements()) {
75539
+ const type = statement.get();
75540
+ if (type instanceof Statements.ClassDefinition || type instanceof Statements.Interface) {
75541
+ const name = (_a = statement.findFirstExpression(Expressions.ClassName)) !== null && _a !== void 0 ? _a : statement.findFirstExpression(Expressions.InterfaceName);
75542
+ definition = (name === null || name === void 0 ? void 0 : name.getFirstToken().getStr().toLowerCase()) === objectName;
75543
+ continue;
75544
+ }
75545
+ else if (type instanceof Statements.EndClass || type instanceof Statements.EndInterface) {
75546
+ definition = false;
75547
+ continue;
75548
+ }
75549
+ else if (definition === false || !(type instanceof _statement_1.Comment)) {
75550
+ continue;
75551
+ }
75552
+ const token = statement.getFirstToken();
75553
+ const str = token.getStr();
75554
+ if (str.startsWith(`"!`) === false) {
75555
+ continue;
75556
+ }
75557
+ const regex = /\{@link\s+((?:(\w+):)?([\w/]+))\./gi;
75558
+ let match;
75559
+ while ((match = regex.exec(str)) !== null) {
75560
+ const kind = match[2];
75561
+ if (match[3].toLowerCase() !== objectName
75562
+ || (kind !== undefined && kind.toLowerCase() !== objectType.toLowerCase())) {
75563
+ continue;
75564
+ }
75565
+ const row = token.getStart().getRow();
75566
+ const col = token.getStart().getCol() + match.index + match[0].length - 1 - match[1].length;
75567
+ const start = new position_1.Position(row, col);
75568
+ const end = new position_1.Position(row, col + match[1].length);
75569
+ const fix = edit_helper_1.EditHelper.deleteRange(file, start, end);
75570
+ const message = `Use short form of ABAP Doc link, remove "${match[1]}"`;
75571
+ issues.push(issue_1.Issue.atRange(file, start, end, message, this.getMetadata().key, this.conf.severity, fix));
75572
+ }
75573
+ }
75574
+ return issues;
75575
+ }
75576
+ }
75577
+ exports.AbapdocShortLink = AbapdocShortLink;
75578
+ //# sourceMappingURL=abapdoc_short_link.js.map
75579
+
75580
+ /***/ },
75581
+
75437
75582
  /***/ "../core/build/src/rules/abapdoc_shorttext_length.js"
75438
75583
  /*!***********************************************************!*\
75439
75584
  !*** ../core/build/src/rules/abapdoc_shorttext_length.js ***!
@@ -87615,12 +87760,9 @@ ${indentation} output = ${uniqueName}.\n`;
87615
87760
  }
87616
87761
  }
87617
87762
  /** NEW into a data reference creates data, CREATE OBJECT cannot: "target = NEW #|type( [value] )"
87618
- * with a variable typed REF TO a data type becomes CREATE DATA plus the assignment of the value */
87763
+ * with a target typed REF TO a data type becomes CREATE DATA plus the assignment of the value */
87619
87764
  newDataReference(high, target, found, lowFile, highSyntax) {
87620
87765
  var _a, _b, _c;
87621
- if (target.getChildren().length !== 1 || !(((_a = target.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.TargetField)) {
87622
- return undefined;
87623
- }
87624
87766
  const children = found.getChildren();
87625
87767
  const value = found.findDirectExpression(Expressions.Source);
87626
87768
  // NEW, the type, "(", optionally one value, ")"
@@ -87628,12 +87770,23 @@ ${indentation} output = ${uniqueName}.\n`;
87628
87770
  return undefined;
87629
87771
  }
87630
87772
  const name = target.concatTokens();
87773
+ const typeExpr = found.findDirectExpression(Expressions.TypeNameOrInfer);
87774
+ const typeName = typeExpr === null || typeExpr === void 0 ? void 0 : typeExpr.concatTokens();
87631
87775
  const spag = highSyntax.spaghetti.lookupPosition(high.getFirstToken().getStart(), lowFile.getFilename());
87632
- const type = (_b = spag === null || spag === void 0 ? void 0 : spag.findVariable(name)) === null || _b === void 0 ? void 0 : _b.getType();
87776
+ let type = undefined;
87777
+ if (typeName === "#") {
87778
+ // the type of the target, as inferred by the syntax check
87779
+ const typeToken = typeExpr.getFirstToken();
87780
+ const resolved = (_a = spag === null || spag === void 0 ? void 0 : spag.getData().references.find(r => r.referenceType === _reference_1.ReferenceType.InferredType
87781
+ && r.position.getStart().equals(typeToken.getStart()))) === null || _a === void 0 ? void 0 : _a.resolved;
87782
+ type = resolved instanceof _typed_identifier_1.TypedIdentifier ? resolved.getType() : undefined;
87783
+ }
87784
+ else if (target.getChildren().length === 1 && ((_b = target.getFirstChild()) === null || _b === void 0 ? void 0 : _b.get()) instanceof Expressions.TargetField) {
87785
+ type = (_c = spag === null || spag === void 0 ? void 0 : spag.findVariable(name)) === null || _c === void 0 ? void 0 : _c.getType();
87786
+ }
87633
87787
  if (!(type instanceof basic_1.DataReference)) {
87634
87788
  return undefined;
87635
87789
  }
87636
- const typeName = (_c = found.findDirectExpression(Expressions.TypeNameOrInfer)) === null || _c === void 0 ? void 0 : _c.concatTokens();
87637
87790
  const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
87638
87791
  let abap = `CREATE DATA ${name}` + (typeName === "#" ? "" : ` TYPE ${typeName}`) + ".";
87639
87792
  if (value === undefined) {
@@ -87681,7 +87834,7 @@ ${indentation} output = ${uniqueName}.\n`;
87681
87834
  }
87682
87835
  }
87683
87836
  else {
87684
- throw new Error("newParameters, downport, unexpected");
87837
+ return undefined; // not an object, CREATE OBJECT does not apply
87685
87838
  }
87686
87839
  }
87687
87840
  if (cdef && cdef.getMethodDefinitions === undefined) {
@@ -89188,6 +89341,121 @@ exports.ForbiddenIdentifier = ForbiddenIdentifier;
89188
89341
 
89189
89342
  /***/ },
89190
89343
 
89344
+ /***/ "../core/build/src/rules/forbidden_kernel_write.js"
89345
+ /*!*********************************************************!*\
89346
+ !*** ../core/build/src/rules/forbidden_kernel_write.js ***!
89347
+ \*********************************************************/
89348
+ (__unused_webpack_module, exports, __webpack_require__) {
89349
+
89350
+ "use strict";
89351
+
89352
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
89353
+ if (k2 === undefined) k2 = k;
89354
+ var desc = Object.getOwnPropertyDescriptor(m, k);
89355
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
89356
+ desc = { enumerable: true, get: function() { return m[k]; } };
89357
+ }
89358
+ Object.defineProperty(o, k2, desc);
89359
+ }) : (function(o, m, k, k2) {
89360
+ if (k2 === undefined) k2 = k;
89361
+ o[k2] = m[k];
89362
+ }));
89363
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
89364
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
89365
+ }) : function(o, v) {
89366
+ o["default"] = v;
89367
+ });
89368
+ var __importStar = (this && this.__importStar) || (function () {
89369
+ var ownKeys = function(o) {
89370
+ ownKeys = Object.getOwnPropertyNames || function (o) {
89371
+ var ar = [];
89372
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
89373
+ return ar;
89374
+ };
89375
+ return ownKeys(o);
89376
+ };
89377
+ return function (mod) {
89378
+ if (mod && mod.__esModule) return mod;
89379
+ var result = {};
89380
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
89381
+ __setModuleDefault(result, mod);
89382
+ return result;
89383
+ };
89384
+ })();
89385
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
89386
+ exports.ForbiddenKernelWrite = exports.ForbiddenKernelWriteConf = void 0;
89387
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
89388
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
89389
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
89390
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
89391
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
89392
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
89393
+ class ForbiddenKernelWriteConf extends _basic_rule_config_1.BasicRuleConfig {
89394
+ constructor() {
89395
+ super(...arguments);
89396
+ /** Objects allowed to use WRITE '@KERNEL', array of string regex matched against the object name.
89397
+ * Empty, the default, allows every object
89398
+ * @uniqueItems true
89399
+ */
89400
+ this.allow = [];
89401
+ }
89402
+ }
89403
+ exports.ForbiddenKernelWriteConf = ForbiddenKernelWriteConf;
89404
+ class ForbiddenKernelWrite extends _abap_rule_1.ABAPRule {
89405
+ constructor() {
89406
+ super(...arguments);
89407
+ this.conf = new ForbiddenKernelWriteConf();
89408
+ this.allow = [];
89409
+ }
89410
+ getMetadata() {
89411
+ return {
89412
+ key: "forbidden_kernel_write",
89413
+ title: "Forbidden kernel WRITE",
89414
+ shortDescription: `Forbid WRITE '@KERNEL' outside the listed objects`,
89415
+ extendedInformation: `The transpiler emits the literal of WRITE '@KERNEL ...' as raw JavaScript,
89416
+ which runs with the privileges of the host. Open-abap uses this for its kernel classes, code compiled by a host it did not write should not.
89417
+
89418
+ allow is a list of regex, case insensitive, matched against the object name, eg. ["^CL_", "^KERNEL_"].
89419
+ An empty list, the default, allows every object. To forbid WRITE '@KERNEL' everywhere use a regex matching no name, eg. ["^$"].`,
89420
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Security],
89421
+ badExample: `WRITE '@KERNEL process.exit(1);'.`,
89422
+ };
89423
+ }
89424
+ getConfig() {
89425
+ return this.conf;
89426
+ }
89427
+ setConfig(conf) {
89428
+ this.conf = conf;
89429
+ if (this.conf.allow === undefined) {
89430
+ this.conf.allow = [];
89431
+ }
89432
+ this.allow = this.conf.allow.map(a => new RegExp(a, "i"));
89433
+ }
89434
+ runParsed(file, obj) {
89435
+ var _a;
89436
+ if (this.allow.length === 0 || this.allow.some(a => a.test(obj.getName()))) {
89437
+ return [];
89438
+ }
89439
+ const ret = [];
89440
+ for (const s of file.getStatements()) {
89441
+ if (!(s.get() instanceof Statements.Write)) {
89442
+ continue;
89443
+ }
89444
+ // same check as the transpiler, statements/write.ts
89445
+ const source = (_a = s.findDirectExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.concatTokens();
89446
+ if ((source === null || source === void 0 ? void 0 : source.startsWith("'@KERNEL ")) === true) {
89447
+ const message = "WRITE '@KERNEL' not allowed in " + obj.getName();
89448
+ ret.push(issue_1.Issue.atStatement(file, s, message, this.getMetadata().key, this.conf.severity));
89449
+ }
89450
+ }
89451
+ return ret;
89452
+ }
89453
+ }
89454
+ exports.ForbiddenKernelWrite = ForbiddenKernelWrite;
89455
+ //# sourceMappingURL=forbidden_kernel_write.js.map
89456
+
89457
+ /***/ },
89458
+
89191
89459
  /***/ "../core/build/src/rules/forbidden_pseudo_and_pragma.js"
89192
89460
  /*!**************************************************************!*\
89193
89461
  !*** ../core/build/src/rules/forbidden_pseudo_and_pragma.js ***!
@@ -92084,6 +92352,7 @@ __exportStar(__webpack_require__(/*! ./abapdoc */ "../core/build/src/rules/abapd
92084
92352
  __exportStar(__webpack_require__(/*! ./abapdoc_html_tag */ "../core/build/src/rules/abapdoc_html_tag.js"), exports);
92085
92353
  __exportStar(__webpack_require__(/*! ./abapdoc_leading_at */ "../core/build/src/rules/abapdoc_leading_at.js"), exports);
92086
92354
  __exportStar(__webpack_require__(/*! ./abapdoc_parameter_names */ "../core/build/src/rules/abapdoc_parameter_names.js"), exports);
92355
+ __exportStar(__webpack_require__(/*! ./abapdoc_short_link */ "../core/build/src/rules/abapdoc_short_link.js"), exports);
92087
92356
  __exportStar(__webpack_require__(/*! ./abapdoc_shorttext_length */ "../core/build/src/rules/abapdoc_shorttext_length.js"), exports);
92088
92357
  __exportStar(__webpack_require__(/*! ./add_test_attributes */ "../core/build/src/rules/add_test_attributes.js"), exports);
92089
92358
  __exportStar(__webpack_require__(/*! ./aff_and_xml */ "../core/build/src/rules/aff_and_xml.js"), exports);
@@ -92158,6 +92427,7 @@ __exportStar(__webpack_require__(/*! ./exporting */ "../core/build/src/rules/exp
92158
92427
  __exportStar(__webpack_require__(/*! ./final_newline */ "../core/build/src/rules/final_newline.js"), exports);
92159
92428
  __exportStar(__webpack_require__(/*! ./fm_global_parameters_obsolete */ "../core/build/src/rules/fm_global_parameters_obsolete.js"), exports);
92160
92429
  __exportStar(__webpack_require__(/*! ./forbidden_identifier */ "../core/build/src/rules/forbidden_identifier.js"), exports);
92430
+ __exportStar(__webpack_require__(/*! ./forbidden_kernel_write */ "../core/build/src/rules/forbidden_kernel_write.js"), exports);
92161
92431
  __exportStar(__webpack_require__(/*! ./forbidden_pseudo_and_pragma */ "../core/build/src/rules/forbidden_pseudo_and_pragma.js"), exports);
92162
92432
  __exportStar(__webpack_require__(/*! ./forbidden_void_type */ "../core/build/src/rules/forbidden_void_type.js"), exports);
92163
92433
  __exportStar(__webpack_require__(/*! ./form_tables_obsolete */ "../core/build/src/rules/form_tables_obsolete.js"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.120.90",
3
+ "version": "2.120.91",
4
4
  "description": "abaplint - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "homepage": "https://abaplint.org",
41
41
  "devDependencies": {
42
- "@abaplint/core": "^2.120.90",
42
+ "@abaplint/core": "^2.120.91",
43
43
  "@types/chai": "^4.3.20",
44
44
  "@types/minimist": "^1.2.5",
45
45
  "@types/mocha": "^10.0.10",