Skip to content

Commit 2debbdb

Browse files
authored
fix(W-19431143): Renaming sfca tools to match style guide (#167)
* fix(W-19431143): Renaming sfca tools to match style guide * fix(W-19431143): Additional styling changes
1 parent e45ead0 commit 2debbdb

File tree

4 files changed

+10
-40
lines changed

4 files changed

+10
-40
lines changed

packages/mcp-provider-code-analyzer/src/tools/sf-code-analyzer-describe-rule.ts

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,15 @@ import { DescribeRuleAction, DescribeRuleActionImpl, DescribeRuleInput, Describe
55
import { CodeAnalyzerConfigFactoryImpl } from "../factories/CodeAnalyzerConfigFactory.js";
66
import { EnginePluginsFactoryImpl } from "../factories/EnginePluginsFactory.js";
77
import { getErrorMessage } from "../utils.js";
8+
import {CodeAnalyzerRunMcpTool} from "./sf-code-analyzer-run.js";
89

910
const DESCRIPTION: string = `A tool for getting the description of a Code Analyzer rule.\n` +
1011
`This tool can return a JSON that describes the properties of a Code Analyzer rule, which may include information about\n` +
1112
`how it can be fixed.\n` +
1213
`\n` +
1314
`When to use this tool:\n` +
14-
`- When analysis results reference a rule but do not provide enough information for you to confidently fix the violation.\n` +
15-
`- When the user asks for information about a specific rule or violation.\n` +
16-
`\n` +
17-
`Parameters explained:\n` +
18-
`- ruleName: A string corresponding to the name of the rule that should be described.\n` +
19-
`- engineName: A string corresponding to the name of the engine to which the desired rule belongs.\n` +
20-
`\n` +
21-
`Output explained:\n` +
22-
`- status: A string indicating whether the operation as a whole was successful.\n` +
23-
` * In a successful run, this will be "success".\n` +
24-
` * In a failed run, this will be an error message.\n` +
25-
`- rule: A JSON containing the properties of the rule. If this property is absent, it means no such rule existed.\n` +
26-
` The JSON will have the following properties:\n` +
27-
` - name: The name of the rule. Will be equal to the "ruleName" supplied as input to the tool.\n` +
28-
` - engine: The name of the engine to which this rule belongs. Equivalent to the "engineName" input.\n` +
29-
` - severity: A number between 1 and 5 indicating the severity of the rule. Lower numbers are MORE severe.\n` +
30-
` - tags: An array of strings indicating the tags that are applicable to this rule, e.g. "performance", "security", etc.\n` +
31-
` - description: A string describing the purpose and functionality of the rule in question.\n` +
32-
` - resources: A possibly-empty array of strings indicating URLs or paths to documentation or other helpful information.\n`;
15+
`- When the results file from the ${CodeAnalyzerRunMcpTool.NAME} tool does not provide enough information to fix a violation yourself.\n` +
16+
`- When the user asks for information about a specific rule or violation.`;
3317

3418
const inputSchema = z.object({
3519
ruleName: z.string().describe('The name of a rule about which more information is required'),
@@ -52,6 +36,7 @@ type OutputArgsShape = typeof outputSchema.shape;
5236

5337

5438
export class CodeAnalyzerDescribeRuleMcpTool extends McpTool<InputArgsShape, OutputArgsShape> {
39+
public static readonly NAME: string = 'describe_code_analyzer_rule';
5540
private readonly action: DescribeRuleAction;
5641

5742
public constructor(
@@ -73,7 +58,7 @@ export class CodeAnalyzerDescribeRuleMcpTool extends McpTool<InputArgsShape, Out
7358
}
7459

7560
public getName(): string {
76-
return "sf-code-analyzer-describe-rule";
61+
return CodeAnalyzerDescribeRuleMcpTool.NAME;
7762
}
7863

7964
public getConfig(): McpToolConfig<InputArgsShape, OutputArgsShape> {

packages/mcp-provider-code-analyzer/src/tools/sf-code-analyzer-run.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,7 @@ const DESCRIPTION: string = `A tool for performing static analysis against code.
1717
`\n` +
1818
`When to use this tool:\n` +
1919
`- When the user asks you to generate files, use this tool to scan those files.\n` +
20-
`- When the user asks you to check code for problems, use this tool to do that.\n` +
21-
`\n` +
22-
`Parameters explained:\n` +
23-
`- target: An Array of absolute paths to files that should be scanned.\n` +
24-
` * This list MUST include files, and CANNOT include directories or globs.\n` +
25-
` * ALL files included in this array must actually exist on the user's machine.\n` +
26-
` * The array MUST be non-empty.\n` +
27-
` * The array can contain a MAXIMUM of ${MAX_ALLOWABLE_TARGET_COUNT} entries. If there are more than ten files to scan, the tool should be called multiple times.\n` +
28-
`\n` +
29-
`Output explained:\n` +
30-
`- status: A string indicating whether the operation as a whole was successful.\n` +
31-
` * In a successful run, this will be "success".\n` +
32-
` * In a failed run, this will be an error message.\n` +
33-
`- resultsFile: The absolute path to the results file. Read from this file to see what violations were found in the\n` +
34-
` target files, so that either you or the user can fix them.\n` +
35-
` * If the analysis finished successfully, this property will be present.\n` +
36-
` * If the analysis failed, then this property will be absent.\n`;
20+
`- When the user asks you to check code for problems, use this tool to do that.\n`;
3721

3822
const inputSchema = z.object({
3923
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.`)
@@ -48,6 +32,7 @@ type OutputArgsShape = typeof outputSchema.shape;
4832

4933

5034
export class CodeAnalyzerRunMcpTool extends McpTool<InputArgsShape, OutputArgsShape> {
35+
public static readonly NAME: string = 'run_code_analyzer';
5136
private readonly action: RunAnalyzerAction;
5237

5338
public constructor(
@@ -69,7 +54,7 @@ export class CodeAnalyzerRunMcpTool extends McpTool<InputArgsShape, OutputArgsSh
6954
}
7055

7156
public getName(): string {
72-
return "sf-code-analyzer-run";
57+
return CodeAnalyzerRunMcpTool.NAME;
7358
}
7459

7560
public getConfig(): McpToolConfig<InputArgsShape, OutputArgsShape> {

packages/mcp-provider-code-analyzer/test/tools/describe-rule-tool.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe("Tests for DescribeRuleTool", () => {
1919
});
2020

2121
it("When getName is called, then 'sf-example' is returned", () => {
22-
expect(tool.getName()).toEqual('sf-code-analyzer-describe-rule');
22+
expect(tool.getName()).toEqual('describe_code_analyzer_rule');
2323
});
2424

2525
it("When getConfig is called, then the correct configuration is returned", () => {

packages/mcp-provider-code-analyzer/test/tools/sf-code-analyzer-run.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe("Tests for CodeAnalyzerRunMcpTool", () => {
2626
});
2727

2828
it("When getName is called, then 'sf-example' is returned", () => {
29-
expect(tool.getName()).toEqual('sf-code-analyzer-run');
29+
expect(tool.getName()).toEqual('run_code_analyzer');
3030
});
3131

3232
it("When getConfig is called, then the correct configuration is returned", () => {

0 commit comments

Comments
 (0)