{
  "ruleId": "C012",
  "name": "Command Query Separation",
  "description": "Separate commands (modify state) from queries (return data)",
  "category": "architecture",
  "severity": "warning",
  "languages": ["typescript", "javascript", "dart"],
  "enabled": true,
  "version": "1.0.0",
  "status": "stable",
  "tags": ["architecture", "cqs", "design-pattern", "separation-of-concerns"],
  "config": {
    "commandIndicators": [
      "set", "update", "delete", "remove", "add", "insert",
      "save", "store", "persist", "write", "modify", "mutate",
      "push", "pop", "shift", "unshift", "splice"
    ],
    "queryIndicators": [
      "get", "find", "fetch", "retrieve", "load", "read",
      "calculate", "compute", "is", "has", "can", "should"
    ],
    "allowedExceptions": [
      "pop", "shift", "splice"
    ]
  },
  "examples": {
    "violations": [
      {
        "language": "typescript",
        "code": "function updateAndGetUser(id: string, data: any): User { this.update(id, data); return this.findById(id); }",
        "reason": "Function both modifies state and returns data"
      },
      {
        "language": "dart",
        "code": "User saveAndReturn(User user) { _repository.save(user); return user; }",
        "reason": "Method performs command (save) and query (return) operations"
      }
    ],
    "valid": [
      {
        "language": "typescript",
        "code": "function updateUser(id: string, data: any): void { this.update(id, data); }",
        "reason": "Pure command - modifies state, returns void"
      },
      {
        "language": "typescript",
        "code": "function getUser(id: string): User { return this.findById(id); }",
        "reason": "Pure query - only returns data, no side effects"
      }
    ]
  },
  "fixes": {
    "autoFixable": false,
    "suggestions": [
      "Split function into separate command and query methods",
      "Command methods should return void or Task/Future<void>",
      "Query methods should be pure and have no side effects",
      "Use events or callbacks for commands that need to notify callers"
    ]
  }
}
