Skip to main content

clone_fingerprint

Function clone_fingerprint 

Source
pub fn clone_fingerprint(instances: &[CloneInstance]) -> String
Expand description

Compute the legacy short content fingerprint for a clone group from its instances.

The fingerprint is derived from the representative instance’s raw source fragment (the first instance after super::types::DuplicationReport::sort, which orders instances by (file, line)), so it is:

  • content-derived, not line-derived (moving a clone down a file does not change it),
  • sibling-stable (editing one clone group never changes another group’s fingerprint, since each hashes only its own content),

Use CloneFingerprintSet for user-facing report output, since it widens only the rare colliding handles while preserving this short form for the common case.

Hashes the empty string for an empty group (never produced by the detector, which guarantees >= 2 instances), so the result is still a well-formed dup:<8hex> handle.