[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6F504VBCBDC956BEVT5SVSC":3,"skill-same:01M6F504VBCBDC956BEVT5SVSC":59},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":31,"linkOnly":32,"markdownContent":33,"markdownBody":34,"frontMatter":35,"refName":36,"commitSha":37,"skillDirectory":38,"forksCount":39,"repositoryHtmlUrl":40,"repositoryHomepageUrl":41,"ownerHtmlUrl":42,"ownerBlogUrl":6,"ownerDescription":43,"updatedAt":44,"install":45,"resources":58},"01M6F504VBCBDC956BEVT5SVSC","refactor-method-complexity-reduce",null,"Refactor given method `${input:methodName}` to reduce its cognitive complexity to `${input:complexityThreshold}` or below, by extracting helper methods.","ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",66,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fgithub\u002Fawesome-copilot\u002Frefactor-method-complexity-reduce\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000007","代码审查","SCENARIO","使用场景",[24,25,26,27,28,29,30],"refactor method complexity reduce","refactor","complexity","methods","input","helper","extracting","2026-11-10 10:12:30",false,"---\nname: refactor-method-complexity-reduce\ndescription: 'Refactor given method `${input:methodName}` to reduce its cognitive complexity to `${input:complexityThreshold}` or below, by extracting helper methods.'\n---\n\n# Refactor Method to Reduce Cognitive Complexity\n\n## Objective\nRefactor the method `${input:methodName}`, to reduce its cognitive complexity to `${input:complexityThreshold}` or below, by extracting logic into focused helper methods.\n\n## Instructions\n\n1. **Analyze the current method** to identify sources of cognitive complexity:\n   - Nested conditional statements\n   - Multiple if-else or switch chains\n   - Repeated code blocks\n   - Multiple loops with conditions\n   - Complex boolean expressions\n\n2. **Identify extraction opportunities**:\n   - Validation logic that can be extracted into a separate method\n   - Type-specific or case-specific processing that repeats\n   - Complex transformations or calculations\n   - Common patterns that appear multiple times\n\n3. **Extract focused helper methods**:\n   - Each helper should have a single, clear responsibility\n   - Extract validation into separate `Validate*` methods\n   - Extract type-specific logic into handler methods\n   - Create utility methods for common operations\n   - Use appropriate access levels (static, private, async)\n\n4. **Simplify the main method**:\n   - Reduce nesting depth\n   - Replace massive if-else chains with smaller orchestrated calls\n   - Use switch statements where appropriate for cleaner dispatch\n   - Ensure the main method reads as a high-level flow\n\n5. **Preserve functionality**:\n   - Maintain the same input\u002Foutput behavior\n   - Keep all validation and error handling\n   - Preserve exception types and error messages\n   - Ensure all parameters are properly passed to helpers\n\n6. **Best practices**:\n   - Make helper methods static when they don't need instance state\n   - Use null checks and guard clauses early\n   - Avoid creating unnecessary local variables\n   - Consider using tuples for multiple return values\n   - Group related helper methods together\n\n## Implementation Approach\n\n- Extract helper methods before refactoring the main flow\n- Test incrementally to ensure no regressions\n- Use meaningful names that describe the extracted responsibility\n- Keep extracted methods close to where they're used\n- Consider making repeated code patterns into generic methods\n\n## Result\n\nThe refactored method should:\n- Have cognitive complexity reduced to the target threshold of `${input:complexityThreshold}` or below\n- Be more readable and maintainable\n- Have clear separation of concerns\n- Be easier to test and debug\n- Retain all original functionality\n\n## Testing and Validation\n\n**CRITICAL: After completing the refactoring, you MUST:**\n\n1. **Run all existing tests** related to the refactored method and its surrounding functionality\n2. **MANDATORY: Explicitly verify test results show \"failed=0\"**\n   - **NEVER assume tests passed** - always examine the actual test output\n   - Search for the summary line containing pass\u002Ffail counts (e.g., \"passed=X failed=Y\")\n   - **If the summary shows any number other than \"failed=0\", tests have FAILED**\n   - If test output is in a file, read the entire file to locate and verify the failure count\n   - Running tests is NOT the same as verifying tests passed\n   - **Do not proceed** until you have explicitly confirmed zero failures\n3. **If any tests fail (failed > 0):**\n   - State clearly how many tests failed\n   - Analyze each failure to understand what functionality was broken\n   - Common causes: null handling, empty collection checks, condition logic errors\n   - Identify the root cause in the refactored code\n   - Correct the refactored code to restore the original behavior\n   - Re-run tests and verify \"failed=0\" in the output\n   - Repeat until all tests pass (failed=0)\n4. **Verify compilation** - Ensure there are no compilation errors\n5. **Check cognitive complexity** - Confirm the metric is at or below the target threshold of `${input:complexityThreshold}`\n\n## Confirmation Checklist\n- [ ] Code compiles without errors\n- [ ] **Test results explicitly state \"failed=0\"** (verified by reading the output)\n- [ ] All test failures analyzed and corrected (if any occurred)\n- [ ] Cognitive complexity is at or below the target threshold of `${input:complexityThreshold}`\n- [ ] All original functionality is preserved\n- [ ] Code follows project conventions and standards\n\n","# Refactor Method to Reduce Cognitive Complexity\n\n## Objective\nRefactor the method `${input:methodName}`, to reduce its cognitive complexity to `${input:complexityThreshold}` or below, by extracting logic into focused helper methods.\n\n## Instructions\n\n1. **Analyze the current method** to identify sources of cognitive complexity:\n   - Nested conditional statements\n   - Multiple if-else or switch chains\n   - Repeated code blocks\n   - Multiple loops with conditions\n   - Complex boolean expressions\n\n2. **Identify extraction opportunities**:\n   - Validation logic that can be extracted into a separate method\n   - Type-specific or case-specific processing that repeats\n   - Complex transformations or calculations\n   - Common patterns that appear multiple times\n\n3. **Extract focused helper methods**:\n   - Each helper should have a single, clear responsibility\n   - Extract validation into separate `Validate*` methods\n   - Extract type-specific logic into handler methods\n   - Create utility methods for common operations\n   - Use appropriate access levels (static, private, async)\n\n4. **Simplify the main method**:\n   - Reduce nesting depth\n   - Replace massive if-else chains with smaller orchestrated calls\n   - Use switch statements where appropriate for cleaner dispatch\n   - Ensure the main method reads as a high-level flow\n\n5. **Preserve functionality**:\n   - Maintain the same input\u002Foutput behavior\n   - Keep all validation and error handling\n   - Preserve exception types and error messages\n   - Ensure all parameters are properly passed to helpers\n\n6. **Best practices**:\n   - Make helper methods static when they don't need instance state\n   - Use null checks and guard clauses early\n   - Avoid creating unnecessary local variables\n   - Consider using tuples for multiple return values\n   - Group related helper methods together\n\n## Implementation Approach\n\n- Extract helper methods before refactoring the main flow\n- Test incrementally to ensure no regressions\n- Use meaningful names that describe the extracted responsibility\n- Keep extracted methods close to where they're used\n- Consider making repeated code patterns into generic methods\n\n## Result\n\nThe refactored method should:\n- Have cognitive complexity reduced to the target threshold of `${input:complexityThreshold}` or below\n- Be more readable and maintainable\n- Have clear separation of concerns\n- Be easier to test and debug\n- Retain all original functionality\n\n## Testing and Validation\n\n**CRITICAL: After completing the refactoring, you MUST:**\n\n1. **Run all existing tests** related to the refactored method and its surrounding functionality\n2. **MANDATORY: Explicitly verify test results show \"failed=0\"**\n   - **NEVER assume tests passed** - always examine the actual test output\n   - Search for the summary line containing pass\u002Ffail counts (e.g., \"passed=X failed=Y\")\n   - **If the summary shows any number other than \"failed=0\", tests have FAILED**\n   - If test output is in a file, read the entire file to locate and verify the failure count\n   - Running tests is NOT the same as verifying tests passed\n   - **Do not proceed** until you have explicitly confirmed zero failures\n3. **If any tests fail (failed > 0):**\n   - State clearly how many tests failed\n   - Analyze each failure to understand what functionality was broken\n   - Common causes: null handling, empty collection checks, condition logic errors\n   - Identify the root cause in the refactored code\n   - Correct the refactored code to restore the original behavior\n   - Re-run tests and verify \"failed=0\" in the output\n   - Repeat until all tests pass (failed=0)\n4. **Verify compilation** - Ensure there are no compilation errors\n5. **Check cognitive complexity** - Confirm the metric is at or below the target threshold of `${input:complexityThreshold}`\n\n## Confirmation Checklist\n- [ ] Code compiles without errors\n- [ ] **Test results explicitly state \"failed=0\"** (verified by reading the output)\n- [ ] All test failures analyzed and corrected (if any occurred)\n- [ ] Cognitive complexity is at or below the target threshold of `${input:complexityThreshold}`\n- [ ] All original functionality is preserved\n- [ ] Code follows project conventions and standards\n\n",{"name":5,"description":7},"main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Fgithub\u002Fawesome-copilot\u002Frefactor-method-complexity-reduce",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":8,"skillName":5,"commands":46,"prompt":56,"zipAvailable":57},[47,50,53],{"tool":48,"command":49},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill refactor-method-complexity-reduce",{"tool":51,"command":52},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill refactor-method-complexity-reduce",{"tool":54,"command":55},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill refactor-method-complexity-reduce","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fgithub\u002Fawesome-copilot\u002Frefactor-method-complexity-reduce\u002FSKILL.md",true,[],[60,72,82,91,97,104],{"skillNo":61,"name":62,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":68,"publishedAt":31},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[65],{"categoryNo":66,"categoryName":67,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[69,70,71],"model","model hierarchy","model hierarchy skill",{"skillNo":73,"name":74,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":78,"publishedAt":31},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[77],{"categoryNo":66,"categoryName":67,"taxonomyType":21,"taxonomyTypeDesc":22},[79,80,81],"MCP","zoom","zoom mcp",{"skillNo":83,"name":84,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":31},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[88,89,90,80],"sdk","zoom apps sdk","apps",{"skillNo":92,"name":93,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":31},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[93],{"skillNo":98,"name":99,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":103,"publishedAt":31},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[102],{"categoryNo":66,"categoryName":67,"taxonomyType":21,"taxonomyTypeDesc":22},[99],{"skillNo":105,"name":106,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":31},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[106]]