@abaplint/cli 2.102.55 → 2.102.57

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 +136 -6
  2. package/package.json +6 -6
package/build/cli.js CHANGED
@@ -295,6 +295,10 @@ class Formatter {
295
295
  return new Formatters.CodeFrame().output(issues, fileCount);
296
296
  case "checkstyle":
297
297
  return new Formatters.Checkstyle().output(issues, fileCount);
298
+ case "sonarqube":
299
+ return new Formatters.Sonarqube().output(issues, fileCount);
300
+ case "codeclimate":
301
+ return new Formatters.CodeClimate().output(issues, fileCount);
298
302
  default:
299
303
  return new Formatters.Standard().output(issues, fileCount);
300
304
  }
@@ -359,6 +363,51 @@ exports.Checkstyle = Checkstyle;
359
363
 
360
364
  /***/ }),
361
365
 
366
+ /***/ "./build/src/formatters/codeclimate.js":
367
+ /*!*********************************************!*\
368
+ !*** ./build/src/formatters/codeclimate.js ***!
369
+ \*********************************************/
370
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
371
+
372
+ "use strict";
373
+
374
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
375
+ exports.CodeClimate = void 0;
376
+ const node_crypto_1 = __webpack_require__(/*! node:crypto */ "node:crypto");
377
+ function md5(content) {
378
+ return (0, node_crypto_1.createHash)("md5").update(content).digest("hex");
379
+ }
380
+ class CodeClimate {
381
+ output(issues, _fileCount) {
382
+ const out = [];
383
+ const defaultSeverity = "info";
384
+ const severityArray = ["info", "minor", "major", "critical", "blocker"];
385
+ for (const issue of issues) {
386
+ const single = {
387
+ type: "issue",
388
+ check_name: issue.getKey(),
389
+ description: issue.getMessage(),
390
+ categories: ["Code Quality"],
391
+ location: {
392
+ path: issue.getFilename(),
393
+ lines: {
394
+ begin: issue.getStart().getRow(),
395
+ end: issue.getEnd().getRow(),
396
+ },
397
+ },
398
+ severity: (severityArray.includes(issue.getSeverity().toLowerCase())) ? issue.getSeverity().toLowerCase() : defaultSeverity,
399
+ fingerprint: md5(issue.getKey() + issue.getMessage() + issue.getFilename() + issue.getStart().getRow() + issue.getEnd().getRow()),
400
+ };
401
+ out.push(single);
402
+ }
403
+ return JSON.stringify(out) + "\n";
404
+ }
405
+ }
406
+ exports.CodeClimate = CodeClimate;
407
+ //# sourceMappingURL=codeclimate.js.map
408
+
409
+ /***/ }),
410
+
362
411
  /***/ "./build/src/formatters/codeframe.js":
363
412
  /*!*******************************************!*\
364
413
  !*** ./build/src/formatters/codeframe.js ***!
@@ -472,6 +521,8 @@ __exportStar(__webpack_require__(/*! ./standard */ "./build/src/formatters/stand
472
521
  __exportStar(__webpack_require__(/*! ./total */ "./build/src/formatters/total.js"), exports);
473
522
  __exportStar(__webpack_require__(/*! ./codeframe */ "./build/src/formatters/codeframe.js"), exports);
474
523
  __exportStar(__webpack_require__(/*! ./checkstyle */ "./build/src/formatters/checkstyle.js"), exports);
524
+ __exportStar(__webpack_require__(/*! ./sonarqube */ "./build/src/formatters/sonarqube.js"), exports);
525
+ __exportStar(__webpack_require__(/*! ./codeclimate */ "./build/src/formatters/codeclimate.js"), exports);
475
526
  //# sourceMappingURL=index.js.map
476
527
 
477
528
  /***/ }),
@@ -615,6 +666,57 @@ exports.Junit = Junit;
615
666
 
616
667
  /***/ }),
617
668
 
669
+ /***/ "./build/src/formatters/sonarqube.js":
670
+ /*!*******************************************!*\
671
+ !*** ./build/src/formatters/sonarqube.js ***!
672
+ \*******************************************/
673
+ /***/ ((__unused_webpack_module, exports) => {
674
+
675
+ "use strict";
676
+
677
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
678
+ exports.Sonarqube = void 0;
679
+ class Sonarqube {
680
+ output(issues, _fileCount) {
681
+ const out = {};
682
+ const issueArray = [];
683
+ const defaultSeverity = "INFO";
684
+ const severityArray = ["INFO", "MINOR", "MAJOR", "CRITICAL", "BLOCKER"];
685
+ for (const issue of issues) {
686
+ const startOffset = issue.getStart().getCol() - 1;
687
+ const endOffset = issue.getEnd().getCol() - 2;
688
+ const single = {
689
+ engineId: "abaplint",
690
+ ruleId: issue.getKey(),
691
+ severity: (severityArray.includes(issue.getSeverity().toUpperCase())) ? issue.getSeverity().toUpperCase() : defaultSeverity,
692
+ type: "CODE_SMELL",
693
+ primaryLocation: {
694
+ message: issue.getMessage(),
695
+ filePath: issue.getFilename(),
696
+ textRange: {
697
+ startLine: issue.getStart().getRow(),
698
+ endLine: issue.getEnd().getRow(),
699
+ startColumn: startOffset,
700
+ endColumn: endOffset,
701
+ },
702
+ },
703
+ effortMinutes: 10,
704
+ };
705
+ if (startOffset >= endOffset) {
706
+ delete single.primaryLocation.textRange.startColumn;
707
+ delete single.primaryLocation.textRange.endColumn;
708
+ }
709
+ issueArray.push(single);
710
+ }
711
+ out.issues = issueArray;
712
+ return JSON.stringify(out) + "\n";
713
+ }
714
+ }
715
+ exports.Sonarqube = Sonarqube;
716
+ //# sourceMappingURL=sonarqube.js.map
717
+
718
+ /***/ }),
719
+
618
720
  /***/ "./build/src/formatters/standard.js":
619
721
  /*!******************************************!*\
620
722
  !*** ./build/src/formatters/standard.js ***!
@@ -16498,9 +16600,10 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
16498
16600
  exports.TruncateDataset = void 0;
16499
16601
  const combi_1 = __webpack_require__(/*! ../combi */ "./node_modules/@abaplint/core/build/src/abap/2_statements/combi.js");
16500
16602
  const expressions_1 = __webpack_require__(/*! ../expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
16603
+ const version_1 = __webpack_require__(/*! ../../../version */ "./node_modules/@abaplint/core/build/src/version.js");
16501
16604
  class TruncateDataset {
16502
16605
  getMatcher() {
16503
- return (0, combi_1.seq)("TRUNCATE DATASET", expressions_1.Source, "AT CURRENT POSITION");
16606
+ return (0, combi_1.verNot)(version_1.Version.Cloud, (0, combi_1.seq)("TRUNCATE DATASET", expressions_1.Source, "AT CURRENT POSITION"));
16504
16607
  }
16505
16608
  }
16506
16609
  exports.TruncateDataset = TruncateDataset;
@@ -21873,6 +21976,7 @@ class TypeUtils {
21873
21976
  else if (source instanceof basic_1.XStringType) {
21874
21977
  if (target instanceof basic_1.CLikeType
21875
21978
  || target instanceof basic_1.IntegerType
21979
+ || target instanceof basic_1.StringType
21876
21980
  || target instanceof basic_1.ObjectReferenceType
21877
21981
  || target instanceof basic_1.HexType) {
21878
21982
  return false;
@@ -24672,6 +24776,7 @@ class MethodCallChain {
24672
24776
  if (first.get() instanceof Expressions.MethodCall) {
24673
24777
  children.unshift(first);
24674
24778
  }
24779
+ let previous = "";
24675
24780
  while (children.length > 0) {
24676
24781
  const current = children.shift();
24677
24782
  if (current === undefined) {
@@ -24692,6 +24797,9 @@ class MethodCallChain {
24692
24797
  }
24693
24798
  }
24694
24799
  else {
24800
+ if (previous === "=>" && (method === null || method === void 0 ? void 0 : method.isStatic()) === false) {
24801
+ throw new Error("Method \"" + methodName + "\" not static");
24802
+ }
24695
24803
  const extra = {
24696
24804
  ooName: foundDef === null || foundDef === void 0 ? void 0 : foundDef.getName(),
24697
24805
  ooType: foundDef instanceof class_definition_1.ClassDefinition ? "CLAS" : "INTF"
@@ -24729,6 +24837,7 @@ class MethodCallChain {
24729
24837
  else if (current instanceof nodes_1.ExpressionNode && current.get() instanceof Expressions.AttributeName) {
24730
24838
  context = new attribute_name_1.AttributeName().runSyntax(context, current, scope, filename);
24731
24839
  }
24840
+ previous = current.concatTokens();
24732
24841
  }
24733
24842
  return context;
24734
24843
  }
@@ -26389,7 +26498,8 @@ class StringTemplate {
26389
26498
  if (type === undefined) {
26390
26499
  throw new Error("No target type determined");
26391
26500
  }
26392
- else if (typeUtils.isCharLike(type) === false && typeUtils.isHexLike(type) === false) {
26501
+ else if ((typeUtils.isCharLike(type) === false && typeUtils.isHexLike(type) === false)
26502
+ || type instanceof basic_1.StructureType) {
26393
26503
  throw new Error("Not character like, " + type.constructor.name);
26394
26504
  }
26395
26505
  const format = templateSource.findDirectExpression(Expressions.StringTemplateFormatting);
@@ -27436,9 +27546,10 @@ const source_1 = __webpack_require__(/*! ../expressions/source */ "./node_module
27436
27546
  const fstarget_1 = __webpack_require__(/*! ../expressions/fstarget */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/fstarget.js");
27437
27547
  const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
27438
27548
  const dynamic_1 = __webpack_require__(/*! ../expressions/dynamic */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/dynamic.js");
27549
+ const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_type_utils.js");
27439
27550
  class Assign {
27440
27551
  runSyntax(node, scope, filename) {
27441
- var _a, _b;
27552
+ var _a;
27442
27553
  const assignSource = node.findDirectExpression(Expressions.AssignSource);
27443
27554
  const sources = (assignSource === null || assignSource === void 0 ? void 0 : assignSource.findDirectExpressions(Expressions.Source)) || [];
27444
27555
  const theSource = sources[sources.length - 1];
@@ -27457,10 +27568,18 @@ class Assign {
27457
27568
  else {
27458
27569
  sourceType = new source_1.Source().runSyntax(theSource, scope, filename);
27459
27570
  }
27460
- if (sourceType === undefined || ((_a = node.findDirectExpression(Expressions.AssignSource)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Dynamic))) {
27571
+ if ((assignSource === null || assignSource === void 0 ? void 0 : assignSource.getChildren().length) === 5
27572
+ && ((_a = assignSource === null || assignSource === void 0 ? void 0 : assignSource.getFirstChild()) === null || _a === void 0 ? void 0 : _a.concatTokens()) === "COMPONENT") {
27573
+ const componentSource = sources[sources.length - 2];
27574
+ const componentType = new source_1.Source().runSyntax(componentSource, scope, filename);
27575
+ if (new _type_utils_1.TypeUtils(scope).isAssignable(componentType, new basic_1.CharacterType(30)) === false) {
27576
+ throw new Error("component name must be charlike");
27577
+ }
27578
+ }
27579
+ if (sourceType === undefined || (assignSource === null || assignSource === void 0 ? void 0 : assignSource.findDirectExpression(Expressions.Dynamic))) {
27461
27580
  sourceType = new basic_1.AnyType();
27462
27581
  }
27463
- for (const d of ((_b = node.findDirectExpression(Expressions.AssignSource)) === null || _b === void 0 ? void 0 : _b.findAllExpressions(Expressions.Dynamic)) || []) {
27582
+ for (const d of (assignSource === null || assignSource === void 0 ? void 0 : assignSource.findAllExpressions(Expressions.Dynamic)) || []) {
27464
27583
  new dynamic_1.Dynamic().runSyntax(d, scope, filename);
27465
27584
  }
27466
27585
  const target = node.findDirectExpression(Expressions.FSTarget);
@@ -49187,7 +49306,7 @@ class Registry {
49187
49306
  }
49188
49307
  static abaplintVersion() {
49189
49308
  // magic, see build script "version.sh"
49190
- return "2.102.55";
49309
+ return "2.102.57";
49191
49310
  }
49192
49311
  getDDICReferences() {
49193
49312
  return this.ddicReferences;
@@ -81798,6 +81917,17 @@ module.exports = require("fs");
81798
81917
 
81799
81918
  /***/ }),
81800
81919
 
81920
+ /***/ "node:crypto":
81921
+ /*!******************************!*\
81922
+ !*** external "node:crypto" ***!
81923
+ \******************************/
81924
+ /***/ ((module) => {
81925
+
81926
+ "use strict";
81927
+ module.exports = require("node:crypto");
81928
+
81929
+ /***/ }),
81930
+
81801
81931
  /***/ "node:os":
81802
81932
  /*!**************************!*\
81803
81933
  !*** external "node:os" ***!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.102.55",
3
+ "version": "2.102.57",
4
4
  "description": "abaplint - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -38,19 +38,19 @@
38
38
  },
39
39
  "homepage": "https://abaplint.org",
40
40
  "devDependencies": {
41
- "@abaplint/core": "^2.102.55",
42
- "@types/chai": "^4.3.6",
41
+ "@abaplint/core": "^2.102.57",
42
+ "@types/chai": "^4.3.7",
43
43
  "@types/glob": "^7.2.0",
44
44
  "@types/minimist": "^1.2.3",
45
45
  "@types/mocha": "^10.0.2",
46
- "@types/node": "^20.8.2",
46
+ "@types/node": "^20.8.4",
47
47
  "@types/progress": "^2.0.5",
48
48
  "chai": "^4.3.10",
49
49
  "chalk": "^5.3.0",
50
- "eslint": "^8.50.0",
50
+ "eslint": "^8.51.0",
51
51
  "glob": "^7.2.3",
52
52
  "json5": "^2.2.3",
53
- "memfs": "^4.5.0",
53
+ "memfs": "^4.6.0",
54
54
  "minimist": "^1.2.8",
55
55
  "mocha": "^10.2.0",
56
56
  "progress": "^2.0.3",