スキル一覧に戻る
mgreenly

refactoringsmells

by mgreenly

An AI Coding Agent

1🍴 0📅 2026年1月24日
GitHubで見るManusで実行

SKILL.md


name: refactoring/smells description: Code Smells refactoring skill

Code Smells

Checklist of code smells to identify during refactoring. Both generic C issues and ikigai-specific violations.

Generic C Code Smells

Function-Level

SmellSignalAction
Long function>50 linesExtract functions by responsibility
Deep nesting>3 levelsExtract inner logic, use early returns
Long parameter list>4 paramsIntroduce parameter object (struct)
Magic numbersLiteral values in logicDefine named constants
Duplicate codeCopy-pasted blocksExtract shared function
Comments explaining what// increment counterRename to be self-documenting
Dead codeUnreachable branchesDelete it
Complex conditionalsif (a && b || c && !d)Extract to named boolean or function

Structural

SmellSignalAction
God structStruct with 10+ fieldsSplit by responsibility
Feature envyFunction uses another module's data extensivelyMove function to that module
Primitive obsessionPassing raw char*, int everywhereIntroduce domain types
Shotgun surgeryOne change requires editing many filesConsolidate related code
Divergent changeOne file changes for unrelated reasonsSplit by responsibility

ikigai-Specific Violations

Naming

ViolationExampleFix
Missing ik_ prefixconfig_load()ik_cfg_load()
Wrong abbreviationik_configuration_load()ik_cfg_load() (use approved abbrev)
Inconsistent module prefixik_config_load() vs ik_cfg_parse()Pick one, use consistently
Missing _ptr suffixbool *visible; (raw pointer)bool *visible_ptr;
Missing g_ prefixvolatile sig_atomic_t shutdown;g_shutdown

Error Handling

ViolationExampleFix
Unchecked res_tik_cfg_load(...); use(cfg);TRY(ik_cfg_load(...)) or check is_err()
Wrong mechanismif (!ptr) return ERR(...) for OOMOOM → PANIC(), not res_t
assert for runtimeassert(file_exists(path))External input → res_t, not assert
Missing LCOV markerif (!ptr) PANIC("OOM");Add // LCOV_EXCL_BR_LINE
Error on wrong contextERR(tmp, ...) before talloc_free(tmp)Use parent context for errors

Memory (talloc)

ViolationExampleFix
malloc instead of tallocchar *buf = malloc(size);talloc_array(ctx, char, size)
Missing parenttalloc_new(NULL) in non-mainPass parent context from caller
Orphaned allocationtalloc(ctx, ...) never freed/stolenAttach to proper parent or free
Hidden allocationFunction mallocs internallyAccept TALLOC_CTX* parameter

Dependency Injection

ViolationExampleFix
Global statestatic config_t *g_config;Pass config as parameter
Hidden I/Oload_from_disk() inside initLoad externally, pass data in
Service locatorget_service("db")Pass db_t* parameter
Constructor does workinit() opens files, connectsAccept opened resources as params

Style

ViolationExampleFix
Block comment/* comment */// comment
Primitive typeint count;int32_t count;
Wrong include orderSystem before project headersProject headers first
static helper functionstatic void helper() {...}Inline at call site

Investigation Workflow

  1. Scan for patterns - Use grep/search for smell signals
  2. Triage by impact - Fix high-frequency smells first
  3. Verify with tests - Ensure refactoring doesn't break behavior
  4. One smell at a time - Don't mix refactoring types in one commit

スコア

総合スコア

60/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です