Remove redundant code patterns that add complexity without value. This includes: 1. Duplicate code blocks - Extract shared logic into reusable functions
Remove redundant code patterns that add complexity without value. This includes:
Example of simplifying control flow:
// Before
if (filename.endsWith(PROMPT_FILE_EXTENSION)) {
return filename.slice(0, -PROMPT_FILE_EXTENSION.length);
} else if (filename.endsWith(INSTRUCTION_FILE_EXTENSION)) {
return filename.slice(0, -INSTRUCTION_FILE_EXTENSION.length);
} else if (filename === COPILOT_CUSTOM_INSTRUCTIONS_FILENAME) {
return filename.slice(0, -3);
}
// After
if (filename.endsWith(PROMPT_FILE_EXTENSION)) {
return filename.slice(0, -PROMPT_FILE_EXTENSION.length);
}
if (filename.endsWith(INSTRUCTION_FILE_EXTENSION)) {
return filename.slice(0, -INSTRUCTION_FILE_EXTENSION.length);
}
if (filename === COPILOT_CUSTOM_INSTRUCTIONS_FILENAME) {
return filename.slice(0, -3);
}
For repeated patterns, extract into helper functions:
// Before
const FAILED_TASK_STATUS = { icon: { ...Codicon.error, color: { id: problemsErrorIconForeground } }};
const WARNING_TASK_STATUS = { icon: { ...Codicon.warning, color: { id: problemsWarningIconForeground } }};
// After
const createColoredIcon = (icon: Codicon, colorId: string) => ({ ...icon, color: { id: colorId }});
const FAILED_TASK_STATUS = { icon: createColoredIcon(Codicon.error, problemsErrorIconForeground) };
const WARNING_TASK_STATUS = { icon: createColoredIcon(Codicon.warning, problemsWarningIconForeground) };
Enter the URL of a public GitHub repository