Copies a rule another function owns: a format, regex, SQL or date pattern
Code that already exists: one of the ways AI coding agents bloat software, from lessloc's pattern catalog. lessloc catches it as repeated-literal.
What makes copying a rule another function owns a bad practice?
The standards that call it a bad practice: DRY; Sonar S1192.
What does lessloc do about copying a rule another function owns?
lessloc catches it as repeated-literal.
repeated-literal(tier 2): A rule, such as a format, regex, query or date pattern, copied out of the function that owns it, or one new rule written in several places.
Related patterns
The other patterns in Code that already exists:
- Reimplementing a helper the project already has: lessloc gives every session the rule: take what is already in the codebase before new code.
- Keeping old and new versions side by side: lessloc gives every session the rule: one implementation per rule.
- Rebuilding what the standard library or framework has: lessloc gives every session a rule against it and catches it as
simplerandreinvented. - Copy-pasted test cases instead of one parametrized test: lessloc catches it as
copied-tests. - A second library for a job an installed one already does:
new-dependencynames the library that is already installed. - The same data shape in several layers (DTO, model, entity):
copycatches identical type bodies. - The same CSS declarations under another selector: lessloc catches it as
style-copy.

