Skip to content

ALL-DUPL0005 · module_repeated_string_literal

Find one string literal a single module writes out over and over.

This is a deterministic rule for all languages. Read its implementation.

Add up every place one module spells the exact same string and report that value once it reaches minimum_occurrences and is at least minimum_length characters long. A value typed out four times in one file is a decision the module already made and never named, so renaming it means finding every copy first, and missing one is the ordinary way two spellings of the same idea start to drift. A module constant states the decision once and gives every use the same name.

Only text the module states as its own counts, which is an assignment, a return, a collection element, or one side of an equality test. Text handed to a callable belongs to that callable, because a column name, a mode flag, or a format token repeats as often as the calls that need it and names nothing the module decided.

Continue with evidence and references, or open the examples.