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'
image: "rust:slim"
stage: 'extras'
allow_failure: true
script:
- 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 {
#[allow(dead_code)]
cat: gst::DebugCategory,
settings: Mutex<Settings>,
state: Mutex<Option<State>>,

View file

@ -164,7 +164,7 @@ impl BaseParseImpl for CdgParse {
.enumerate()
.find(|(_, byte)| (*byte & CDG_MASK == CDG_COMMAND))
.map(|(i, _)| i)
.unwrap_or(input.get_size()) // skip the whole buffer
.unwrap_or_else(|| input.get_size()) // skip the whole buffer
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> {
let settings = self.settings.lock().unwrap();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -524,8 +524,6 @@ impl Queue {
use gst::QueryView;
gst_log!(self.cat, obj: pad, "Handling query {:?}", query);
#[allow(clippy::redundant_pattern_matching)]
#[allow(clippy::single_match)]
match query.view_mut() {
QueryView::Scheduling(ref mut q) => {
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 ProgressBin {
#[allow(dead_code)]
cat: gst::DebugCategory,
progress: gst::Element,
srcpad: gst::GhostPad,