Skip to main content

CpdClone

Struct CpdClone 

Source
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: bool

True when the clone is absent from the configured baseline (issue #944). Always false when no baseline is in use.

§kind: CloneKind

exact 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

Source

pub fn matched_lines(&self) -> u64

Duplicated lines this clone adds to the statistics: the matched lines of its primary fragment.

Source

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.

Source

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.

Source

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 Clone for CpdClone

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CpdClone

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for CpdClone

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for CpdClone

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for CpdClone

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for CpdClone

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.