@abaplint/core 2.96.1 → 2.96.2

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.
@@ -63,7 +63,7 @@ class Registry {
63
63
  }
64
64
  static abaplintVersion() {
65
65
  // magic, see build script "version.sh"
66
- return "2.96.1";
66
+ return "2.96.2";
67
67
  }
68
68
  getDDICReferences() {
69
69
  return this.references;
@@ -8,6 +8,7 @@ const _abap_rule_1 = require("./_abap_rule");
8
8
  const _basic_rule_config_1 = require("./_basic_rule_config");
9
9
  const version_1 = require("../version");
10
10
  const _irule_1 = require("./_irule");
11
+ const edit_helper_1 = require("../edit_helper");
11
12
  class SQLEscapeHostVariablesConf extends _basic_rule_config_1.BasicRuleConfig {
12
13
  }
13
14
  exports.SQLEscapeHostVariablesConf = SQLEscapeHostVariablesConf;
@@ -22,7 +23,7 @@ class SQLEscapeHostVariables extends _abap_rule_1.ABAPRule {
22
23
  title: "Escape SQL host variables",
23
24
  shortDescription: `Escape SQL host variables, from 740sp05`,
24
25
  extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#avoid-obsolete-language-elements`,
25
- tags: [_irule_1.RuleTag.Upport, _irule_1.RuleTag.Styleguide],
26
+ tags: [_irule_1.RuleTag.Upport, _irule_1.RuleTag.Styleguide, _irule_1.RuleTag.Quickfix],
26
27
  badExample: `SELECT * FROM tab INTO TABLE res WHERE field = val.`,
27
28
  goodExample: `SELECT * FROM tab INTO TABLE @res WHERE field = @val.`,
28
29
  };
@@ -35,52 +36,45 @@ class SQLEscapeHostVariables extends _abap_rule_1.ABAPRule {
35
36
  }
36
37
  runParsed(file, obj) {
37
38
  const issues = [];
38
- if (obj.getType() === "INTF") {
39
+ const type = obj.getType();
40
+ if (type === "INTF" || type === "TYPE") {
39
41
  return [];
40
42
  }
41
- if (this.reg.getConfig().getVersion() < version_1.Version.v740sp02 && this.reg.getConfig().getVersion() !== version_1.Version.Cloud) {
43
+ if (this.reg.getConfig().getVersion() < version_1.Version.v740sp02
44
+ && this.reg.getConfig().getVersion() !== version_1.Version.Cloud) {
42
45
  return [];
43
46
  }
44
47
  for (const s of file.getStatements()) {
45
- const str = s.concatTokens().toUpperCase();
46
- if (s.get() instanceof Statements.Select
47
- || s.get() instanceof Statements.SelectLoop) {
48
- // this is not completely correct and does not catch all, but okay for now
49
- // todo: replace with logic from "else if" branch below, when/if it proves to work
50
- if (str.includes(" INTO ( @")
51
- || str.includes(" INTO (@")
52
- || str.includes(" INTO @")
53
- || str.includes(" INTO TABLE @")
54
- || str.includes(" INTO CORRESPONDING FIELDS OF @")
55
- || str.includes(" INTO CORRESPONDING FIELDS OF TABLE @")
56
- || str.includes(" APPENDING TABLE @")
57
- || (str.includes(" APPENDING ") === false && str.includes(" INTO ") === false)
58
- || str.includes(" APPENDING CORRESPONDING FIELDS OF TABLE @")) {
59
- continue;
60
- }
61
- else {
62
- const message = "Escape SQL host variables";
63
- const issue = issue_1.Issue.atToken(file, s.getFirstToken(), message, this.getMetadata().key, this.conf.severity);
64
- issues.push(issue);
65
- }
66
- }
67
- else if (s.get() instanceof Statements.UpdateDatabase
48
+ if (s.get() instanceof Statements.UpdateDatabase
68
49
  || s.get() instanceof Statements.ModifyDatabase
50
+ || s.get() instanceof Statements.Select
51
+ || s.get() instanceof Statements.SelectLoop
69
52
  || s.get() instanceof Statements.InsertDatabase
70
53
  || s.get() instanceof Statements.DeleteDatabase) {
71
- if (str.startsWith("MODIFY SCREEN FROM ")) {
72
- continue;
73
- }
74
54
  for (const o of s.findAllExpressions(Expressions.SQLSource)) {
75
55
  const first = o.getFirstChild();
76
56
  if (((first === null || first === void 0 ? void 0 : first.get()) instanceof Expressions.Source && first.getChildren()[0].get() instanceof Expressions.FieldChain)
77
57
  || ((first === null || first === void 0 ? void 0 : first.get()) instanceof Expressions.SimpleSource3 && first.getChildren()[0].get() instanceof Expressions.FieldChain)) {
78
58
  const message = "Escape SQL host variables";
79
- const issue = issue_1.Issue.atToken(file, first.getFirstToken(), message, this.getMetadata().key, this.conf.severity);
59
+ const firstToken = o.getFirstChild().getFirstToken();
60
+ const fix = edit_helper_1.EditHelper.replaceToken(file, firstToken, "@" + (firstToken === null || firstToken === void 0 ? void 0 : firstToken.getStr()));
61
+ const issue = issue_1.Issue.atToken(file, first.getFirstToken(), message, this.getMetadata().key, this.conf.severity, fix);
80
62
  issues.push(issue);
81
63
  break;
82
64
  }
83
65
  }
66
+ for (const o of s.findAllExpressions(Expressions.SQLTarget)) {
67
+ const escaped = o.findDirectTokenByText("@");
68
+ if (escaped !== undefined) {
69
+ continue;
70
+ }
71
+ const message = "Escape SQL host variables";
72
+ const firstToken = o.getFirstChild().getFirstToken();
73
+ const fix = edit_helper_1.EditHelper.replaceToken(file, firstToken, "@" + (firstToken === null || firstToken === void 0 ? void 0 : firstToken.getStr()));
74
+ const issue = issue_1.Issue.atToken(file, o.getFirstToken(), message, this.getMetadata().key, this.conf.severity, fix);
75
+ issues.push(issue);
76
+ break;
77
+ }
84
78
  }
85
79
  }
86
80
  return issues;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.96.1",
3
+ "version": "2.96.2",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",