Skip to content

Commit 1bf2d3a

Browse files
authored
Merge pull request #25
fix: refactor handleRegularCharacter to eliminate invariant return
2 parents 743fb90 + c1a3437 commit 1bf2d3a

7 files changed

Lines changed: 14 additions & 31 deletions

File tree

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
1515

1616
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=lindentechde_Somon-Script&metric=alert_status)](https://sonarcloud.io/project/overview?id=lindentechde_Somon-Script)
17-
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=lindentechde_Somon-Script&metric=coverage)](https://sonarcloud.io/project/overview?id=lindentechde_Somon-Script)
1817
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=lindentechde_Somon-Script&metric=bugs)](https://sonarcloud.io/project/overview?id=lindentechde_Somon-Script)
1918
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=lindentechde_Somon-Script&metric=code_smells)](https://sonarcloud.io/project/overview?id=lindentechde_Somon-Script)
2019
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=lindentechde_Somon-Script&metric=security_rating)](https://sonarcloud.io/project/overview?id=lindentechde_Somon-Script)

README.ru.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
[![Лицензия](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
1515

1616
[![Статус Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=lindentechde_Somon-Script&metric=alert_status)](https://sonarcloud.io/project/overview?id=lindentechde_Somon-Script)
17-
[![Покрытие](https://sonarcloud.io/api/project_badges/measure?project=lindentechde_Somon-Script&metric=coverage)](https://sonarcloud.io/project/overview?id=lindentechde_Somon-Script)
1817
[![Ошибки](https://sonarcloud.io/api/project_badges/measure?project=lindentechde_Somon-Script&metric=bugs)](https://sonarcloud.io/project/overview?id=lindentechde_Somon-Script)
1918
[![Проблемы Кода](https://sonarcloud.io/api/project_badges/measure?project=lindentechde_Somon-Script&metric=code_smells)](https://sonarcloud.io/project/overview?id=lindentechde_Somon-Script)
2019
[![Рейтинг Безопасности](https://sonarcloud.io/api/project_badges/measure?project=lindentechde_Somon-Script&metric=security_rating)](https://sonarcloud.io/project/overview?id=lindentechde_Somon-Script)

README.tj.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
[![Иҷозатнома](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
1515

1616
[![Ҳолати Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=lindentechde_Somon-Script&metric=alert_status)](https://sonarcloud.io/project/overview?id=lindentechde_Somon-Script)
17-
[![Пӯшиш](https://sonarcloud.io/api/project_badges/measure?project=lindentechde_Somon-Script&metric=coverage)](https://sonarcloud.io/project/overview?id=lindentechde_Somon-Script)
1817
[![Хатоҳо](https://sonarcloud.io/api/project_badges/measure?project=lindentechde_Somon-Script&metric=bugs)](https://sonarcloud.io/project/overview?id=lindentechde_Somon-Script)
1918
[![Мушкилоти Код](https://sonarcloud.io/api/project_badges/measure?project=lindentechde_Somon-Script&metric=code_smells)](https://sonarcloud.io/project/overview?id=lindentechde_Somon-Script)
2019
[![Рейтинги Бехатарӣ](https://sonarcloud.io/api/project_badges/measure?project=lindentechde_Somon-Script&metric=security_rating)](https://sonarcloud.io/project/overview?id=lindentechde_Somon-Script)

package-lock.json

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lexer.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -457,15 +457,12 @@ export class Lexer {
457457

458458
private handleRegularCharacter(): string {
459459
const char = this.currentChar();
460+
this.advance();
460461
if (char === '\n') {
461-
this.advance();
462462
this.line++;
463463
this.column = 1;
464-
return char;
465-
} else {
466-
this.advance();
467-
return char;
468464
}
465+
return char;
469466
}
470467

471468
private readNumber(startLine: number, startColumn: number): Token {

src/module-system/module-system.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ export class ModuleSystem {
230230
): CompilationError {
231231
// Try to extract line and column from error message
232232
const lineColMatch = message.match(/(?:line|:)\s*(\d+)(?::(\d+))?/i);
233-
const line = lineColMatch ? Number.parseInt(lineColMatch[1], 10) : undefined;
234-
const column = lineColMatch && lineColMatch[2] ? Number.parseInt(lineColMatch[2], 10) : undefined;
233+
const line = lineColMatch?.[1] ? Number.parseInt(lineColMatch[1], 10) : undefined;
234+
const column = lineColMatch?.[2] ? Number.parseInt(lineColMatch[2], 10) : undefined;
235235

236236
return {
237237
message,

tests/helpers/test-utils.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,19 @@ export interface CliRunOptions {
6969

7070
/** Run a CLI command with common defaults */
7171
export function runCliCommand(options: CliRunOptions): SpawnSyncReturns<string> {
72-
return spawnSync(
73-
process.execPath,
74-
[CLI_PATH, options.command, ...options.args],
75-
{
76-
encoding: options.encoding || 'utf-8',
77-
timeout: options.timeout || 10000,
78-
cwd: options.cwd,
79-
env: options.env || process.env,
80-
}
81-
);
72+
return spawnSync(process.execPath, [CLI_PATH, options.command, ...options.args], {
73+
encoding: options.encoding || 'utf-8',
74+
timeout: options.timeout || 10000,
75+
cwd: options.cwd,
76+
env: options.env || process.env,
77+
});
8278
}
8379

8480
/** Create a test .som file with given content */
85-
export function createTestFile(filePath: string, content: string = TEST_FIXTURES.testFunction): void {
81+
export function createTestFile(
82+
filePath: string,
83+
content: string = TEST_FIXTURES.testFunction
84+
): void {
8685
fs.writeFileSync(filePath, content);
8786
}
8887

0 commit comments

Comments
 (0)