def assert_valid_rule_class(clazz):
<EOL>if not (issubclass(clazz, rules.LineRule) or issubclass(clazz, rules.CommitRule)):<EOL><INDENT>msg = u"<STR_LIT>"<EOL>raise UserRuleError(msg.format(clazz.__name__, rules.CommitRule.__module__,<EOL>rules.LineRule.__name__, rules.CommitRule.__name__))<EOL><DEDENT>if not hasattr(clazz, '<STR_LIT:id>') or clazz.id is None or not clazz.id:<EOL><INDENT>raise UserRuleError(u"<STR_LIT>".format(clazz.__name__))<EOL><DEDENT>if clazz.id[<NUM_LIT:0>].upper() in ['<STR_LIT:R>', '<STR_LIT:T>', '<STR_LIT:B>', '<STR_LIT:M>']:<EOL><INDENT>msg = u"<STR_LIT>"<EOL>raise UserRuleError(msg.format(clazz.__name__, clazz.id[<NUM_LIT:0>]))<EOL><DEDENT>if not hasattr(clazz, '<STR_LIT:name>') or clazz.name is None or not clazz.name:<EOL><INDENT>raise UserRuleError(u"<STR_LIT>".format(clazz.__name__))<EOL><DEDENT>if not isinstance(clazz.options_spec, list):<EOL><INDENT>msg = u"<STR_LIT>"<EOL>raise UserRuleError(msg.format(clazz.__name__, options.RuleOption.__module__, options.RuleOption.__name__))<EOL><DEDENT>for option in clazz.options_spec:<EOL><INDENT>if not isinstance(option, options.RuleOption):<EOL><INDENT>msg = u"<STR_LIT>"<EOL>raise UserRuleError(msg.format(clazz.__name__, options.RuleOption.__module__, options.RuleOption.__name__))<EOL><DEDENT><DEDENT>if not hasattr(clazz, '<STR_LIT>') or not inspect.isroutine(clazz.validate):<EOL><INDENT>raise UserRuleError(u"<STR_LIT>".format(clazz.__name__))<EOL><DEDENT>if issubclass(clazz, rules.LineRule):<EOL><INDENT>if clazz.target not in [rules.CommitMessageTitle, rules.CommitMessageBody]:<EOL><INDENT>msg = u"<STR_LIT>"<EOL>msg = msg.format(clazz.__name__, rules.CommitMessageTitle.__module__,<EOL>rules.CommitMessageTitle.__name__, rules.CommitMessageBody.__name__)<EOL>raise UserRuleError(msg)<EOL><DEDENT><DEDENT>
Asserts that a given rule clazz is valid by checking a number of its properties:
 - Rules must extend from  LineRule or CommitRule
 - Rule classes must have id and name string attributes.
   The options_spec is optional, but if set, it must be a list of gitlint Options.
 - Rule classes must have a validate method. In case of a CommitRule, validate must take a single commit parameter.
   In case of LineRule, validate must take line and commit as first and second parameters.
 - LineRule classes must have a target class attributes that is set to either
   CommitMessageTitle or CommitMessageBody.
 - User Rule id's cannot start with R, T, B or M as these rule ids are reserved for gitlint itself.