Skip to content

Commit 6800df8

Browse files
committed
Fix code scanning issues
This resolves 30 occurrences of: ```ts require(path.join(__dirname), './relative-path')) ``` By replacing them with the equivalent: ``` require('./relative-path') ```
1 parent f039273 commit 6800df8

File tree

4 files changed

+30
-32
lines changed

4 files changed

+30
-32
lines changed

test/autoCompletion.test.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ describe('Auto Completion Tests', () => {
786786
});
787787

788788
it('Insert required attributes at correct level', (done) => {
789-
const schema = require(path.join(__dirname, './fixtures/testRequiredProperties.json'));
789+
const schema = require('./fixtures/testRequiredProperties.json');
790790
schemaProvider.addSchema(SCHEMA_ID, schema);
791791
const content = '- top:\n prop1: demo\n- ';
792792
const completion = parseSetup(content, content.length);
@@ -804,7 +804,7 @@ describe('Auto Completion Tests', () => {
804804
});
805805

806806
it('Insert required attributes at correct level even on first element', (done) => {
807-
const schema = require(path.join(__dirname, './fixtures/testRequiredProperties.json'));
807+
const schema = require('./fixtures/testRequiredProperties.json');
808808
schemaProvider.addSchema(SCHEMA_ID, schema);
809809
const content = '- ';
810810
const completion = parseSetup(content, content.length);
@@ -822,7 +822,7 @@ describe('Auto Completion Tests', () => {
822822
});
823823

824824
it('Provide the 3 types when none provided', (done) => {
825-
const schema = require(path.join(__dirname, './fixtures/testArrayMaxProperties.json'));
825+
const schema = require('./fixtures/testArrayMaxProperties.json');
826826
schemaProvider.addSchema(SCHEMA_ID, schema);
827827
const content = '- ';
828828
const completion = parseSetup(content, content.length);
@@ -852,7 +852,7 @@ describe('Auto Completion Tests', () => {
852852
});
853853

854854
it('Provide the 2 types when one is provided', (done) => {
855-
const schema = require(path.join(__dirname, './fixtures/testArrayMaxProperties.json'));
855+
const schema = require('./fixtures/testArrayMaxProperties.json');
856856
schemaProvider.addSchema(SCHEMA_ID, schema);
857857
const content = '- prop1:\n ';
858858
const completion = parseSetup(content, content.length);
@@ -876,7 +876,7 @@ describe('Auto Completion Tests', () => {
876876
});
877877

878878
it('Provide the 2 types when one is provided and the second is typed', (done) => {
879-
const schema = require(path.join(__dirname, './fixtures/testArrayMaxProperties.json'));
879+
const schema = require('./fixtures/testArrayMaxProperties.json');
880880
schemaProvider.addSchema(SCHEMA_ID, schema);
881881
const content = '- prop1:\n p';
882882
const completion = parseSetup(content, content.length);
@@ -900,7 +900,7 @@ describe('Auto Completion Tests', () => {
900900
});
901901

902902
it('Provide no completion when maxProperties reached', (done) => {
903-
const schema = require(path.join(__dirname, './fixtures/testArrayMaxProperties.json'));
903+
const schema = require('./fixtures/testArrayMaxProperties.json');
904904
schemaProvider.addSchema(SCHEMA_ID, schema);
905905
const content = '- prop1:\n prop2:\n ';
906906
const completion = parseSetup(content, content.length);
@@ -1041,7 +1041,7 @@ describe('Auto Completion Tests', () => {
10411041

10421042
describe('Array Specific Tests', function () {
10431043
it('Should insert empty array item', (done) => {
1044-
const schema = require(path.join(__dirname, './fixtures/testStringArray.json'));
1044+
const schema = require('./fixtures/testStringArray.json');
10451045
schemaProvider.addSchema(SCHEMA_ID, schema);
10461046
const content = 'fooBa'; // len: 5
10471047
const completion = parseSetup(content, content.lastIndexOf('Ba') + 2); // pos: 3+2
@@ -1842,7 +1842,7 @@ describe('Auto Completion Tests', () => {
18421842

18431843
describe('Indentation Specific Tests', function () {
18441844
it('Indent should be considered with position relative to slash', (done) => {
1845-
const schema = require(path.join(__dirname, './fixtures/testArrayIndent.json'));
1845+
const schema = require('./fixtures/testArrayIndent.json');
18461846
schemaProvider.addSchema(SCHEMA_ID, schema);
18471847
const content = 'install:\n - he'; // len: 15
18481848
const completion = parseSetup(content, content.lastIndexOf('he') + 2); // pos: 13+2
@@ -1860,7 +1860,7 @@ describe('Auto Completion Tests', () => {
18601860
});
18611861

18621862
it('Large indent should be considered with position relative to slash', (done) => {
1863-
const schema = require(path.join(__dirname, './fixtures/testArrayIndent.json'));
1863+
const schema = require('./fixtures/testArrayIndent.json');
18641864
schemaProvider.addSchema(SCHEMA_ID, schema);
18651865
const content = 'install:\n - he'; // len: 25
18661866
const completion = parseSetup(content, content.lastIndexOf('he') + 2); // pos: 23+2
@@ -1878,7 +1878,7 @@ describe('Auto Completion Tests', () => {
18781878
});
18791879

18801880
it('Tab indent should be considered with position relative to slash', (done) => {
1881-
const schema = require(path.join(__dirname, './fixtures/testArrayIndent.json'));
1881+
const schema = require('./fixtures/testArrayIndent.json');
18821882
schemaProvider.addSchema(SCHEMA_ID, schema);
18831883
const content = 'install:\n -\t he'; // len: 27
18841884
const completion = parseSetup(content, content.lastIndexOf('he') + 2); // pos: 25+2
@@ -2601,7 +2601,7 @@ describe('Auto Completion Tests', () => {
26012601

26022602
describe('Array completion', () => {
26032603
it('Simple array object completion with "-" without any item', (done) => {
2604-
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
2604+
const schema = require('./fixtures/testArrayCompletionSchema.json');
26052605
schemaProvider.addSchema(SCHEMA_ID, schema);
26062606
const content = 'test_simpleArrayObject:\n -';
26072607
const completion = parseSetup(content, content.length);
@@ -2615,7 +2615,7 @@ describe('Auto Completion Tests', () => {
26152615
});
26162616

26172617
it('Simple array object completion without "-" after array item', (done) => {
2618-
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
2618+
const schema = require('./fixtures/testArrayCompletionSchema.json');
26192619
schemaProvider.addSchema(SCHEMA_ID, schema);
26202620
const content = 'test_simpleArrayObject:\n - obj1:\n name: 1\n ';
26212621
const completion = parseSetup(content, content.length);
@@ -2628,7 +2628,7 @@ describe('Auto Completion Tests', () => {
26282628
});
26292629

26302630
it('Simple array object completion with "-" after array item', (done) => {
2631-
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
2631+
const schema = require('./fixtures/testArrayCompletionSchema.json');
26322632
schemaProvider.addSchema(SCHEMA_ID, schema);
26332633
const content = 'test_simpleArrayObject:\n - obj1:\n name: 1\n -';
26342634
const completion = parseSetup(content, content.length);
@@ -2642,7 +2642,7 @@ describe('Auto Completion Tests', () => {
26422642
});
26432643

26442644
it('Array anyOf two objects completion with "- " without any item', (done) => {
2645-
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
2645+
const schema = require('./fixtures/testArrayCompletionSchema.json');
26462646
schemaProvider.addSchema(SCHEMA_ID, schema);
26472647
const content = 'test_array_anyOf_2objects:\n - ';
26482648
const completion = parseSetup(content, content.length);
@@ -2658,7 +2658,7 @@ describe('Auto Completion Tests', () => {
26582658
});
26592659

26602660
it('Array anyOf two objects completion with "-" without any item', (done) => {
2661-
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
2661+
const schema = require('./fixtures/testArrayCompletionSchema.json');
26622662
schemaProvider.addSchema(SCHEMA_ID, schema);
26632663
const content = 'test_array_anyOf_2objects:\n -';
26642664
const completion = parseSetup(content, content.length);
@@ -2672,7 +2672,7 @@ describe('Auto Completion Tests', () => {
26722672
});
26732673

26742674
it('Simple array object completion without "-" befor array empty item', (done) => {
2675-
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
2675+
const schema = require('./fixtures/testArrayCompletionSchema.json');
26762676
schemaProvider.addSchema(SCHEMA_ID, schema);
26772677
const content = 'test_simpleArrayObject:\n |\n| -'; // len: 30, pos: 26
26782678
const completion = parseSetup(content);
@@ -2685,7 +2685,7 @@ describe('Auto Completion Tests', () => {
26852685
});
26862686

26872687
it('Array anyOf two objects completion without "-" after array item', (done) => {
2688-
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
2688+
const schema = require('./fixtures/testArrayCompletionSchema.json');
26892689
schemaProvider.addSchema(SCHEMA_ID, schema);
26902690
const content = 'test_array_anyOf_2objects:\n - obj1:\n name: 1\n ';
26912691
const completion = parseSetup(content, content.length);
@@ -2697,7 +2697,7 @@ describe('Auto Completion Tests', () => {
26972697
});
26982698

26992699
it('Array nested anyOf without "-" should return all array items', (done) => {
2700-
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
2700+
const schema = require('./fixtures/testArrayCompletionSchema.json');
27012701
schemaProvider.addSchema(SCHEMA_ID, schema);
27022702
const content = 'test_array_nested_anyOf:\n - obj1:\n name:1\n ';
27032703
const completion = parseSetup(content, content.length);
@@ -2709,7 +2709,7 @@ describe('Auto Completion Tests', () => {
27092709
});
27102710

27112711
it('Array anyOf two objects completion with "-" after array item', (done) => {
2712-
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
2712+
const schema = require('./fixtures/testArrayCompletionSchema.json');
27132713
schemaProvider.addSchema(SCHEMA_ID, schema);
27142714
const content = 'test_array_anyOf_2objects:\n - obj1:\n name: 1\n -';
27152715
const completion = parseSetup(content, content.length);
@@ -2723,7 +2723,7 @@ describe('Auto Completion Tests', () => {
27232723
});
27242724

27252725
it('Array anyOf two objects completion indentation', async () => {
2726-
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
2726+
const schema = require('./fixtures/testArrayCompletionSchema.json');
27272727
schemaProvider.addSchema(SCHEMA_ID, schema);
27282728
const content = 'test_array_anyOf_2objects:\n - obj';
27292729
const completion = await parseSetup(content, content.length);

test/autoCompletionFix.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
} from './utils/testHelper';
1818
import { expect } from 'chai';
1919
import { createExpectedCompletion } from './utils/verifyError';
20-
import * as path from 'path';
2120
import { JSONSchema } from './../src/languageservice/jsonSchema';
2221

2322
describe('Auto Completion Fix Tests', () => {
@@ -200,7 +199,7 @@ spec:
200199

201200
it('should complete array', async () => {
202201
// eslint-disable-next-line @typescript-eslint/no-var-requires
203-
const schema = require(path.join(__dirname, './fixtures/test-nested-object-array.json'));
202+
const schema = require('./fixtures/test-nested-object-array.json');
204203
schemaProvider.addSchema(SCHEMA_ID, schema);
205204
const content = `objA:
206205
- name: nameA1
@@ -215,7 +214,7 @@ objB:
215214

216215
it('should complete array item for "oneOf" schema', async () => {
217216
// eslint-disable-next-line @typescript-eslint/no-var-requires
218-
const schema = require(path.join(__dirname, './fixtures/test-completion-oneOf.json'));
217+
const schema = require('./fixtures/test-completion-oneOf.json');
219218
schemaProvider.addSchema(SCHEMA_ID, schema);
220219
const content = `metadata:
221220
Selector:

test/schema.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -582,15 +582,15 @@ describe('JSON Schema', () => {
582582

583583
describe('Test schema priority', function () {
584584
// eslint-disable-next-line @typescript-eslint/no-var-requires
585-
const schemaAssociationSample = require(path.join(__dirname, './fixtures/sample-association.json'));
585+
const schemaAssociationSample = require('./fixtures/sample-association.json');
586586
// eslint-disable-next-line @typescript-eslint/no-var-requires
587-
const schemaStoreSample = require(path.join(__dirname, './fixtures/sample-schemastore.json'));
587+
const schemaStoreSample = require('./fixtures/sample-schemastore.json');
588588
// eslint-disable-next-line @typescript-eslint/no-var-requires
589-
const schemaSettingsSample = require(path.join(__dirname, './fixtures/sample-settings.json'));
589+
const schemaSettingsSample = require('./fixtures/sample-settings.json');
590590
// eslint-disable-next-line @typescript-eslint/no-var-requires
591591
const schemaModelineSample = path.join(__dirname, './fixtures/sample-modeline.json');
592592
// eslint-disable-next-line @typescript-eslint/no-var-requires
593-
const schemaDefaultSnippetSample = require(path.join(__dirname, './fixtures/defaultSnippets-const-if-else.json'));
593+
const schemaDefaultSnippetSample = require('./fixtures/defaultSnippets-const-if-else.json');
594594
const languageSettingsSetup = new ServiceSetup().withCompletion();
595595

596596
it('Modeline Schema takes precendence over all other schema APIs', async () => {

test/schemaValidation.test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
MissingRequiredPropWarning,
1717
} from './utils/errorMessages';
1818
import * as assert from 'assert';
19-
import * as path from 'path';
2019
import { Diagnostic, DiagnosticSeverity, Position } from 'vscode-languageserver-types';
2120
import { expect } from 'chai';
2221
import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings';
@@ -1486,7 +1485,7 @@ obj:
14861485
});
14871486
it('should distinguish types in error "Incorrect type (Expected "type1 | type2 | type3")"', async () => {
14881487
// eslint-disable-next-line @typescript-eslint/no-var-requires
1489-
const schema = require(path.join(__dirname, './fixtures/testMultipleSimilarSchema.json'));
1488+
const schema = require('./fixtures/testMultipleSimilarSchema.json');
14901489
schemaProvider.addSchemaWithUri(SCHEMA_ID, 'file:///sharedSchema.json', schema.sharedSchema);
14911490
schemaProvider.addSchema(SCHEMA_ID, schema.schema);
14921491
const content = 'test_anyOf_objects:\n ';
@@ -1502,7 +1501,7 @@ obj:
15021501
});
15031502
it('should combine types in "Incorrect type error"', async () => {
15041503
// eslint-disable-next-line @typescript-eslint/no-var-requires
1505-
const schema = require(path.join(__dirname, './fixtures/testMultipleSimilarSchema.json'));
1504+
const schema = require('./fixtures/testMultipleSimilarSchema.json');
15061505

15071506
schemaProvider.addSchemaWithUri(SCHEMA_ID, 'file:///sharedSchema.json', schema.sharedSchema);
15081507
schemaProvider.addSchema(SCHEMA_ID, schema.schema);
@@ -1515,7 +1514,7 @@ obj:
15151514
});
15161515
it('should combine const value', async () => {
15171516
// eslint-disable-next-line @typescript-eslint/no-var-requires
1518-
const schema = require(path.join(__dirname, './fixtures/testMultipleSimilarSchema.json'));
1517+
const schema = require('./fixtures/testMultipleSimilarSchema.json');
15191518

15201519
schemaProvider.addSchemaWithUri(SCHEMA_ID, 'file:///sharedSchema.json', schema.sharedSchema);
15211520
schemaProvider.addSchema(SCHEMA_ID, schema.schema);
@@ -1528,7 +1527,7 @@ obj:
15281527
});
15291528
it('should distinguish types in error: "Missing property from multiple schemas"', async () => {
15301529
// eslint-disable-next-line @typescript-eslint/no-var-requires
1531-
const schema = require(path.join(__dirname, './fixtures/testMultipleSimilarSchema.json'));
1530+
const schema = require('./fixtures/testMultipleSimilarSchema.json');
15321531

15331532
schemaProvider.addSchemaWithUri(sharedSchemaId, 'file:///sharedSchema.json', schema.sharedSchema);
15341533
schemaProvider.addSchema(SCHEMA_ID, schema.schema);

0 commit comments

Comments
 (0)