Fix or silence all remaining clippy warnings

Also ignore common errors we don't care about when running clippy and
make clippy errors fail the CI.
This commit is contained in:
Sebastian Dröge 2019-09-07 10:42:07 +03:00
parent 2c7775125a
commit 83cc8104a1
13 changed files with 20 additions and 35 deletions

View file

@ -85,7 +85,6 @@ clippy:
extends: '.tarball_setup' extends: '.tarball_setup'
image: "rust:slim" image: "rust:slim"
stage: 'extras' stage: 'extras'
allow_failure: true
script: script:
- rustup component add clippy-preview - rustup component add clippy-preview
- cargo clippy --color=always --all --all-features - cargo clippy --color=always --all --all-features -- -A clippy::redundant_pattern_matching -A clippy::single_match -A clippy::cast_lossless

View file

@ -54,6 +54,7 @@ struct State {
} }
struct AudioEcho { struct AudioEcho {
#[allow(dead_code)]
cat: gst::DebugCategory, cat: gst::DebugCategory,
settings: Mutex<Settings>, settings: Mutex<Settings>,
state: Mutex<Option<State>>, state: Mutex<Option<State>>,

View file

@ -164,7 +164,7 @@ impl BaseParseImpl for CdgParse {
.enumerate() .enumerate()
.find(|(_, byte)| (*byte & CDG_MASK == CDG_COMMAND)) .find(|(_, byte)| (*byte & CDG_MASK == CDG_COMMAND))
.map(|(i, _)| i) .map(|(i, _)| i)
.unwrap_or(input.get_size()) // skip the whole buffer .unwrap_or_else(|| input.get_size()) // skip the whole buffer
as u32 as u32
}; };

View file

@ -133,6 +133,7 @@ impl MccEnc {
}); });
} }
#[allow(clippy::write_with_newline)]
fn generate_headers(&self, _state: &State, buffer: &mut Vec<u8>) -> Result<(), gst::FlowError> { fn generate_headers(&self, _state: &State, buffer: &mut Vec<u8>) -> Result<(), gst::FlowError> {
let settings = self.settings.lock().unwrap(); let settings = self.settings.lock().unwrap();

View file

@ -94,6 +94,8 @@ struct State {
need_flush_stop: bool, need_flush_stop: bool,
} }
type CombineError<'a> = combine::easy::Errors<u8, &'a [u8], combine::stream::PointerOffset>;
impl Default for State { impl Default for State {
fn default() -> Self { fn default() -> Self {
Self { Self {
@ -156,16 +158,7 @@ fn parse_timecode_rate(
} }
impl State { impl State {
fn get_line( fn get_line(&mut self, drain: bool) -> Result<Option<MccLine>, (&[u8], CombineError)> {
&mut self,
drain: bool,
) -> Result<
Option<MccLine>,
(
&[u8],
combine::easy::Errors<u8, &[u8], combine::stream::PointerOffset>,
),
> {
let line = if self.replay_last_line { let line = if self.replay_last_line {
self.replay_last_line = false; self.replay_last_line = false;
&self.last_raw_line &self.last_raw_line
@ -706,12 +699,10 @@ impl MccParse {
mode: gst::PadMode, mode: gst::PadMode,
active: bool, active: bool,
) -> Result<(), gst::LoggableError> { ) -> Result<(), gst::LoggableError> {
if active { if mode == gst::PadMode::Pull {
if mode == gst::PadMode::Pull { if active {
self.start_task(element)?; self.start_task(element)?;
} } else {
} else {
if mode == gst::PadMode::Pull {
let _ = self.sinkpad.stop_task(); let _ = self.sinkpad.stop_task();
} }
} }

View file

@ -52,6 +52,8 @@ struct State {
last_timecode: Option<gst_video::ValidVideoTimeCode>, last_timecode: Option<gst_video::ValidVideoTimeCode>,
} }
type CombineError<'a> = combine::easy::Errors<u8, &'a [u8], combine::stream::PointerOffset>;
impl Default for State { impl Default for State {
fn default() -> Self { fn default() -> Self {
Self { Self {
@ -68,16 +70,7 @@ impl Default for State {
} }
impl State { impl State {
fn get_line( fn get_line(&mut self, drain: bool) -> Result<Option<SccLine>, (&[u8], CombineError)> {
&mut self,
drain: bool,
) -> Result<
Option<SccLine>,
(
&[u8],
combine::easy::Errors<u8, &[u8], combine::stream::PointerOffset>,
),
> {
let line = match self.reader.get_line_with_drain(drain) { let line = match self.reader.get_line_with_drain(drain) {
None => { None => {
return Ok(None); return Ok(None);
@ -186,7 +179,7 @@ impl State {
&mut self, &mut self,
buffer: &mut gst::buffer::Buffer, buffer: &mut gst::buffer::Buffer,
timecode: &gst_video::ValidVideoTimeCode, timecode: &gst_video::ValidVideoTimeCode,
framerate: &gst::Fraction, framerate: gst::Fraction,
element: &gst::Element, element: &gst::Element,
) { ) {
let buffer = buffer.get_mut().unwrap(); let buffer = buffer.get_mut().unwrap();
@ -341,7 +334,7 @@ impl SccParse {
buf_mut.copy_from_slice(0, d).unwrap(); buf_mut.copy_from_slice(0, d).unwrap();
} }
state.add_buffer_metadata(&mut buffer, &timecode, &framerate, element); state.add_buffer_metadata(&mut buffer, &timecode, framerate, element);
timecode.increment_frame(); timecode.increment_frame();
let buffers = buffers.get_mut().unwrap(); let buffers = buffers.get_mut().unwrap();
buffers.add(buffer); buffers.add(buffer);

View file

@ -46,6 +46,7 @@ struct FlvDemux {
state: Mutex<State>, state: Mutex<State>,
} }
#[allow(clippy::large_enum_variant)]
#[derive(Debug)] #[derive(Debug)]
enum State { enum State {
Stopped, Stopped,
@ -1419,6 +1420,7 @@ impl VideoFormat {
} }
} }
#[allow(clippy::useless_let_if_seq)]
fn update_with_metadata(&mut self, metadata: &Metadata) -> bool { fn update_with_metadata(&mut self, metadata: &Metadata) -> bool {
let mut changed = false; let mut changed = false;

View file

@ -123,6 +123,7 @@ static PROPERTIES: [subclass::Property; 6] = [
}), }),
]; ];
#[allow(clippy::large_enum_variant)]
#[derive(Debug)] #[derive(Debug)]
enum State { enum State {
Stopped, Stopped,

View file

@ -28,6 +28,7 @@ use gst_base::subclass::prelude::*;
use crate::s3url::*; use crate::s3url::*;
use crate::s3utils; use crate::s3utils;
#[allow(clippy::large_enum_variant)]
enum StreamingState { enum StreamingState {
Stopped, Stopped,
Started { Started {

View file

@ -16,7 +16,6 @@
// Boston, MA 02110-1335, USA. // Boston, MA 02110-1335, USA.
#![crate_type = "cdylib"] #![crate_type = "cdylib"]
#![allow(clippy::cast_lossless)]
extern crate libc; extern crate libc;

View file

@ -923,8 +923,6 @@ impl ProxySrc {
use gst::EventView; use gst::EventView;
let mut new_event = None; let mut new_event = None;
#[allow(clippy::redundant_pattern_matching)]
#[allow(clippy::single_match)]
match event.view() { match event.view() {
EventView::CustomDownstreamSticky(e) => { EventView::CustomDownstreamSticky(e) => {
let s = e.get_structure().unwrap(); let s = e.get_structure().unwrap();

View file

@ -524,8 +524,6 @@ impl Queue {
use gst::QueryView; use gst::QueryView;
gst_log!(self.cat, obj: pad, "Handling query {:?}", query); gst_log!(self.cat, obj: pad, "Handling query {:?}", query);
#[allow(clippy::redundant_pattern_matching)]
#[allow(clippy::single_match)]
match query.view_mut() { match query.view_mut() {
QueryView::Scheduling(ref mut q) => { QueryView::Scheduling(ref mut q) => {
let mut new_query = gst::Query::new_scheduling(); let mut new_query = gst::Query::new_scheduling();

View file

@ -16,6 +16,7 @@ use gst::subclass::prelude::*;
// Struct containing all the element data // Struct containing all the element data
struct ProgressBin { struct ProgressBin {
#[allow(dead_code)]
cat: gst::DebugCategory, cat: gst::DebugCategory,
progress: gst::Element, progress: gst::Element,
srcpad: gst::GhostPad, srcpad: gst::GhostPad,