Skip to content

Commit 3d91202

Browse files
authored
fix: @W-19772910@ Fixed issue with relative paths (#291)
* @W-19772910@ Fixed issue with relative paths * @W-19772910@ Fixed failing tests
1 parent 34f8e51 commit 3d91202

11 files changed

+109
-71
lines changed

packages/mcp-provider-code-analyzer/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
"types": "dist/index.d.ts",
1515
"dependencies": {
1616
"@modelcontextprotocol/sdk": "^1.18.0",
17-
"@salesforce/code-analyzer-core": "^0.35.0",
18-
"@salesforce/code-analyzer-engine-api": "^0.29.0",
19-
"@salesforce/code-analyzer-eslint-engine": "^0.31.0",
20-
"@salesforce/code-analyzer-pmd-engine": "^0.30.0",
21-
"@salesforce/code-analyzer-regex-engine": "^0.27.0",
22-
"@salesforce/code-analyzer-retirejs-engine": "^0.26.0",
17+
"@salesforce/code-analyzer-core": "^0.38.0",
18+
"@salesforce/code-analyzer-engine-api": "^0.30.0",
19+
"@salesforce/code-analyzer-eslint-engine": "^0.34.0",
20+
"@salesforce/code-analyzer-pmd-engine": "^0.31.0",
21+
"@salesforce/code-analyzer-regex-engine": "^0.28.0",
22+
"@salesforce/code-analyzer-retirejs-engine": "^0.27.0",
2323
"@salesforce/mcp-test-client": "0.0.1",
2424
"@salesforce/mcp-provider-api": "^0.4.0",
2525
"zod": "^3.25.76"
Binary file not shown.

packages/mcp-provider-code-analyzer/src/tools/run_code_analyzer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const DESCRIPTION: string = `A tool for performing static analysis against code.
2020
`- When the user asks you to check code for problems, use this tool to do that.\n`;
2121

2222
export const inputSchema = z.object({
23-
target: z.array(z.string()).describe(`A JSON-formatted array of between 1 and ${MAX_ALLOWABLE_TARGET_COUNT} files on the users machine that should be scanned.`)
23+
target: z.array(z.string()).describe(`A JSON-formatted array of between 1 and ${MAX_ALLOWABLE_TARGET_COUNT} files on the users machine that should be scanned. These paths MUST be ABSOLUTE paths, and not relative paths.`)
2424
});
2525
type InputArgsShape = typeof inputSchema.shape;
2626

packages/mcp-provider-code-analyzer/test/actions/run-analyzer.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,16 @@ describe('RunAnalyzerActionImpl', () => {
218218
const pathSepVar: string = path.sep.replaceAll('\\', '\\\\');
219219
const runDir: string = process.cwd().replaceAll('\\' , '\\\\');
220220

221+
const codeAnalyzerVersion: string = (JSON.parse((await fs.promises.readFile(path.join(require.resolve('@salesforce/code-analyzer-core'), '..', '..', 'package.json'), 'utf-8'))) as any).version;
222+
const pmdEngineVersion: string = (JSON.parse((await fs.promises.readFile(path.join(require.resolve('@salesforce/code-analyzer-pmd-engine'), '..', '..', 'package.json'), 'utf-8'))) as any).version;
223+
const regexEngineVersion: string = (JSON.parse((await fs.promises.readFile(path.join(require.resolve('@salesforce/code-analyzer-regex-engine'), '..', '..', 'package.json'), 'utf-8'))) as any).version;
224+
221225
const expectedOutfile: string = (await fs.promises.readFile(comparisonFile, 'utf-8'))
222226
.replaceAll('{{RUNDIR}}', runDir)
223227
.replaceAll(`{{SEP}}`, pathSepVar)
228+
.replaceAll('{{CODE_ANALYZER_VERSION}}', codeAnalyzerVersion)
229+
.replaceAll('{{PMD_ENGINE_VERSION}}', pmdEngineVersion)
230+
.replaceAll('{{REGEX_ENGINE_VERSION}}', regexEngineVersion)
224231
.replaceAll('{{PMD_VERSION}}', PMD_VERSION);
225232

226233
expect(outputFileContents).toContain(expectedOutfile);

packages/mcp-provider-code-analyzer/test/fixtures/comparison-files/UnexpectedEngineError-violation.goldfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"sev5": 0
1010
},
1111
"versions": {
12-
"code-analyzer": "0.35.0",
12+
"code-analyzer": "{{CODE_ANALYZER_VERSION}}",
1313
"UnrunnableEngine": "1.0.0"
1414
},
1515
"violations": [

packages/mcp-provider-code-analyzer/test/fixtures/comparison-files/UninstantiableEngineError-for-EngineThatCannotReturnRules.goldfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"sev5": 0
1010
},
1111
"versions": {
12-
"code-analyzer": "0.35.0",
12+
"code-analyzer": "{{CODE_ANALYZER_VERSION}}",
1313
"EngineThatCannotReturnRules": "unknown"
1414
},
1515
"violations": [

packages/mcp-provider-code-analyzer/test/fixtures/comparison-files/invalid-pmd-config-violation.goldfile.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"sev5": 0
1010
},
1111
"versions": {
12-
"code-analyzer": "0.35.0",
13-
"cpd": "0.30.0",
14-
"regex": "0.27.0",
12+
"code-analyzer": "{{CODE_ANALYZER_VERSION}}",
13+
"cpd": "{{PMD_ENGINE_VERSION}}",
14+
"regex": "{{REGEX_ENGINE_VERSION}}",
1515
"pmd": "unknown"
1616
},
1717
"violations": [

packages/mcp-provider-code-analyzer/test/fixtures/comparison-files/no-custom-engine-violations.goldfile.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"sev5": 0
1010
},
1111
"versions": {
12-
"code-analyzer": "0.35.0",
12+
"code-analyzer": "{{CODE_ANALYZER_VERSION}}",
1313
"EngineThatLogsError": "1.0.0"
1414
},
1515
"violations": []

packages/mcp-provider-code-analyzer/test/fixtures/comparison-files/no-pmd-violations.goldfile.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"sev5": 0
1010
},
1111
"versions": {
12-
"code-analyzer": "0.35.0",
13-
"pmd": "0.30.0",
14-
"regex": "0.27.0"
12+
"code-analyzer": "{{CODE_ANALYZER_VERSION}}",
13+
"pmd": "{{PMD_ENGINE_VERSION}}",
14+
"regex": "{{REGEX_ENGINE_VERSION}}"
1515
},
1616
"violations": []
1717
}

packages/mcp-provider-code-analyzer/test/fixtures/comparison-files/violations-in-ApexTarget2-cls.goldfile.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"sev5": 0
1010
},
1111
"versions": {
12-
"code-analyzer": "0.35.0",
13-
"pmd": "0.30.0",
14-
"regex": "0.27.0"
12+
"code-analyzer": "{{CODE_ANALYZER_VERSION}}",
13+
"pmd": "{{PMD_ENGINE_VERSION}}",
14+
"regex": "{{REGEX_ENGINE_VERSION}}"
1515
},
1616
"violations": [
1717
{

0 commit comments

Comments
 (0)