pub struct CpdClone {
pub format: String,
pub fragment_a: Fragment,
pub fragment_b: Fragment,
pub token_count: u32,
pub is_new: bool,
pub kind: CloneKind,
pub similarity: Option<f32>,
pub similarity_method: Option<SimilarityMethod>,
pub unmatched_lines: [u32; 2],
}Fields§
§format: String§fragment_a: Fragment§fragment_b: Fragment§token_count: u32§is_new: boolTrue when the clone is absent from the configured baseline (issue #944). Always false when no baseline is in use.
kind: CloneKindexact when the raw tokens of both fragments are identical, renamed
when they match only after normalization (issue #998). Always exact
when no normalization option is on.
similarity: Option<f32>For similar clones: matched tokens divided by the tokens of the
longer merged span, in (0, 1). None for exact and renamed clones.
similarity_method: Option<SimilarityMethod>Which mechanism produced a similar clone; the two scores are not
on the same scale, so reporters show it next to the value.
unmatched_lines: [u32; 2]Lines inside each fragment’s span that are not duplicated code, for
fragment_a and fragment_b in that order. Two things land here: the
lines a --max-gap-lines merge left unmatched between its halves, and,
for an embedded block, the host language’s lines lying between two
blocks of the same fragment (issue #1090). Statistics subtract them
from the fragment’s span.
Implementations§
Source§impl CpdClone
impl CpdClone
Sourcepub fn matched_lines(&self) -> u64
pub fn matched_lines(&self) -> u64
Duplicated lines this clone adds to the statistics: the matched lines of its primary fragment.
Sourcepub fn fragment_lines(&self, index: usize) -> u64
pub fn fragment_lines(&self, index: usize) -> u64
Matched lines of one fragment — 0 is A, 1 is B. Per-file summaries need both, and they must not drift apart.
The span is inclusive, so a clone of lines 10 through 19 is ten lines,
the same count the reporters print next to it. Whatever the span covers
but does not duplicate — gap-merge lines, host-language lines between
two embedded blocks — is already in unmatched_lines.
Sourcepub fn exact(
format: impl Into<String>,
fragment_a: Fragment,
fragment_b: Fragment,
token_count: u32,
) -> Self
pub fn exact( format: impl Into<String>, fragment_a: Fragment, fragment_b: Fragment, token_count: u32, ) -> Self
An exact clone with no baseline, similarity or gap metadata.
Sourcepub fn similarity_rounded(&self) -> Option<f64>
pub fn similarity_rounded(&self) -> Option<f64>
similarity rounded to three decimals as an f64, the form reporters
print (an f32 widened to JSON would print as 0.8510638475418091).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for CpdClone
impl<'de> Deserialize<'de> for CpdClone
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for CpdClone
Auto Trait Implementations§
impl Freeze for CpdClone
impl RefUnwindSafe for CpdClone
impl Send for CpdClone
impl Sync for CpdClone
impl Unpin for CpdClone
impl UnsafeUnpin for CpdClone
impl UnwindSafe for CpdClone
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more