Skip to content

Commit

Permalink
Cleanup custom lints
Browse files Browse the repository at this point in the history
- Move custom lints from lib.rs/main.rs into Cargo.toml
- Remove most custom lints, as this is overkill and difficult to
  maintain
- Fix new lints from most recent Rust version
  • Loading branch information
shssoichiro committed Jun 20, 2024
1 parent 953fbb2 commit c0afbf9
Show file tree
Hide file tree
Showing 17 changed files with 112 additions and 341 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rav1e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Run clippy
uses: clechasseur/rs-clippy-check@v3
with:
args: -- -D warnings --verbose -A clippy::wrong-self-convention -A clippy::many_single_char_names -A clippy::upper-case-acronyms
args: -- -D warnings

msrv:
runs-on: ubuntu-22.04
Expand Down
12 changes: 12 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,15 @@ members = [".", "ivf"]

[package.metadata.docs.rs]
no-default-features = true

[lints.clippy]
doc_link_with_quotes = "warn"
doc_markdown = "warn"
missing_errors_doc = "warn"
missing_panics_doc = "warn"
missing_safety_doc = "warn"
comparison_chain = "allow"
enum_variant_names = "allow"
needless_range_loop = "allow"
too_many_arguments = "allow"
upper_case_acronyms = "allow"
12 changes: 12 additions & 0 deletions ivf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,15 @@ homepage = "https://github.com/xiph/rav1e"

[dependencies]
bitstream-io = "2"

[lints.clippy]
doc_link_with_quotes = "warn"
doc_markdown = "warn"
missing_errors_doc = "warn"
missing_panics_doc = "warn"
missing_safety_doc = "warn"
comparison_chain = "allow"
enum_variant_names = "allow"
needless_range_loop = "allow"
too_many_arguments = "allow"
upper_case_acronyms = "allow"
39 changes: 6 additions & 33 deletions ivf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,12 @@
// Media Patent License 1.0 was not distributed with this source code in the
// PATENTS file, you can obtain it at www.aomedia.org/license/patent.

#![deny(bare_trait_objects)]
#![allow(clippy::cast_lossless)]
#![allow(clippy::cast_ptr_alignment)]
#![allow(clippy::cognitive_complexity)]
#![allow(clippy::needless_range_loop)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::verbose_bit_mask)]
#![allow(clippy::unreadable_literal)]
#![allow(clippy::many_single_char_names)]
// Performance lints
#![warn(clippy::linkedlist)]
#![warn(clippy::missing_const_for_fn)]
#![warn(clippy::mutex_integer)]
#![warn(clippy::suboptimal_flops)]
// Correctness lints
#![warn(clippy::expl_impl_clone_on_copy)]
#![warn(clippy::mem_forget)]
#![warn(clippy::path_buf_push_overwrite)]
// Clarity/formatting lints
#![warn(clippy::map_flatten)]
#![warn(clippy::mut_mut)]
#![warn(clippy::needless_borrow)]
#![warn(clippy::needless_continue)]
#![warn(clippy::range_plus_one)]
// Documentation lints
#![warn(clippy::doc_markdown)]
#![warn(clippy::missing_errors_doc)]
#![warn(clippy::missing_panics_doc)]

/// Simple ivf muxer
///
use bitstream_io::{BitRead, BitReader, BitWrite, BitWriter, LittleEndian};
//! Simple ivf muxer

use std::io;

use bitstream_io::{BitRead, BitReader, BitWrite, BitWriter, LittleEndian};

/// # Panics
///
/// - If header cannot be written to output file.
Expand Down Expand Up @@ -137,9 +109,10 @@ pub fn read_packet(r: &mut dyn io::Read) -> io::Result<Packet> {

#[cfg(test)]
mod tests {
use crate::{read_header, read_packet};
use std::io::{BufReader, ErrorKind::InvalidData};

use crate::{read_header, read_packet};

#[test]
fn read_invalid_headers() {
// Invalid magic.
Expand Down
17 changes: 8 additions & 9 deletions src/api/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@
// PATENTS file, you can obtain it at www.aomedia.org/license/patent.
#![deny(missing_docs)]

use std::fmt;
use std::io;
use std::sync::Arc;

use bitstream_io::*;

use crate::api::color::*;
use crate::api::config::*;
use crate::api::internal::*;
use crate::api::util::*;

use bitstream_io::*;

use crate::encoder::*;
use crate::frame::*;
use crate::util::Pixel;

use std::fmt;
use std::io;
use std::sync::Arc;

/// The encoder context.
///
/// Contains the encoding state.
Expand Down Expand Up @@ -122,8 +121,8 @@ impl<T: Pixel> Context<T> {
|| (self.inner.config.still_picture && self.inner.frame_count > 0)
{
return Err(EncoderStatus::EnoughData);
// The rate control can process at most std::i32::MAX frames
} else if self.inner.frame_count == std::i32::MAX as u64 - 1 {
// The rate control can process at most i32::MAX frames
} else if self.inner.frame_count == i32::MAX as u64 - 1 {
self.inner.limit = Some(self.inner.frame_count);
self.is_flushing = true;
}
Expand Down
16 changes: 10 additions & 6 deletions src/asm/x86/sad_plane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
// Media Patent License 1.0 was not distributed with this source code in the
// PATENTS file, you can obtain it at www.aomedia.org/license/patent.

use crate::cpu_features::CpuFeatureLevel;
use crate::sad_plane::*;
use crate::util::{Pixel, PixelType};
use std::mem;

use v_frame::plane::Plane;

use std::mem;
use crate::cpu_features::CpuFeatureLevel;
use crate::sad_plane::*;
use crate::util::{Pixel, PixelType};

macro_rules! decl_sad_plane_fn {
($($f:ident),+) => {
Expand Down Expand Up @@ -46,8 +46,12 @@ pub(crate) fn sad_plane_internal<T: Pixel>(
// SAFETY: Calls Assembly code.
unsafe {
let result = $func(
mem::transmute(src.data_origin().as_ptr()),
mem::transmute(dst.data_origin().as_ptr()),
mem::transmute::<*const T, *const u8>(
src.data_origin().as_ptr(),
),
mem::transmute::<*const T, *const u8>(
dst.data_origin().as_ptr(),
),
src.cfg.stride,
src.cfg.width,
src.cfg.height,
Expand Down
3 changes: 3 additions & 0 deletions src/bin/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ pub struct ParsedCliOptions {
pub metrics_enabled: MetricsEnabled,
pub pass1file_name: Option<PathBuf>,
pub pass2file_name: Option<PathBuf>,
#[cfg(feature = "serialize")]
pub save_config: Option<PathBuf>,
pub photon_noise: u8,
#[cfg(feature = "unstable")]
Expand Down Expand Up @@ -390,6 +391,7 @@ fn build_speed_long_help() -> Option<&'static str> {
pub fn parse_cli() -> Result<ParsedCliOptions, CliError> {
let matches = CliOptions::parse();

#[cfg(feature = "serialize")]
let mut save_config_path = None;
let mut enc = None;

Expand Down Expand Up @@ -489,6 +491,7 @@ pub fn parse_cli() -> Result<ParsedCliOptions, CliError> {
threads: matches.threads,
pass1file_name: matches.first_pass.clone(),
pass2file_name: matches.second_pass.clone(),
#[cfg(feature = "serialize")]
save_config: save_config_path,
photon_noise: matches.photon_noise,
force_highbitdepth: matches.high_bitdepth,
Expand Down
4 changes: 1 addition & 3 deletions src/bin/decoder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// PATENTS file, you can obtain it at www.aomedia.org/license/patent.

use rav1e::prelude::*;
use std::io;

pub mod y4m;

Expand All @@ -25,13 +24,12 @@ pub trait Decoder: Send {
}

#[derive(Debug)]
#[allow(clippy::upper_case_acronyms)]
pub enum DecodeError {
EOF,
BadInput,
UnknownColorspace,
ParseError,
IoError(io::Error),
IoError,
MemoryLimitExceeded,
}

Expand Down
2 changes: 1 addition & 1 deletion src/bin/decoder/y4m.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl From<y4m::Error> for DecodeError {
y4m::Error::BadInput => DecodeError::BadInput,
y4m::Error::UnknownColorspace => DecodeError::UnknownColorspace,
y4m::Error::ParseError(_) => DecodeError::ParseError,
y4m::Error::IoError(e) => DecodeError::IoError(e),
y4m::Error::IoError(_) => DecodeError::IoError,
// Note that this error code has nothing to do with the system running out of memory,
// it means the y4m decoder has exceeded its memory allocation limit.
y4m::Error::OutOfMemory => DecodeError::MemoryLimitExceeded,
Expand Down
74 changes: 0 additions & 74 deletions src/bin/rav1e-ch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,80 +7,6 @@
// Media Patent License 1.0 was not distributed with this source code in the
// PATENTS file, you can obtain it at www.aomedia.org/license/patent.

// Safety lints
#![deny(bare_trait_objects)]
#![deny(clippy::as_ptr_cast_mut)]
#![deny(clippy::large_stack_arrays)]
// Performance lints
#![warn(clippy::inefficient_to_string)]
#![warn(clippy::invalid_upcast_comparisons)]
#![warn(clippy::iter_with_drain)]
#![warn(clippy::linkedlist)]
#![warn(clippy::mutex_integer)]
#![warn(clippy::naive_bytecount)]
#![warn(clippy::needless_bitwise_bool)]
#![warn(clippy::needless_collect)]
#![warn(clippy::or_fun_call)]
#![warn(clippy::stable_sort_primitive)]
#![warn(clippy::suboptimal_flops)]
#![warn(clippy::trivial_regex)]
#![warn(clippy::trivially_copy_pass_by_ref)]
#![warn(clippy::unnecessary_join)]
#![warn(clippy::unused_async)]
#![warn(clippy::zero_sized_map_values)]
// Correctness lints
#![deny(clippy::case_sensitive_file_extension_comparisons)]
#![deny(clippy::copy_iterator)]
#![deny(clippy::expl_impl_clone_on_copy)]
#![deny(clippy::float_cmp)]
#![warn(clippy::imprecise_flops)]
#![deny(clippy::manual_instant_elapsed)]
#![deny(clippy::mem_forget)]
#![deny(clippy::path_buf_push_overwrite)]
#![deny(clippy::same_functions_in_if_condition)]
#![deny(clippy::unchecked_duration_subtraction)]
#![deny(clippy::unicode_not_nfc)]
// Clarity/formatting lints
#![warn(clippy::checked_conversions)]
#![allow(clippy::comparison_chain)]
#![warn(clippy::derive_partial_eq_without_eq)]
#![allow(clippy::enum_variant_names)]
#![warn(clippy::explicit_deref_methods)]
#![warn(clippy::filter_map_next)]
#![warn(clippy::flat_map_option)]
#![warn(clippy::fn_params_excessive_bools)]
#![warn(clippy::implicit_clone)]
#![warn(clippy::iter_not_returning_iterator)]
#![warn(clippy::iter_on_empty_collections)]
#![warn(clippy::macro_use_imports)]
#![warn(clippy::manual_clamp)]
#![warn(clippy::manual_let_else)]
#![warn(clippy::manual_ok_or)]
#![warn(clippy::manual_string_new)]
#![warn(clippy::map_flatten)]
#![warn(clippy::match_bool)]
#![warn(clippy::mut_mut)]
#![warn(clippy::needless_borrow)]
#![warn(clippy::needless_continue)]
#![allow(clippy::needless_range_loop)]
#![allow(clippy::too_many_arguments)]
#![warn(clippy::range_minus_one)]
#![warn(clippy::range_plus_one)]
#![warn(clippy::ref_binding_to_reference)]
#![warn(clippy::ref_option_ref)]
#![warn(clippy::trait_duplication_in_bounds)]
#![warn(clippy::unused_peekable)]
#![warn(clippy::unused_rounding)]
#![warn(clippy::unused_self)]
#![allow(clippy::upper_case_acronyms)]
#![warn(clippy::verbose_bit_mask)]
#![warn(clippy::verbose_file_reads)]
// Documentation lints
#![warn(clippy::doc_link_with_quotes)]
#![warn(clippy::doc_markdown)]
#![warn(clippy::missing_errors_doc)]
#![warn(clippy::missing_panics_doc)]

#[macro_use]
extern crate log;

Expand Down
74 changes: 0 additions & 74 deletions src/bin/rav1e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,80 +7,6 @@
// Media Patent License 1.0 was not distributed with this source code in the
// PATENTS file, you can obtain it at www.aomedia.org/license/patent.

// Safety lints
#![deny(bare_trait_objects)]
#![deny(clippy::as_ptr_cast_mut)]
#![deny(clippy::large_stack_arrays)]
// Performance lints
#![warn(clippy::inefficient_to_string)]
#![warn(clippy::invalid_upcast_comparisons)]
#![warn(clippy::iter_with_drain)]
#![warn(clippy::linkedlist)]
#![warn(clippy::mutex_integer)]
#![warn(clippy::naive_bytecount)]
#![warn(clippy::needless_bitwise_bool)]
#![warn(clippy::needless_collect)]
#![warn(clippy::or_fun_call)]
#![warn(clippy::stable_sort_primitive)]
#![warn(clippy::suboptimal_flops)]
#![warn(clippy::trivial_regex)]
#![warn(clippy::trivially_copy_pass_by_ref)]
#![warn(clippy::unnecessary_join)]
#![warn(clippy::unused_async)]
#![warn(clippy::zero_sized_map_values)]
// Correctness lints
#![deny(clippy::case_sensitive_file_extension_comparisons)]
#![deny(clippy::copy_iterator)]
#![deny(clippy::expl_impl_clone_on_copy)]
#![deny(clippy::float_cmp)]
#![warn(clippy::imprecise_flops)]
#![deny(clippy::manual_instant_elapsed)]
#![deny(clippy::mem_forget)]
#![deny(clippy::path_buf_push_overwrite)]
#![deny(clippy::same_functions_in_if_condition)]
#![deny(clippy::unchecked_duration_subtraction)]
#![deny(clippy::unicode_not_nfc)]
// Clarity/formatting lints
#![warn(clippy::checked_conversions)]
#![allow(clippy::comparison_chain)]
#![warn(clippy::derive_partial_eq_without_eq)]
#![allow(clippy::enum_variant_names)]
#![warn(clippy::explicit_deref_methods)]
#![warn(clippy::filter_map_next)]
#![warn(clippy::flat_map_option)]
#![warn(clippy::fn_params_excessive_bools)]
#![warn(clippy::implicit_clone)]
#![warn(clippy::iter_not_returning_iterator)]
#![warn(clippy::iter_on_empty_collections)]
#![warn(clippy::macro_use_imports)]
#![warn(clippy::manual_clamp)]
#![warn(clippy::manual_let_else)]
#![warn(clippy::manual_ok_or)]
#![warn(clippy::manual_string_new)]
#![warn(clippy::map_flatten)]
#![warn(clippy::match_bool)]
#![warn(clippy::mut_mut)]
#![warn(clippy::needless_borrow)]
#![warn(clippy::needless_continue)]
#![allow(clippy::needless_range_loop)]
#![allow(clippy::too_many_arguments)]
#![warn(clippy::range_minus_one)]
#![warn(clippy::range_plus_one)]
#![warn(clippy::ref_binding_to_reference)]
#![warn(clippy::ref_option_ref)]
#![warn(clippy::trait_duplication_in_bounds)]
#![warn(clippy::unused_peekable)]
#![warn(clippy::unused_rounding)]
#![warn(clippy::unused_self)]
#![allow(clippy::upper_case_acronyms)]
#![warn(clippy::verbose_bit_mask)]
#![warn(clippy::verbose_file_reads)]
// Documentation lints
#![warn(clippy::doc_link_with_quotes)]
#![warn(clippy::doc_markdown)]
#![warn(clippy::missing_errors_doc)]
#![warn(clippy::missing_panics_doc)]

#[macro_use]
extern crate log;

Expand Down
Loading

0 comments on commit c0afbf9

Please sign in to comment.