...
 
Commits (4)
stages:
- test
- lint
before_script:
- apt-get update -yqq
# - apt-get install -yqq --no-install-recommends build-essential
- apt-get install -yqq --no-install-recommends librsvg2-dev libgtk-3-dev
.cargo_test_template: &cargo_test
stage: test
script:
- rustc --version && cargo --version
- cargo build
- cargo test --verbose
variables:
RUST_BACKTRACE: "FULL"
stable:test:
# https://hub.docker.com/_/rust/
image: "rust"
<<: *cargo_test
# nightly:test:
# # https://hub.docker.com/r/rustlang/rust/
# image: "rustlang/rust:nightly"
# <<: *cargo_test
# Configure and run clippy on nightly
clippy:
image: "rustlang/rust:nightly"
stage: lint
script:
- rustc --version && cargo --version
- cargo install clippy --force
- cargo clippy --all
#![allow(unknown_lints)]
#![deny(clippy)]
extern crate structopt;
#[macro_use]
extern crate structopt_derive;
......@@ -73,11 +76,9 @@ fn process_path<P: AsRef<Path>>(opt: &Opt, path: P) -> Result<(), Error> {
if meta.is_dir() {
process_directory(opt, path)?;
} else {
if let Some(ext) = path.as_ref().extension() {
if ext == "svg" || ext == "SVG" {
process_file(opt, &path)?;
}
} else if let Some(ext) = path.as_ref().extension() {
if ext == "svg" || ext == "SVG" {
process_file(opt, &path)?;
}
}
......@@ -126,7 +127,7 @@ fn process_file<P: AsRef<Path>>(opt: &Opt, path: P) -> Result<(), Error> {
fn render_to_pixbuf(handle: &rsvg::Handle) -> Result<(), ProcessingError> {
handle.get_pixbuf()
.ok_or(ProcessingError::RenderingError)
.ok_or_else(|| ProcessingError::RenderingError)
.map(|_| ())
}
......@@ -180,7 +181,7 @@ fn run(opt: &Opt) -> Result<(), Error> {
fn main() {
let opt = Opt::from_args();
if opt.inputs.len() == 0 {
if opt.inputs.is_empty() {
eprintln!("No input files or directories specified\n");
let app = Opt::clap();
......