Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
id = "B5"
options_spec = [IntOption('min-length', 20, "Minimum body length")]
def validate(self, commit):
min_length = self.options['min-length'].value
body_message_no_newline = "".join([line for line in commit.message.body if line is not None])
actual_length = len(body_message_no_newline)
if 0 < actual_length < min_length:
violation_message = "Body message is too short ({0}<{1})".format(actual_length, min_length)
return [RuleViolation(self.id, violation_message, body_message_no_newline, 3)]
class BodyMissing(CommitRule):
name = "body-is-missing"
id = "B6"
options_spec = [BoolOption('ignore-merge-commits', True, "Ignore merge commits")]
def validate(self, commit):
# ignore merges when option tells us to, which may have no body
if self.options['ignore-merge-commits'].value and commit.is_merge_commit:
return
if len(commit.message.body) < 2:
return [RuleViolation(self.id, "Body message is missing", None, 3)]
class BodyChangedFileMention(CommitRule):
name = "body-changed-file-mention"
id = "B7"
options_spec = [ListOption('files', [], "Files that need to be mentioned")]
def validate(self, commit):
violations = []
self.rules = RuleCollection(self.default_rule_classes)
self._verbosity = options.IntOption('verbosity', 3, "Verbosity")
self._ignore_merge_commits = options.BoolOption('ignore-merge-commits', True, "Ignore merge commits")
self._ignore_fixup_commits = options.BoolOption('ignore-fixup-commits', True, "Ignore fixup commits")
self._ignore_squash_commits = options.BoolOption('ignore-squash-commits', True, "Ignore squash commits")
self._ignore_revert_commits = options.BoolOption('ignore-revert-commits', True, "Ignore revert commits")
self._debug = options.BoolOption('debug', False, "Enable debug mode")
self._extra_path = None
target_description = "Path of the target git repository (default=current working directory)"
self._target = options.PathOption('target', os.path.realpath(os.getcwd()), target_description)
self._ignore = options.ListOption('ignore', [], 'List of rule-ids to ignore')
self._contrib = options.ListOption('contrib', [], 'List of contrib-rules to enable')
self._config_path = None
ignore_stdin_description = "Ignore any stdin data. Useful for running in CI server."
self._ignore_stdin = options.BoolOption('ignore-stdin', False, ignore_stdin_description)
self._staged = options.BoolOption('staged', False, "Read staged commit meta-info from the local repository.")
def __init__(self):
self.rules = RuleCollection(self.default_rule_classes)
self._verbosity = options.IntOption('verbosity', 3, "Verbosity")
self._ignore_merge_commits = options.BoolOption('ignore-merge-commits', True, "Ignore merge commits")
self._ignore_fixup_commits = options.BoolOption('ignore-fixup-commits', True, "Ignore fixup commits")
self._ignore_squash_commits = options.BoolOption('ignore-squash-commits', True, "Ignore squash commits")
self._ignore_revert_commits = options.BoolOption('ignore-revert-commits', True, "Ignore revert commits")
self._debug = options.BoolOption('debug', False, "Enable debug mode")
self._extra_path = None
target_description = "Path of the target git repository (default=current working directory)"
self._target = options.PathOption('target', os.path.realpath(os.getcwd()), target_description)
self._ignore = options.ListOption('ignore', [], 'List of rule-ids to ignore')
self._contrib = options.ListOption('contrib', [], 'List of contrib-rules to enable')
self._config_path = None
ignore_stdin_description = "Ignore any stdin data. Useful for running in CI server."
self._ignore_stdin = options.BoolOption('ignore-stdin', False, ignore_stdin_description)
self._staged = options.BoolOption('staged', False, "Read staged commit meta-info from the local repository.")
def __init__(self):
self.rules = RuleCollection(self.default_rule_classes)
self._verbosity = options.IntOption('verbosity', 3, "Verbosity")
self._ignore_merge_commits = options.BoolOption('ignore-merge-commits', True, "Ignore merge commits")
self._ignore_fixup_commits = options.BoolOption('ignore-fixup-commits', True, "Ignore fixup commits")
self._ignore_squash_commits = options.BoolOption('ignore-squash-commits', True, "Ignore squash commits")
self._ignore_revert_commits = options.BoolOption('ignore-revert-commits', True, "Ignore revert commits")
self._debug = options.BoolOption('debug', False, "Enable debug mode")
self._extra_path = None
target_description = "Path of the target git repository (default=current working directory)"
self._target = options.PathOption('target', os.path.realpath(os.getcwd()), target_description)
self._ignore = options.ListOption('ignore', [], 'List of rule-ids to ignore')
self._contrib = options.ListOption('contrib', [], 'List of contrib-rules to enable')
self._config_path = None
ignore_stdin_description = "Ignore any stdin data. Useful for running in CI server."
self._ignore_stdin = options.BoolOption('ignore-stdin', False, ignore_stdin_description)
self._staged = options.BoolOption('staged', False, "Read staged commit meta-info from the local repository.")
def __init__(self):
self.rules = RuleCollection(self.default_rule_classes)
self._verbosity = options.IntOption('verbosity', 3, "Verbosity")
self._ignore_merge_commits = options.BoolOption('ignore-merge-commits', True, "Ignore merge commits")
self._ignore_fixup_commits = options.BoolOption('ignore-fixup-commits', True, "Ignore fixup commits")
self._ignore_squash_commits = options.BoolOption('ignore-squash-commits', True, "Ignore squash commits")
self._ignore_revert_commits = options.BoolOption('ignore-revert-commits', True, "Ignore revert commits")
self._debug = options.BoolOption('debug', False, "Enable debug mode")
self._extra_path = None
target_description = "Path of the target git repository (default=current working directory)"
self._target = options.PathOption('target', os.path.realpath(os.getcwd()), target_description)
self._ignore = options.ListOption('ignore', [], 'List of rule-ids to ignore')
self._contrib = options.ListOption('contrib', [], 'List of contrib-rules to enable')
self._config_path = None
ignore_stdin_description = "Ignore any stdin data. Useful for running in CI server."
self._ignore_stdin = options.BoolOption('ignore-stdin', False, ignore_stdin_description)
self._staged = options.BoolOption('staged', False, "Read staged commit meta-info from the local repository.")
def __init__(self):
self.rules = RuleCollection(self.default_rule_classes)
self._verbosity = options.IntOption('verbosity', 3, "Verbosity")
self._ignore_merge_commits = options.BoolOption('ignore-merge-commits', True, "Ignore merge commits")
self._ignore_fixup_commits = options.BoolOption('ignore-fixup-commits', True, "Ignore fixup commits")
self._ignore_squash_commits = options.BoolOption('ignore-squash-commits', True, "Ignore squash commits")
self._ignore_revert_commits = options.BoolOption('ignore-revert-commits', True, "Ignore revert commits")
self._debug = options.BoolOption('debug', False, "Enable debug mode")
self._extra_path = None
target_description = "Path of the target git repository (default=current working directory)"
self._target = options.PathOption('target', os.path.realpath(os.getcwd()), target_description)
self._ignore = options.ListOption('ignore', [], 'List of rule-ids to ignore')
self._contrib = options.ListOption('contrib', [], 'List of contrib-rules to enable')
self._config_path = None
ignore_stdin_description = "Ignore any stdin data. Useful for running in CI server."
self._ignore_stdin = options.BoolOption('ignore-stdin', False, ignore_stdin_description)
self._staged = options.BoolOption('staged', False, "Read staged commit meta-info from the local repository.")
def __init__(self):
self.rules = RuleCollection(self.default_rule_classes)
self._verbosity = options.IntOption('verbosity', 3, "Verbosity")
self._ignore_merge_commits = options.BoolOption('ignore-merge-commits', True, "Ignore merge commits")
self._ignore_fixup_commits = options.BoolOption('ignore-fixup-commits', True, "Ignore fixup commits")
self._ignore_squash_commits = options.BoolOption('ignore-squash-commits', True, "Ignore squash commits")
self._ignore_revert_commits = options.BoolOption('ignore-revert-commits', True, "Ignore revert commits")
self._debug = options.BoolOption('debug', False, "Enable debug mode")
self._extra_path = None
target_description = "Path of the target git repository (default=current working directory)"
self._target = options.PathOption('target', os.path.realpath(os.getcwd()), target_description)
self._ignore = options.ListOption('ignore', [], 'List of rule-ids to ignore')
self._contrib = options.ListOption('contrib', [], 'List of contrib-rules to enable')
self._config_path = None
ignore_stdin_description = "Ignore any stdin data. Useful for running in CI server."
self._ignore_stdin = options.BoolOption('ignore-stdin', False, ignore_stdin_description)
self._staged = options.BoolOption('staged', False, "Read staged commit meta-info from the local repository.")
def __init__(self):
self.rules = RuleCollection(self.default_rule_classes)
self._verbosity = options.IntOption('verbosity', 3, "Verbosity")
self._ignore_merge_commits = options.BoolOption('ignore-merge-commits', True, "Ignore merge commits")
self._ignore_fixup_commits = options.BoolOption('ignore-fixup-commits', True, "Ignore fixup commits")
self._ignore_squash_commits = options.BoolOption('ignore-squash-commits', True, "Ignore squash commits")
self._ignore_revert_commits = options.BoolOption('ignore-revert-commits', True, "Ignore revert commits")
self._debug = options.BoolOption('debug', False, "Enable debug mode")
self._extra_path = None
target_description = "Path of the target git repository (default=current working directory)"
self._target = options.PathOption('target', os.path.realpath(os.getcwd()), target_description)
self._ignore = options.ListOption('ignore', [], 'List of rule-ids to ignore')
self._contrib = options.ListOption('contrib', [], 'List of contrib-rules to enable')
self._config_path = None
ignore_stdin_description = "Ignore any stdin data. Useful for running in CI server."
self._ignore_stdin = options.BoolOption('ignore-stdin', False, ignore_stdin_description)
self._staged = options.BoolOption('staged', False, "Read staged commit meta-info from the local repository.")