Skip to content

Commit

Permalink
Moved to expect for lints and small changes for rusteomics
Browse files Browse the repository at this point in the history
  • Loading branch information
douweschulte committed Feb 4, 2025
1 parent 866b4ce commit ca2f8a4
Show file tree
Hide file tree
Showing 66 changed files with 172 additions and 187 deletions.
2 changes: 1 addition & 1 deletion rustyms-generate-databases/src/gnome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fn find_mass(mods: &HashMap<String, GNOmeModification>, mut name: String) -> Opt
mass
}

#[allow(dead_code)]
#[expect(dead_code)]
mod gnome_terms {
pub const SUBSUMPTION_MOLECULAR_WEIGHT: &str = "GNO:00000012";
pub const SUBSUMPTION_BASECOMPOSITION: &str = "GNO:00000013";
Expand Down
8 changes: 4 additions & 4 deletions rustyms/src/align/alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl<A, B> Ord for Alignment<'_, A, B> {

impl<'lifetime, A: AtMax<SimpleLinear>, B: AtMax<SimpleLinear>> Alignment<'lifetime, A, B> {
/// Recreate an alignment from a path, the path is [`Self::short`].
#[allow(clippy::missing_panics_doc)]
#[expect(clippy::missing_panics_doc)]
pub fn create_from_path(
seq_a: &'lifetime Peptidoform<A>,
seq_b: &'lifetime Peptidoform<B>,
Expand Down Expand Up @@ -436,7 +436,7 @@ impl<A: AtMax<Linear>, B: AtMax<Linear>> Alignment<'_, A, B> {

/// Get the mass delta for this match, if it is a (partial) local match it will only take the matched amino acids into account.
/// If there are multiple possible masses for any of the stretches it returns the smallest difference.
#[allow(clippy::missing_panics_doc)]
#[expect(clippy::missing_panics_doc)]
pub fn mass_difference(&self) -> Mass {
self.mass_a()
.iter()
Expand All @@ -448,7 +448,7 @@ impl<A: AtMax<Linear>, B: AtMax<Linear>> Alignment<'_, A, B> {

/// Get the error in ppm for this match, if it is a (partial) local match it will only take the matched amino acids into account.
/// If there are multiple possible masses for any of the stretches it returns the smallest difference.
#[allow(clippy::missing_panics_doc)]
#[expect(clippy::missing_panics_doc)]
pub fn ppm(&self) -> Ratio {
self.mass_a()
.iter()
Expand Down Expand Up @@ -592,7 +592,7 @@ pub struct Score {
}

#[cfg(test)]
#[allow(clippy::missing_panics_doc)]
#[expect(clippy::missing_panics_doc)]
mod tests {
use crate::{
align::{align, AlignScoring, AlignType},
Expand Down
6 changes: 3 additions & 3 deletions rustyms/src/align/consecutive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl<'lifetime, A> ConsecutiveAlignment<'lifetime, A> {

impl<A: AtMax<Linear>> ConsecutiveAlignment<'_, A> {
/// Break up in the main alignment into the regions as annotated in the alleles.
#[allow(clippy::missing_panics_doc)]
#[expect(clippy::missing_panics_doc)]
pub fn regions(&self) -> Vec<(Peptidoform<A>, Region)> {
let mut b_offset = 0;
self.alignments
Expand Down Expand Up @@ -82,7 +82,7 @@ impl<A: AtMax<Linear>> ConsecutiveAlignment<'_, A> {
/// If the sequence is too short to cover all genes only the genes that could be matched are returned.
/// # Panics
/// If there are not two or more genes listed. If the return number is 0.
#[allow(clippy::needless_pass_by_value)]
#[expect(clippy::needless_pass_by_value)]
pub fn consecutive_align<const STEPS: u16, A: AtMax<SimpleLinear> + AtMax<Linear>>(
sequence: &Peptidoform<A>,
genes: &[(GeneType, AlignType)],
Expand Down Expand Up @@ -144,7 +144,7 @@ pub fn consecutive_align<const STEPS: u16, A: AtMax<SimpleLinear> + AtMax<Linear
/// # Panics
/// If there are not two or more genes listed. If the return number is 0.
#[cfg(feature = "rayon")]
#[allow(clippy::needless_pass_by_value)]
#[expect(clippy::needless_pass_by_value)]
pub fn par_consecutive_align<
const STEPS: u16,
A: AtMax<SimpleLinear> + AtMax<Linear> + Send + Sync,
Expand Down
4 changes: 2 additions & 2 deletions rustyms/src/align/diagonal_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl<T> DiagonalArray<T> {
/// # Safety
/// This function assumes the index to be valid. Not upholding this does an out of bounds unsafe [`[T]::get_unchecked_mut`].
/// A debug assertion hold up this promise on debug builds.
#[allow(dead_code)]
#[expect(dead_code)]
pub unsafe fn get_unchecked_mut(&mut self, index: [usize; 2]) -> &mut T {
debug_assert!(self.validate_indices(index));
let index = Self::length(index[0], self.max_depth) + index[1];
Expand Down Expand Up @@ -84,7 +84,7 @@ impl<T> std::ops::IndexMut<[usize; 2]> for DiagonalArray<T> {
}

#[cfg(test)]
#[allow(clippy::missing_panics_doc)]
#[expect(clippy::missing_panics_doc)]
mod tests {
use super::DiagonalArray;

Expand Down
8 changes: 4 additions & 4 deletions rustyms/src/align/mass_alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use super::{
/// The [`AlignType`] controls the alignment behaviour, global/local or anything in between.
/// # Panics
/// It panics when the length of `seq_a` or `seq_b` is bigger than [`isize::MAX`].
#[allow(clippy::too_many_lines)]
#[expect(clippy::too_many_lines)]
pub fn align<'lifetime, const STEPS: u16, A: AtMax<SimpleLinear>, B: AtMax<SimpleLinear>>(
seq_a: &'lifetime Peptidoform<A>,
seq_b: &'lifetime Peptidoform<B>,
Expand Down Expand Up @@ -263,7 +263,7 @@ fn score<A: AtMax<SimpleLinear>, B: AtMax<SimpleLinear>>(
})
}
};
#[allow(clippy::cast_possible_wrap)]
#[expect(clippy::cast_possible_wrap)]
let local = scoring.mass_base as isize
+ if rotated {
scoring.rotated as isize * a.0.len() as isize
Expand Down Expand Up @@ -361,7 +361,7 @@ impl Matrix {
}
}

#[allow(clippy::cast_possible_wrap)]
#[expect(clippy::cast_possible_wrap)]
pub fn global_start(&mut self, is_a: bool, scoring: AlignScoring<'_>) {
let max = if is_a { self.a } else { self.b };
for index in 0..=max {
Expand Down Expand Up @@ -480,7 +480,7 @@ impl std::ops::IndexMut<[usize; 2]> for Matrix {
}

#[cfg(test)]
#[allow(clippy::missing_panics_doc)]
#[expect(clippy::missing_panics_doc)]
mod tests {
use super::score;
use crate::align::scoring::AlignScoring;
Expand Down
2 changes: 1 addition & 1 deletion rustyms/src/align/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub mod matrix {
}

#[cfg(test)]
#[allow(clippy::missing_panics_doc)]
#[expect(clippy::missing_panics_doc)]
mod tests {
use crate::{peptidoform::SimpleLinear, Peptidoform};

Expand Down
11 changes: 4 additions & 7 deletions rustyms/src/aminoacids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl AminoAcid {

/// All losses from the base immonium ions. Compiled from the sources below.
///
/// | AA | [Wikipedia](https://upload.wikimedia.org/wikipedia/commons/thumb/0/01/Amino_acid_fragment_ions.png/400px-Amino_acid_fragment_ions.png) | 0.1016/1044-0305(93)87006-X | [ionsource](https://www.ionsource.com/Card/immon/immon.htm) | [10.1002/chin.199624319](http://dx.doi.org/10.1002/chin.199624319) | [Prospector (MS-Comp)](https://prospector.ucsf.edu/prospector/cgi-bin/msform.cgi?form=mscomp) | [10.1186/1477-5956-9-2](http://dx.doi.org/10.1186/1477-5956-9-2) | 10.1016/j.ymeth.2004.08.013 | 10.1385/1597452750 (table 5) | 10.1021/ac902712f | [Prospector (MS-Product)](https://prospector.ucsf.edu/prospector/cgi-bin/msform.cgi?form=msproduct) | [ThermoFisher](https://tools.thermofisher.com/content/sfs/brochures/cms_040030.pdf) | 10.1074/mcp.O113.035915 | 10.1074/mcp.O113.035915 | 10.1021/ac902712f | [Prospector (MS-Product)](https://prospector.ucsf.edu/prospector/cgi-bin/msform.cgi?form=msproduct) | | 10.1385/1597452750 (table 5) | Sources | Best mass | Best formula | Loss | Loss formula | Interpreted loss | Interpreted formula | Final |
/// | AA | [Wikipedia](https://upload.wikimedia.org/wikipedia/commons/thumb/0/01/Amino_acid_fragment_ions.png/400px-Amino_acid_fragment_ions.png) | 0.1016/1044-0305(93)87006-X | [ionsource](https://www.ionsource.com/Card/immon/immon.htm) | [10.1002/chin.199624319](http://dx.doi.org/10.1002/chin.199624319) | [Prospector (MS-Comp)](https://prospector.ucsf.edu/prospector/cgi-bin/msform.cgi?form=mscomp) | [10.1186/1477-5956-9-2](http://dx.doi.org/10.1186/1477-5956-9-2) | 10.1016/j.ymeth.2004.08.013 | 10.1385/1597452750 (table 5) | 10.1021/ac902712f | [Prospector (MS-Product)](https://prospector.ucsf.edu/prospector/cgi-bin/msform.cgi?form=msproduct) | [ThermoFisher](https://tools.thermofisher.com/content/sfs/brochures/cms_040030.pdf) | 10.1074/mcp.O113.035915 | 10.1074/mcp.O113.035915 | 10.1021/ac902712f | [Prospector (MS-Product)](https://prospector.ucsf.edu/prospector/cgi-bin/msform.cgi?form=msproduct) | | 10.1385/1597452750 (table 5) | Sources | Best mass | Best formula | Loss | Loss formula | Interpreted loss | Interpreted formula | Final |
/// |-------|---------------------------------------------------------------------------------------------------------------------------|-----------------------------|------------------------------------------------|------------------------------------------|-----------------------------------------------------------------------|-----------------------------------------|-----------------------------|------------------------------|-------------------|--------------------------------------------------------------------------|---------------------------------------------------------------------|-------------------------|-------------------------|-------------------|--------------------------------------------------------------------------|------------------------------|---------|----------:|--------------|----------|--------------|------------------|-------------------------|------------|
/// | A | 44 | 44 | | 44 | | 44 | | 44.05 | | | 44.0500 | | | | | | 6 | 44.0500 | | | | | | |
/// | R | 129 | 129 | | 129 | | 129 | | 129.11 | | | 129.1140 | 129.1135 | C5H13N4+ | | | | 8 | 129.1138 | C5H13N4+ | | | | | |
Expand Down Expand Up @@ -271,7 +271,8 @@ impl AminoAcid {
}
}

#[allow(clippy::too_many_lines, clippy::too_many_arguments)]
// TODO: generalise over used storage type, so using molecularformula, monoisotopic mass, or average mass, also make sure that AAs can return these numbers in a const fashion
#[expect(clippy::too_many_lines, clippy::too_many_arguments)]
pub(crate) fn fragments(
self,
n_term: &Multi<MolecularFormula>,
Expand Down Expand Up @@ -557,11 +558,7 @@ impl std::fmt::Display for AminoAcid {
}

#[cfg(test)]
#[allow(
clippy::unreadable_literal,
clippy::float_cmp,
clippy::missing_panics_doc
)]
#[expect(clippy::unreadable_literal, clippy::missing_panics_doc)]
mod tests {
use super::*;

Expand Down
4 changes: 2 additions & 2 deletions rustyms/src/checked_aminoacid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct CheckedAminoAcid<T> {
marker: PhantomData<T>,
}

#[allow(non_upper_case_globals, missing_docs)]
#[expect(non_upper_case_globals, missing_docs)]
impl CheckedAminoAcid<UnAmbiguous> {
pub const A: Self = Self::Alanine;
pub const C: Self = Self::Cysteine;
Expand Down Expand Up @@ -215,7 +215,7 @@ impl CheckedAminoAcid<UnAmbiguous> {
];
}

#[allow(non_upper_case_globals, missing_docs)]
#[expect(non_upper_case_globals, missing_docs)]
impl CheckedAminoAcid<SemiAmbiguous> {
pub const B: Self = Self::AmbiguousAsparagine;
pub const Z: Self = Self::AmbiguousGlutamine;
Expand Down
2 changes: 1 addition & 1 deletion rustyms/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub fn elemental_data() -> &'static ElementalData {
static ELEMENTAL_DATA_CELL: OnceLock<ElementalData> = OnceLock::new();

#[cfg(test)]
#[allow(clippy::missing_panics_doc)]
#[expect(clippy::missing_panics_doc)]
mod test {
#[test]
fn hill_notation() {
Expand Down
8 changes: 4 additions & 4 deletions rustyms/src/error/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub enum Context {
},
}

#[allow(clippy::needless_pass_by_value, dead_code)] // the impl ToString should be passed like this, otherwise &str gives errors
#[expect(clippy::needless_pass_by_value)] // the impl ToString should be passed like this, otherwise &str gives errors
impl Context {
/// Creates a new context when no context can be given
pub const fn none() -> Self {
Expand Down Expand Up @@ -135,7 +135,7 @@ impl Context {
}

/// Creates a new context to highlight a certain position
#[allow(clippy::unwrap_used, clippy::missing_panics_doc)]
#[expect(clippy::unwrap_used, clippy::missing_panics_doc)]
pub fn position(pos: &FilePosition<'_>) -> Self {
if pos.text.is_empty() {
Self::Line {
Expand Down Expand Up @@ -227,7 +227,7 @@ impl Context {
fn display(&self, f: &mut fmt::Formatter<'_>, note: Option<&str>) -> fmt::Result {
const MAX_COLS: usize = 95;
let mut tail = true; // End with a tailing line ╵
#[allow(
#[expect(
clippy::cast_sign_loss,
clippy::cast_precision_loss,
clippy::cast_possible_truncation
Expand Down Expand Up @@ -330,7 +330,7 @@ impl Context {
write!(f, "\n{:pad$} ╷", "", pad = margin)?;
let mut number = *start_linenumber + 1;
let mut highlights_peek = highlights.iter().peekable();
#[allow(unused)]

for (index, line) in lines.iter().enumerate() {
number += 1;
write!(f, "\n{number:<margin$} │ {line}")?;
Expand Down
6 changes: 3 additions & 3 deletions rustyms/src/error/custom_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::error;
use std::fmt;

/// An error. Stored as a pointer to a structure on the heap to prevent large sizes which could be
/// detremental to performance for the happy path.
/// detrimental to performance for the happy path.
#[derive(Serialize, Deserialize, PartialEq, Clone, Eq, Hash)]
pub struct CustomError {
content: Box<InnerError>,
Expand All @@ -29,7 +29,7 @@ struct InnerError {
underlying_errors: Vec<CustomError>,
}

#[allow(clippy::needless_pass_by_value, dead_code)] // The impl ToString should be passed like this, otherwise &str gives errors
#[expect(clippy::needless_pass_by_value)] // The impl ToString should be passed like this, otherwise &str gives errors
impl CustomError {
/// Create a new `CustomError`.
///
Expand Down Expand Up @@ -233,7 +233,7 @@ impl fmt::Display for CustomError {
impl error::Error for CustomError {}

#[cfg(test)]
#[allow(clippy::print_stdout, clippy::missing_panics_doc)]
#[expect(clippy::print_stdout, clippy::missing_panics_doc)]
mod tests {
use super::*;
use crate::error::FilePosition;
Expand Down
1 change: 0 additions & 1 deletion rustyms/src/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ mod context;
/// An error with all its properties
mod custom_error;

#[allow(unused_imports)]
pub use context::{Context, FilePosition};
pub use custom_error::CustomError;
13 changes: 6 additions & 7 deletions rustyms/src/formula.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl From<&MolecularFormula> for OrderedMass {

impl MolecularFormula {
/// The mass of the molecular formula of this element, if all element species (isotopes) exists
#[allow(clippy::missing_panics_doc)]
#[expect(clippy::missing_panics_doc)]
pub fn monoisotopic_mass(&self) -> Mass {
let mut mass = da(*self.additional_mass);
for (e, i, n) in &self.elements {
Expand All @@ -32,7 +32,7 @@ impl MolecularFormula {
}

/// The average weight of the molecular formula of this element, if all element species (isotopes) exists
#[allow(clippy::missing_panics_doc)]
#[expect(clippy::missing_panics_doc)]
pub fn average_weight(&self) -> Mass {
let mut mass = da(*self.additional_mass); // Technically this is wrong, the additional mass is defined to be monoisotopic
for (e, i, n) in &self.elements {
Expand All @@ -49,7 +49,6 @@ impl MolecularFormula {
/// but will be in the form of monoisotopic exact mass + n, where n is the integer dalton offset for that isomer.
///
/// Only available with crate feature 'isotopes'.
#[allow(clippy::missing_panics_doc)]
#[cfg(feature = "isotopes")]
pub fn most_abundant_mass(&self) -> Mass {
let isotopes = self.isotopic_distribution(0.01);
Expand Down Expand Up @@ -146,7 +145,7 @@ impl std::fmt::Display for AmbiguousLabel {
}
}

#[allow(clippy::missing_panics_doc)] // Cannot panic
#[expect(clippy::missing_panics_doc)] // Cannot panic
fn to_subscript_num(input: isize) -> String {
let text = input.to_string();
let mut output = String::new();
Expand All @@ -160,7 +159,7 @@ fn to_subscript_num(input: isize) -> String {
output
}

#[allow(clippy::missing_panics_doc)] // Cannot panic
#[expect(clippy::missing_panics_doc)] // Cannot panic
fn to_superscript_num(input: u16) -> String {
let text = input.to_string();
let mut output = String::new();
Expand All @@ -186,7 +185,7 @@ impl std::fmt::Display for MolecularFormula {
}

#[cfg(test)]
#[allow(clippy::missing_panics_doc)]
#[expect(clippy::missing_panics_doc)]
mod tests {
use crate::{
model::ChargeRange, molecular_formula, AminoAcid, Fragment, MolecularCharge,
Expand Down Expand Up @@ -292,7 +291,7 @@ mod tests {
}

#[test]
#[allow(clippy::similar_names)]
#[expect(clippy::similar_names)]
fn labels() {
let labelled = AminoAcid::AmbiguousAsparagine.formulas();
let unlabelled: crate::Multi<MolecularFormula> =
Expand Down
12 changes: 6 additions & 6 deletions rustyms/src/fragment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl Fragment {
/// Generate a list of possible fragments from the list of possible preceding termini and neutral losses
/// # Panics
/// When the charge range results in a negative charge
#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
#[must_use]
pub fn generate_all(
theoretical_mass: &Multi<MolecularFormula>,
Expand Down Expand Up @@ -335,7 +335,7 @@ pub enum DiagnosticPosition {

/// The possible types of fragments
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize, Default)]
#[allow(non_camel_case_types)]
#[expect(non_camel_case_types)]
pub enum FragmentType {
/// a
a(PeptidePosition),
Expand Down Expand Up @@ -547,7 +547,7 @@ impl Display for FragmentType {

/// The possible kinds of N terminal backbone fragments.
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
#[allow(non_camel_case_types)]
#[expect(non_camel_case_types)]
pub enum BackboneNFragment {
/// a
a,
Expand All @@ -573,7 +573,7 @@ impl Display for BackboneNFragment {

/// The possible kinds of C terminal backbone fragments.
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
#[allow(non_camel_case_types)]
#[expect(non_camel_case_types)]
pub enum BackboneCFragment {
/// x
x,
Expand All @@ -599,7 +599,7 @@ impl Display for BackboneCFragment {

/// The possible kinds of fragments, same options as [`FragmentType`] but without any additional data
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
#[allow(non_camel_case_types)]
#[expect(non_camel_case_types)]
pub enum FragmentKind {
/// a
a,
Expand Down Expand Up @@ -701,7 +701,7 @@ impl std::fmt::Display for GlycanBreakPos {
}

#[cfg(test)]
#[allow(clippy::missing_panics_doc)]
#[expect(clippy::missing_panics_doc)]
mod tests {

use crate::{AminoAcid, MultiChemical};
Expand Down
Loading

0 comments on commit ca2f8a4

Please sign in to comment.