Skip to content

Config

Configuration for commit message linting.

This module defines the configuration structures and rules for linting commit messages according to Conventional Commits specifications.

RuleLevel

Bases: Enum

Enforcement level for a linting rule.

Source code in src/codemap/git/commit_linter/config.py
18
19
20
21
22
23
class RuleLevel(enum.Enum):
	"""Enforcement level for a linting rule."""

	DISABLED = 0
	WARNING = 1
	ERROR = 2

DISABLED class-attribute instance-attribute

DISABLED = 0

WARNING class-attribute instance-attribute

WARNING = 1

ERROR class-attribute instance-attribute

ERROR = 2

Rule dataclass

A rule configuration for commit linting.

Source code in src/codemap/git/commit_linter/config.py
26
27
28
29
30
31
32
33
34
@dataclass
class Rule:
	"""A rule configuration for commit linting."""

	name: str
	condition: str
	rule: Literal["always", "never"] = "always"
	level: RuleLevel = RuleLevel.ERROR
	value: Any = None

__init__

__init__(
	name: str,
	condition: str,
	rule: Literal["always", "never"] = "always",
	level: RuleLevel = ERROR,
	value: Any = None,
) -> None

name instance-attribute

name: str

condition instance-attribute

condition: str

rule class-attribute instance-attribute

rule: Literal['always', 'never'] = 'always'

level class-attribute instance-attribute

level: RuleLevel = ERROR

value class-attribute instance-attribute

value: Any = None

CommitLintConfig dataclass

Configuration for commit message linting rules.

Rather than providing default values here, this class now loads its configuration from the central config.py file via ConfigLoader.

Source code in src/codemap/git/commit_linter/config.py
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
@dataclass
class CommitLintConfig:
	"""
	Configuration for commit message linting rules.

	Rather than providing default values here, this class now loads its
	configuration from the central config.py file via ConfigLoader.

	"""

	# Header rules
	header_max_length: Rule = field(
		default_factory=lambda: Rule(
			name="header-max-length",
			condition="header has value or less characters",
			rule="always",
			value=100,  # Default value, will be overridden by config
			level=RuleLevel.ERROR,
		)
	)

	# More rule definitions with minimal defaults...
	header_min_length: Rule = field(
		default_factory=lambda: Rule(
			name="header-min-length",
			condition="header has value or more characters",
			rule="always",
			value=0,
		)
	)

	header_case: Rule = field(
		default_factory=lambda: Rule(
			name="header-case",
			condition="header is in case value",
			rule="always",
			value="lower-case",
			level=RuleLevel.DISABLED,
		)
	)

	header_full_stop: Rule = field(
		default_factory=lambda: Rule(
			name="header-full-stop",
			condition="header ends with value",
			rule="never",
			value=".",
		)
	)

	header_trim: Rule = field(
		default_factory=lambda: Rule(
			name="header-trim",
			condition="header must not have initial and/or trailing whitespaces",
			rule="always",
		)
	)

	# Type rules
	type_enum: Rule = field(
		default_factory=lambda: Rule(
			name="type-enum",
			condition="type is found in value",
			rule="always",
			value=[],  # Will be populated from config
		)
	)

	type_case: Rule = field(
		default_factory=lambda: Rule(
			name="type-case",
			condition="type is in case value",
			rule="always",
			value="lower-case",
		)
	)

	type_empty: Rule = field(
		default_factory=lambda: Rule(
			name="type-empty",
			condition="type is empty",
			rule="never",
		)
	)

	# Other rules with minimal definitions...
	# Scope rules
	scope_enum: Rule = field(
		default_factory=lambda: Rule(
			name="scope-enum",
			condition="scope is found in value",
			rule="always",
			value=[],
			level=RuleLevel.DISABLED,
		)
	)

	scope_case: Rule = field(
		default_factory=lambda: Rule(
			name="scope-case",
			condition="scope is in case value",
			rule="always",
			value="lower-case",
		)
	)

	scope_empty: Rule = field(
		default_factory=lambda: Rule(
			name="scope-empty",
			condition="scope is empty",
			rule="never",
			level=RuleLevel.DISABLED,
		)
	)

	# Subject rules
	subject_case: Rule = field(
		default_factory=lambda: Rule(
			name="subject-case",
			condition="subject is in case value",
			rule="always",
			value=["sentence-case", "start-case", "pascal-case", "upper-case"],
		)
	)

	subject_empty: Rule = field(
		default_factory=lambda: Rule(
			name="subject-empty",
			condition="subject is empty",
			rule="never",
		)
	)

	subject_full_stop: Rule = field(
		default_factory=lambda: Rule(
			name="subject-full-stop",
			condition="subject ends with value",
			rule="never",
			value=".",
		)
	)

	subject_exclamation_mark: Rule = field(
		default_factory=lambda: Rule(
			name="subject-exclamation-mark",
			condition="subject has exclamation before the : marker",
			rule="never",
			level=RuleLevel.DISABLED,
		)
	)

	# Body rules
	body_leading_blank: Rule = field(
		default_factory=lambda: Rule(
			name="body-leading-blank",
			condition="body begins with blank line",
			rule="always",
			level=RuleLevel.WARNING,
		)
	)

	body_empty: Rule = field(
		default_factory=lambda: Rule(
			name="body-empty",
			condition="body is empty",
			rule="never",
			level=RuleLevel.DISABLED,
		)
	)

	body_max_line_length: Rule = field(
		default_factory=lambda: Rule(
			name="body-max-line-length",
			condition="body lines has value or less characters",
			rule="always",
			value=100,
		)
	)

	# Footer rules
	footer_leading_blank: Rule = field(
		default_factory=lambda: Rule(
			name="footer-leading-blank",
			condition="footer begins with blank line",
			rule="always",
			level=RuleLevel.WARNING,
		)
	)

	footer_empty: Rule = field(
		default_factory=lambda: Rule(
			name="footer-empty",
			condition="footer is empty",
			rule="never",
			level=RuleLevel.DISABLED,
		)
	)

	footer_max_line_length: Rule = field(
		default_factory=lambda: Rule(
			name="footer-max-line-length",
			condition="footer lines has value or less characters",
			rule="always",
			value=100,
		)
	)

	# Additional rules that are still referenced by the linter
	type_max_length: Rule = field(
		default_factory=lambda: Rule(
			name="type-max-length",
			condition="type has value or less characters",
			rule="always",
			value=float("inf"),
		)
	)

	type_min_length: Rule = field(
		default_factory=lambda: Rule(
			name="type-min-length",
			condition="type has value or more characters",
			rule="always",
			value=0,
		)
	)

	scope_max_length: Rule = field(
		default_factory=lambda: Rule(
			name="scope-max-length",
			condition="scope has value or less characters",
			rule="always",
			value=float("inf"),
		)
	)

	scope_min_length: Rule = field(
		default_factory=lambda: Rule(
			name="scope-min-length",
			condition="scope has value or more characters",
			rule="always",
			value=0,
		)
	)

	subject_max_length: Rule = field(
		default_factory=lambda: Rule(
			name="subject-max-length",
			condition="subject has value or less characters",
			rule="always",
			value=float("inf"),
		)
	)

	subject_min_length: Rule = field(
		default_factory=lambda: Rule(
			name="subject-min-length",
			condition="subject has value or more characters",
			rule="always",
			value=0,
		)
	)

	body_max_length: Rule = field(
		default_factory=lambda: Rule(
			name="body-max-length",
			condition="body has value or less characters",
			rule="always",
			value=float("inf"),
		)
	)

	body_min_length: Rule = field(
		default_factory=lambda: Rule(
			name="body-min-length",
			condition="body has value or more characters",
			rule="always",
			value=0,
		)
	)

	body_case: Rule = field(
		default_factory=lambda: Rule(
			name="body-case",
			condition="body is in case value",
			rule="always",
			value="lower-case",
			level=RuleLevel.DISABLED,
		)
	)

	body_full_stop: Rule = field(
		default_factory=lambda: Rule(
			name="body-full-stop",
			condition="body ends with value",
			rule="never",
			value=".",
			level=RuleLevel.DISABLED,
		)
	)

	# Reference rules
	references_empty: Rule = field(
		default_factory=lambda: Rule(
			name="references-empty",
			condition="references has at least one entry",
			rule="never",
			level=RuleLevel.DISABLED,
		)
	)

	# Signed-off rules
	signed_off_by: Rule = field(
		default_factory=lambda: Rule(
			name="signed-off-by",
			condition="message has value",
			rule="always",
			value="Signed-off-by:",
			level=RuleLevel.DISABLED,
		)
	)

	trailer_exists: Rule = field(
		default_factory=lambda: Rule(
			name="trailer-exists",
			condition="message has trailer value",
			rule="always",
			value="Signed-off-by:",
			level=RuleLevel.DISABLED,
		)
	)

	footer_max_length: Rule = field(
		default_factory=lambda: Rule(
			name="footer-max-length",
			condition="footer has value or less characters",
			rule="always",
			value=float("inf"),
		)
	)

	footer_min_length: Rule = field(
		default_factory=lambda: Rule(
			name="footer-min-length",
			condition="footer has value or more characters",
			rule="always",
			value=0,
		)
	)

	@classmethod
	def get_rules(cls, config_loader: ConfigLoader) -> "CommitLintConfig":
		"""
		Get the rules from the config.

		Args:
		    config_loader: ConfigLoader instance for retrieving additional configuration

		Returns:
		    CommitLintConfig: Configured instance
		"""
		config = cls()
		commit_config = config_loader.get.commit
		lint_config = commit_config.lint

		# Update all rules from lint config
		for rule_name in dir(config):
			if not rule_name.startswith("_") and isinstance(getattr(config, rule_name), Rule):
				rule_obj = getattr(config, rule_name)
				rule_config = getattr(lint_config, rule_name, None)

				if rule_config:
					rule_obj.rule = rule_config.rule
					rule_obj.value = rule_config.value
					rule_obj.level = RuleLevel[rule_config.level]

		# Handle special cases from commit convention
		if commit_config.convention.types:
			config.type_enum.value = commit_config.convention.types

		if commit_config.convention.scopes:
			config.scope_enum.value = commit_config.convention.scopes
			if config.scope_enum.value:
				config.scope_enum.level = RuleLevel.ERROR

		if commit_config.convention.max_length and not lint_config.header_max_length:
			config.header_max_length.value = commit_config.convention.max_length

		return config

__init__

__init__(
	header_max_length: Rule = lambda: Rule(
		name="header-max-length",
		condition="header has value or less characters",
		rule="always",
		value=100,
		level=ERROR,
	)(),
	header_min_length: Rule = lambda: Rule(
		name="header-min-length",
		condition="header has value or more characters",
		rule="always",
		value=0,
	)(),
	header_case: Rule = lambda: Rule(
		name="header-case",
		condition="header is in case value",
		rule="always",
		value="lower-case",
		level=DISABLED,
	)(),
	header_full_stop: Rule = lambda: Rule(
		name="header-full-stop",
		condition="header ends with value",
		rule="never",
		value=".",
	)(),
	header_trim: Rule = lambda: Rule(
		name="header-trim",
		condition="header must not have initial and/or trailing whitespaces",
		rule="always",
	)(),
	type_enum: Rule = lambda: Rule(
		name="type-enum",
		condition="type is found in value",
		rule="always",
		value=[],
	)(),
	type_case: Rule = lambda: Rule(
		name="type-case",
		condition="type is in case value",
		rule="always",
		value="lower-case",
	)(),
	type_empty: Rule = lambda: Rule(
		name="type-empty",
		condition="type is empty",
		rule="never",
	)(),
	scope_enum: Rule = lambda: Rule(
		name="scope-enum",
		condition="scope is found in value",
		rule="always",
		value=[],
		level=DISABLED,
	)(),
	scope_case: Rule = lambda: Rule(
		name="scope-case",
		condition="scope is in case value",
		rule="always",
		value="lower-case",
	)(),
	scope_empty: Rule = lambda: Rule(
		name="scope-empty",
		condition="scope is empty",
		rule="never",
		level=DISABLED,
	)(),
	subject_case: Rule = lambda: Rule(
		name="subject-case",
		condition="subject is in case value",
		rule="always",
		value=[
			"sentence-case",
			"start-case",
			"pascal-case",
			"upper-case",
		],
	)(),
	subject_empty: Rule = lambda: Rule(
		name="subject-empty",
		condition="subject is empty",
		rule="never",
	)(),
	subject_full_stop: Rule = lambda: Rule(
		name="subject-full-stop",
		condition="subject ends with value",
		rule="never",
		value=".",
	)(),
	subject_exclamation_mark: Rule = lambda: Rule(
		name="subject-exclamation-mark",
		condition="subject has exclamation before the : marker",
		rule="never",
		level=DISABLED,
	)(),
	body_leading_blank: Rule = lambda: Rule(
		name="body-leading-blank",
		condition="body begins with blank line",
		rule="always",
		level=WARNING,
	)(),
	body_empty: Rule = lambda: Rule(
		name="body-empty",
		condition="body is empty",
		rule="never",
		level=DISABLED,
	)(),
	body_max_line_length: Rule = lambda: Rule(
		name="body-max-line-length",
		condition="body lines has value or less characters",
		rule="always",
		value=100,
	)(),
	footer_leading_blank: Rule = lambda: Rule(
		name="footer-leading-blank",
		condition="footer begins with blank line",
		rule="always",
		level=WARNING,
	)(),
	footer_empty: Rule = lambda: Rule(
		name="footer-empty",
		condition="footer is empty",
		rule="never",
		level=DISABLED,
	)(),
	footer_max_line_length: Rule = lambda: Rule(
		name="footer-max-line-length",
		condition="footer lines has value or less characters",
		rule="always",
		value=100,
	)(),
	type_max_length: Rule = lambda: Rule(
		name="type-max-length",
		condition="type has value or less characters",
		rule="always",
		value=float("inf"),
	)(),
	type_min_length: Rule = lambda: Rule(
		name="type-min-length",
		condition="type has value or more characters",
		rule="always",
		value=0,
	)(),
	scope_max_length: Rule = lambda: Rule(
		name="scope-max-length",
		condition="scope has value or less characters",
		rule="always",
		value=float("inf"),
	)(),
	scope_min_length: Rule = lambda: Rule(
		name="scope-min-length",
		condition="scope has value or more characters",
		rule="always",
		value=0,
	)(),
	subject_max_length: Rule = lambda: Rule(
		name="subject-max-length",
		condition="subject has value or less characters",
		rule="always",
		value=float("inf"),
	)(),
	subject_min_length: Rule = lambda: Rule(
		name="subject-min-length",
		condition="subject has value or more characters",
		rule="always",
		value=0,
	)(),
	body_max_length: Rule = lambda: Rule(
		name="body-max-length",
		condition="body has value or less characters",
		rule="always",
		value=float("inf"),
	)(),
	body_min_length: Rule = lambda: Rule(
		name="body-min-length",
		condition="body has value or more characters",
		rule="always",
		value=0,
	)(),
	body_case: Rule = lambda: Rule(
		name="body-case",
		condition="body is in case value",
		rule="always",
		value="lower-case",
		level=DISABLED,
	)(),
	body_full_stop: Rule = lambda: Rule(
		name="body-full-stop",
		condition="body ends with value",
		rule="never",
		value=".",
		level=DISABLED,
	)(),
	references_empty: Rule = lambda: Rule(
		name="references-empty",
		condition="references has at least one entry",
		rule="never",
		level=DISABLED,
	)(),
	signed_off_by: Rule = lambda: Rule(
		name="signed-off-by",
		condition="message has value",
		rule="always",
		value="Signed-off-by:",
		level=DISABLED,
	)(),
	trailer_exists: Rule = lambda: Rule(
		name="trailer-exists",
		condition="message has trailer value",
		rule="always",
		value="Signed-off-by:",
		level=DISABLED,
	)(),
	footer_max_length: Rule = lambda: Rule(
		name="footer-max-length",
		condition="footer has value or less characters",
		rule="always",
		value=float("inf"),
	)(),
	footer_min_length: Rule = lambda: Rule(
		name="footer-min-length",
		condition="footer has value or more characters",
		rule="always",
		value=0,
	)(),
) -> None

header_max_length class-attribute instance-attribute

header_max_length: Rule = field(
	default_factory=lambda: Rule(
		name="header-max-length",
		condition="header has value or less characters",
		rule="always",
		value=100,
		level=ERROR,
	)
)

header_min_length class-attribute instance-attribute

header_min_length: Rule = field(
	default_factory=lambda: Rule(
		name="header-min-length",
		condition="header has value or more characters",
		rule="always",
		value=0,
	)
)

header_case class-attribute instance-attribute

header_case: Rule = field(
	default_factory=lambda: Rule(
		name="header-case",
		condition="header is in case value",
		rule="always",
		value="lower-case",
		level=DISABLED,
	)
)

header_full_stop class-attribute instance-attribute

header_full_stop: Rule = field(
	default_factory=lambda: Rule(
		name="header-full-stop",
		condition="header ends with value",
		rule="never",
		value=".",
	)
)

header_trim class-attribute instance-attribute

header_trim: Rule = field(
	default_factory=lambda: Rule(
		name="header-trim",
		condition="header must not have initial and/or trailing whitespaces",
		rule="always",
	)
)

type_enum class-attribute instance-attribute

type_enum: Rule = field(
	default_factory=lambda: Rule(
		name="type-enum",
		condition="type is found in value",
		rule="always",
		value=[],
	)
)

type_case class-attribute instance-attribute

type_case: Rule = field(
	default_factory=lambda: Rule(
		name="type-case",
		condition="type is in case value",
		rule="always",
		value="lower-case",
	)
)

type_empty class-attribute instance-attribute

type_empty: Rule = field(
	default_factory=lambda: Rule(
		name="type-empty",
		condition="type is empty",
		rule="never",
	)
)

scope_enum class-attribute instance-attribute

scope_enum: Rule = field(
	default_factory=lambda: Rule(
		name="scope-enum",
		condition="scope is found in value",
		rule="always",
		value=[],
		level=DISABLED,
	)
)

scope_case class-attribute instance-attribute

scope_case: Rule = field(
	default_factory=lambda: Rule(
		name="scope-case",
		condition="scope is in case value",
		rule="always",
		value="lower-case",
	)
)

scope_empty class-attribute instance-attribute

scope_empty: Rule = field(
	default_factory=lambda: Rule(
		name="scope-empty",
		condition="scope is empty",
		rule="never",
		level=DISABLED,
	)
)

subject_case class-attribute instance-attribute

subject_case: Rule = field(
	default_factory=lambda: Rule(
		name="subject-case",
		condition="subject is in case value",
		rule="always",
		value=[
			"sentence-case",
			"start-case",
			"pascal-case",
			"upper-case",
		],
	)
)

subject_empty class-attribute instance-attribute

subject_empty: Rule = field(
	default_factory=lambda: Rule(
		name="subject-empty",
		condition="subject is empty",
		rule="never",
	)
)

subject_full_stop class-attribute instance-attribute

subject_full_stop: Rule = field(
	default_factory=lambda: Rule(
		name="subject-full-stop",
		condition="subject ends with value",
		rule="never",
		value=".",
	)
)

subject_exclamation_mark class-attribute instance-attribute

subject_exclamation_mark: Rule = field(
	default_factory=lambda: Rule(
		name="subject-exclamation-mark",
		condition="subject has exclamation before the : marker",
		rule="never",
		level=DISABLED,
	)
)

body_leading_blank class-attribute instance-attribute

body_leading_blank: Rule = field(
	default_factory=lambda: Rule(
		name="body-leading-blank",
		condition="body begins with blank line",
		rule="always",
		level=WARNING,
	)
)

body_empty class-attribute instance-attribute

body_empty: Rule = field(
	default_factory=lambda: Rule(
		name="body-empty",
		condition="body is empty",
		rule="never",
		level=DISABLED,
	)
)

body_max_line_length class-attribute instance-attribute

body_max_line_length: Rule = field(
	default_factory=lambda: Rule(
		name="body-max-line-length",
		condition="body lines has value or less characters",
		rule="always",
		value=100,
	)
)

footer_leading_blank class-attribute instance-attribute

footer_leading_blank: Rule = field(
	default_factory=lambda: Rule(
		name="footer-leading-blank",
		condition="footer begins with blank line",
		rule="always",
		level=WARNING,
	)
)

footer_empty class-attribute instance-attribute

footer_empty: Rule = field(
	default_factory=lambda: Rule(
		name="footer-empty",
		condition="footer is empty",
		rule="never",
		level=DISABLED,
	)
)

footer_max_line_length class-attribute instance-attribute

footer_max_line_length: Rule = field(
	default_factory=lambda: Rule(
		name="footer-max-line-length",
		condition="footer lines has value or less characters",
		rule="always",
		value=100,
	)
)

type_max_length class-attribute instance-attribute

type_max_length: Rule = field(
	default_factory=lambda: Rule(
		name="type-max-length",
		condition="type has value or less characters",
		rule="always",
		value=float("inf"),
	)
)

type_min_length class-attribute instance-attribute

type_min_length: Rule = field(
	default_factory=lambda: Rule(
		name="type-min-length",
		condition="type has value or more characters",
		rule="always",
		value=0,
	)
)

scope_max_length class-attribute instance-attribute

scope_max_length: Rule = field(
	default_factory=lambda: Rule(
		name="scope-max-length",
		condition="scope has value or less characters",
		rule="always",
		value=float("inf"),
	)
)

scope_min_length class-attribute instance-attribute

scope_min_length: Rule = field(
	default_factory=lambda: Rule(
		name="scope-min-length",
		condition="scope has value or more characters",
		rule="always",
		value=0,
	)
)

subject_max_length class-attribute instance-attribute

subject_max_length: Rule = field(
	default_factory=lambda: Rule(
		name="subject-max-length",
		condition="subject has value or less characters",
		rule="always",
		value=float("inf"),
	)
)

subject_min_length class-attribute instance-attribute

subject_min_length: Rule = field(
	default_factory=lambda: Rule(
		name="subject-min-length",
		condition="subject has value or more characters",
		rule="always",
		value=0,
	)
)

body_max_length class-attribute instance-attribute

body_max_length: Rule = field(
	default_factory=lambda: Rule(
		name="body-max-length",
		condition="body has value or less characters",
		rule="always",
		value=float("inf"),
	)
)

body_min_length class-attribute instance-attribute

body_min_length: Rule = field(
	default_factory=lambda: Rule(
		name="body-min-length",
		condition="body has value or more characters",
		rule="always",
		value=0,
	)
)

body_case class-attribute instance-attribute

body_case: Rule = field(
	default_factory=lambda: Rule(
		name="body-case",
		condition="body is in case value",
		rule="always",
		value="lower-case",
		level=DISABLED,
	)
)

body_full_stop class-attribute instance-attribute

body_full_stop: Rule = field(
	default_factory=lambda: Rule(
		name="body-full-stop",
		condition="body ends with value",
		rule="never",
		value=".",
		level=DISABLED,
	)
)

references_empty class-attribute instance-attribute

references_empty: Rule = field(
	default_factory=lambda: Rule(
		name="references-empty",
		condition="references has at least one entry",
		rule="never",
		level=DISABLED,
	)
)

signed_off_by class-attribute instance-attribute

signed_off_by: Rule = field(
	default_factory=lambda: Rule(
		name="signed-off-by",
		condition="message has value",
		rule="always",
		value="Signed-off-by:",
		level=DISABLED,
	)
)

trailer_exists class-attribute instance-attribute

trailer_exists: Rule = field(
	default_factory=lambda: Rule(
		name="trailer-exists",
		condition="message has trailer value",
		rule="always",
		value="Signed-off-by:",
		level=DISABLED,
	)
)

footer_max_length class-attribute instance-attribute

footer_max_length: Rule = field(
	default_factory=lambda: Rule(
		name="footer-max-length",
		condition="footer has value or less characters",
		rule="always",
		value=float("inf"),
	)
)

footer_min_length class-attribute instance-attribute

footer_min_length: Rule = field(
	default_factory=lambda: Rule(
		name="footer-min-length",
		condition="footer has value or more characters",
		rule="always",
		value=0,
	)
)

get_rules classmethod

get_rules(config_loader: ConfigLoader) -> CommitLintConfig

Get the rules from the config.

Parameters:

Name Type Description Default
config_loader ConfigLoader

ConfigLoader instance for retrieving additional configuration

required

Returns:

Name Type Description
CommitLintConfig CommitLintConfig

Configured instance

Source code in src/codemap/git/commit_linter/config.py
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
@classmethod
def get_rules(cls, config_loader: ConfigLoader) -> "CommitLintConfig":
	"""
	Get the rules from the config.

	Args:
	    config_loader: ConfigLoader instance for retrieving additional configuration

	Returns:
	    CommitLintConfig: Configured instance
	"""
	config = cls()
	commit_config = config_loader.get.commit
	lint_config = commit_config.lint

	# Update all rules from lint config
	for rule_name in dir(config):
		if not rule_name.startswith("_") and isinstance(getattr(config, rule_name), Rule):
			rule_obj = getattr(config, rule_name)
			rule_config = getattr(lint_config, rule_name, None)

			if rule_config:
				rule_obj.rule = rule_config.rule
				rule_obj.value = rule_config.value
				rule_obj.level = RuleLevel[rule_config.level]

	# Handle special cases from commit convention
	if commit_config.convention.types:
		config.type_enum.value = commit_config.convention.types

	if commit_config.convention.scopes:
		config.scope_enum.value = commit_config.convention.scopes
		if config.scope_enum.value:
			config.scope_enum.level = RuleLevel.ERROR

	if commit_config.convention.max_length and not lint_config.header_max_length:
		config.header_max_length.value = commit_config.convention.max_length

	return config