Skip to content

Commit

Permalink
Clean up clippy attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
t4ccer committed Sep 14, 2024
1 parent f22e063 commit 977aeeb
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 44 deletions.
5 changes: 1 addition & 4 deletions cgt/drawing/svg.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
//! Simple SVG immediate drawing utilities
#![cfg_attr(
feature = "cargo-clippy",
allow(clippy::missing_errors_doc, clippy::new_ret_no_self)
)]
#![allow(clippy::missing_errors_doc, clippy::new_ret_no_self)]

use std::fmt::{self, Write};

Expand Down
5 changes: 1 addition & 4 deletions cgt/graph/directed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ pub struct Graph {
}

impl Display for Graph {
#[cfg_attr(
feature = "cargo-clippy",
allow(clippy::missing_inline_in_public_items)
)]
#[allow(clippy::missing_inline_in_public_items)]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
for (idx, elem) in self.adjacency_matrix.iter().enumerate() {
write!(f, "{}", u8::from(*elem))?;
Expand Down
2 changes: 1 addition & 1 deletion cgt/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub trait FiniteGrid: Grid + Sized {
fn zero_size() -> Self;

/// Default, one-line display function for grids using `|` as row separator
#[cfg_attr(feature = "cargo-clippy", allow(clippy::missing_errors_doc))]
#[allow(clippy::missing_errors_doc)]
fn display(&self, w: &mut impl Write, sep: char) -> std::fmt::Result
where
Self::Item: CharTile,
Expand Down
2 changes: 1 addition & 1 deletion cgt/grid/small_bit_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ where

/// Rotate grid 90° clockwise
#[must_use]
#[cfg_attr(feature = "cargo-clippy", allow(clippy::missing_panics_doc))]
#[allow(clippy::missing_panics_doc)]
pub fn rotate(&self) -> Self {
let mut result = Self::empty(self.height(), self.width()).unwrap();
for y in 0..self.height() {
Expand Down
13 changes: 3 additions & 10 deletions cgt/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@
//! [calculations on canonical forms](crate::short::partizan::canonical_form::CanonicalForm)
#![warn(missing_docs)]
#![cfg_attr(
feature = "cargo-clippy",
warn(
clippy::all,
clippy::nursery,
clippy::pedantic,
),
allow(
#![warn(clippy::all, clippy::nursery, clippy::pedantic)]
#![allow(
clippy::new_without_default,
clippy::similar_names,
clippy::must_use_candidate,
Expand All @@ -27,8 +21,7 @@
clippy::needless_update,
clippy::cast_precision_loss,
clippy::missing_panics_doc
)
)]
)]

pub mod drawing;
pub mod genetic_algorithm;
Expand Down
2 changes: 1 addition & 1 deletion cgt/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ macro_rules! if_chain {
pub(crate) use if_chain;

#[test]
#[cfg_attr(feature = "cargo-clippy", allow(clippy::missing_const_for_fn))]
#[allow(clippy::missing_const_for_fn)]
fn test_if_chain() {
let mut _bar;

Expand Down
14 changes: 7 additions & 7 deletions cgt/short/partizan/canonical_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl Nus {
/// Parse nus from string, using notation without pluses between number, up, and star components
///
/// Pattern: `\d*([v^]\d*)?(\*\d*)`
#[cfg_attr(feature = "cargo-clippy", allow(clippy::missing_errors_doc))]
#[allow(clippy::missing_errors_doc)]
pub fn parse(input: &str) -> nom::IResult<&str, Self> {
let full_input = input;
// This flag is set if we explicitly parse a number, rather than set it to zero if
Expand Down Expand Up @@ -380,7 +380,7 @@ impl Moves {

/// Try converting moves to NUS. Returns [None] if moves do not form a NUS
// Macro expands to loads of ifs
#[cfg_attr(feature = "cargo-clippy", allow(clippy::cognitive_complexity))]
#[allow(clippy::cognitive_complexity)]
pub fn to_nus(&self) -> Option<Nus> {
let mut result = Nus::new_integer(0);

Expand Down Expand Up @@ -736,7 +736,7 @@ impl Moves {
}

/// Print moves with NUS unwrapped using `{G^L | G^R}` notation
#[cfg_attr(feature = "cargo-clippy", allow(clippy::missing_errors_doc))]
#[allow(clippy::missing_errors_doc)]
pub fn print_deep(&self, f: &mut impl Write) -> fmt::Result {
display::braces(f, |f| {
for (idx, l) in self.left.iter().enumerate() {
Expand All @@ -758,7 +758,7 @@ impl Moves {

/// Print moves to string with NUS unwrapped using `{G^L | G^R}` notation
// Write to `String` never panics
#[cfg_attr(feature = "cargo-clippy", allow(clippy::missing_panics_doc))]
#[allow(clippy::missing_panics_doc)]
pub fn print_deep_to_str(&self) -> String {
let mut buf = String::new();
Self::print_deep(self, &mut buf).unwrap();
Expand Down Expand Up @@ -1035,7 +1035,7 @@ impl CanonicalForm {
}

/// Calculate temperature of the game. Avoids computing a thermograph is game is a NUS
#[cfg_attr(feature = "cargo-clippy", allow(clippy::missing_panics_doc))]
#[allow(clippy::missing_panics_doc)]
pub fn temperature(&self) -> DyadicRationalNumber {
match self.inner {
CanonicalFormInner::Nus(nus) => {
Expand Down Expand Up @@ -1208,7 +1208,7 @@ impl CanonicalForm {

/// A remote star of game `g` is a nimber `*N` if no position of `g` including `g` has value `N*`
#[must_use]
#[cfg_attr(feature = "cargo-clippy", allow(clippy::or_fun_call))]
#[allow(clippy::or_fun_call)]
pub fn far_star(&self) -> Nimber {
if let CanonicalFormInner::Nus(ref nus) = self.inner {
if nus.is_nimber() {
Expand Down Expand Up @@ -1298,7 +1298,7 @@ impl CanonicalForm {
}

/// Parse game using `{a,b,...|c,d,...}` notation
#[cfg_attr(feature = "cargo-clippy", allow(clippy::missing_errors_doc))]
#[allow(clippy::missing_errors_doc)]
pub fn parse(input: &str) -> nom::IResult<&str, Self> {
alt((
|input| Nus::parse(input).map(|(input, nus)| (input, Self::new_nus(nus))),
Expand Down
3 changes: 1 addition & 2 deletions cgt/short/partizan/games/domineering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,12 @@ where
/// ```
// Panic at `Self::empty(minimized_width, minimized_height).unwrap();` is unreachable
#[must_use]
#[cfg_attr(feature = "cargo-clippy", allow(clippy::missing_panics_doc))]
#[allow(clippy::missing_panics_doc)]
pub fn move_top_left(&self) -> Self {
Self::new(move_top_left(&self.grid, Tile::is_non_blocking))
}
}

#[cfg(not(tarpaulin_include))]
impl<G> Svg for Domineering<G>
where
G: Grid<Item = Tile> + FiniteGrid,
Expand Down
1 change: 0 additions & 1 deletion cgt/short/partizan/games/fission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ where
}
}

#[cfg(not(tarpaulin_include))]
impl<G> Svg for Fission<G>
where
G: Grid<Item = Tile> + FiniteGrid,
Expand Down
1 change: 0 additions & 1 deletion cgt/short/partizan/games/ski_jumps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ where
}
}

#[cfg(not(tarpaulin_include))]
impl<G> Svg for SkiJumps<G>
where
G: Grid<Item = Tile> + FiniteGrid,
Expand Down
1 change: 0 additions & 1 deletion cgt/short/partizan/games/toads_and_frogs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ impl Display for ToadsAndFrogs {
}
}

#[cfg(not(tarpaulin_include))]
impl Svg for ToadsAndFrogs {
fn to_svg<W>(&self, buf: &mut W) -> fmt::Result
where
Expand Down
7 changes: 2 additions & 5 deletions cgt/short/partizan/thermograph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Thermograph {
}

/// Get the temperature of the thermograph where both scaffolds merge into a mast
#[cfg_attr(feature = "cargo-clippy", allow(clippy::missing_panics_doc))]
#[allow(clippy::missing_panics_doc)]
pub fn temperature(&self) -> DyadicRationalNumber {
let left = self.get_left_temperature();
let right = self.get_right_temperature();
Expand Down Expand Up @@ -79,10 +79,7 @@ impl Thermograph {

/// Calculate a thermograph given left and right scaffold. Note that scaffolds should be
/// [tilted](Trajectory::tilt) before.
#[cfg_attr(
feature = "cargo-clippy",
allow(clippy::cognitive_complexity, clippy::missing_panics_doc)
)]
#[allow(clippy::cognitive_complexity, clippy::missing_panics_doc)]
pub fn thermographic_intersection(
left_scaffold: Trajectory,
right_scaffold: Trajectory,
Expand Down
5 changes: 1 addition & 4 deletions cgt/short/partizan/trajectory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,7 @@ impl Trajectory {
self.minmax::<false>(other)
}

#[cfg_attr(
feature = "cargo-clippy",
allow(clippy::useless_let_if_seq, clippy::cognitive_complexity)
)]
#[allow(clippy::useless_let_if_seq, clippy::cognitive_complexity)]
fn minmax<const MAX: bool>(&self, other: &Self) -> Self {
let max_multiplier = if MAX { -1 } else { 1 };
// We scan down through the critical points. We keep track of which
Expand Down
4 changes: 2 additions & 2 deletions cgt/short/partizan/transposition_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ impl<G> TranspositionTable<G> for ParallelTranspositionTable<G>
where
G: Eq + Hash,
{
#[cfg_attr(feature = "cargo-clippy", allow(clippy::missing_panics_doc))]
#[allow(clippy::missing_panics_doc)]
#[inline]
fn lookup_position(&self, position: &G) -> Option<CanonicalForm> {
self.positions
.get(position)
.map(|id| self.values[*id].clone())
}

#[cfg_attr(feature = "cargo-clippy", allow(clippy::missing_panics_doc))]
#[allow(clippy::missing_panics_doc)]
#[inline]
fn insert_position(&self, position: G, value: CanonicalForm) {
if let Some(known) = self.known_values.get(&value) {
Expand Down

0 comments on commit 977aeeb

Please sign in to comment.