Skip to content

Commit b0293e6

Browse files
authored
Merge pull request #614 from neo4j/fix-sonarcloud-issues
Fix a couple of code issues raised by sonarcloud
2 parents 2fef5ed + 1d58d77 commit b0293e6

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

src/clauses/Clause.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export abstract class Clause extends CypherASTNode {
109109
throw new Error(`Cannot build root: ${root.constructor.name}`);
110110
}
111111

112-
private getEnv(prefix?: string, config: BuildConfig = {}): CypherEnvironment {
112+
private getEnv(prefix: string | undefined, config: BuildConfig): CypherEnvironment {
113113
return new CypherEnvironment(prefix, config);
114114
}
115115

src/utils/escape.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
* limitations under the License.
1818
*/
1919

20-
const ESCAPE_SYMBOL_REGEX = /`/g;
21-
2220
/** These names must be escaped for variables */
2321
const RESERVED_VAR_NAMES = new Set(["contains", "in", "where", "is"]);
2422

@@ -61,12 +59,12 @@ function escapeIfNeeded(str: string): string {
6159

6260
function escapeString(str: string): string {
6361
const normalizedStr = normalizeString(str);
64-
const escapedStr = normalizedStr.replaceAll(ESCAPE_SYMBOL_REGEX, "``");
62+
const escapedStr = normalizedStr.replaceAll("`", "``");
6563
return `\`${escapedStr}\``;
6664
}
6765

6866
function normalizeString(str: string): string {
69-
return str.replaceAll(/\\u0060/g, "`");
67+
return str.replaceAll("\\u0060", "`");
7068
}
7169

7270
function needsEscape(str: string): boolean {

src/utils/pad-block.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919

2020
export function padBlock(block: string, spaces = 4): string {
2121
const paddingStr = " ".repeat(spaces);
22-
const paddedNewLines = block.replaceAll(/\n/g, `\n${paddingStr}`);
22+
const paddedNewLines = block.replaceAll("\n", `\n${paddingStr}`);
2323
return `${paddingStr}${paddedNewLines}`;
2424
}

0 commit comments

Comments
 (0)