Repository: cobalt-org/liquid-rust
Pull request #72 (2017-01-14 23:59:12)

Refactor CI
I already made similar changes in Cobalt (https://github.com/cobalt-org/cobalt.rs/pull/176). This greatly improves build speed (even more so than in Cobalt because we don't build for OSX here) and stability. It also fixes the code coverage reporting.


Patch:
diff --git a/.travis.yml b/.travis.yml
index 445f0c3..ed9a6b8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,39 +1,53 @@
 sudo: false
 language: rust
-cache: cargo
 rust:
-- stable
-- beta
-- nightly
+  - stable
+  - beta
+  - nightly
 
-before_script:
-- |
-  pip install 'travis-cargo<0.2' --user &&
-  (cargo install rustfmt || true) &&
-  export PATH=$HOME/.local/bin:$PATH &&
-  export PATH=$HOME/.cargo/bin:$PATH
+install:
+  # Install rustfmt
+  - curl -LSfs https://japaric.github.io/trust/install.sh | sh -s -- --force --crate rustfmt --git japaric/rustfmt-bin --tag v0.6.3-20161120
+  # Install clippy
+  - if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then (cargo install clippy || true) fi
+  - export PATH=$HOME/.cargo/bin:$PATH
 
 script:
-- |
-  cargo fmt -- --write-mode=diff &&
-  travis-cargo build &&
-  travis-cargo test &&
-  travis-cargo --only stable doc
+  - cargo build
+  - cargo test
+  - if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then (cargo clippy) fi
+  - cargo fmt -- --write-mode=diff
 
 addons:
   apt:
     packages:
-    - libcurl4-openssl-dev
-    - libelf-dev
-    - libdw-dev
+      - libcurl4-openssl-dev
+      - libelf-dev
+      - libdw-dev
+      - cmake
+      - gcc
+      - binutils-dev
 
-after_success:
-- travis-cargo --only stable doc-upload
-- rm tests/skeptic.rs # "skip" skeptic doctests for coverage
-- travis-cargo --only stable coveralls --no-sudo
+cache:
+  apt: true
+  directories:
+    - $HOME/.cargo
+    - target/debug/build
+
+before_cache:
+    # Travis can't cache files that are not readable by "others"
+    - chmod -R a+r $HOME/.cargo
+
+after_success: |
+  [ $TRAVIS_RUST_VERSION = stable ] &&
+  wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz &&
+  tar xzf master.tar.gz && mkdir kcov-master/build && cd kcov-master/build && cmake .. && make && make install DESTDIR=../tmp && cd ../.. &&
+  ls target/debug &&
+  ./kcov-master/tmp/usr/local/bin/kcov --exclude-pattern=/.cargo target/kcov target/debug/fixtures-* &&
+  ./kcov-master/tmp/usr/local/bin/kcov --exclude-pattern=/.cargo target/kcov target/debug/filters-* &&
+  ./kcov-master/tmp/usr/local/bin/kcov --coveralls-id=$TRAVIS_JOB_ID --exclude-pattern=/.cargo target/kcov target/debug/liquid-*
 
 env:
   global:
-  - TRAVIS_CARGO_NIGHTLY_FEATURE="clippy"
   - secure: FGosPYxgSM1Csyy2q/OiSW2KA7IDlIlLTODxwgszP/MIwOIMobAs5f+IqrEngEi3zKa0IPahQ3DZMZFAaNw9e1gI90ZQKpYgDQHNPeCtO0q4OV94RAjAFqhqVPxXwmNug88tm3NMokzzOafosWD8AzL7dYAx63KBpgCNZteW6CM=
 
diff --git a/appveyor.yml b/appveyor.yml
index f431b75..0dcb2b5 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,9 +1,7 @@
-# This is based on https://github.com/rust-lang-nursery/rustfmt/blob/master/appveyor.yml
-# which is in turn based on https://github.com/japaric/rust-everywhere/blob/master/appveyor.yml
-
 environment:
   global:
-    PROJECT_NAME: liquid-rust
+    RUST_VERSION: stable
+
   matrix:
     # Stable channel
     - TARGET: x86_64-pc-windows-gnu
@@ -19,24 +17,27 @@ environment:
     - TARGET: x86_64-pc-windows-msvc
       CHANNEL: nightly
 
-# Install Rust and Cargo
-# (Based on from https://github.com/rust-lang/libc/blob/master/appveyor.yml)
 install:
-  - ps: Start-FileDownload "https://static.rust-lang.org/dist/channel-rust-stable"
-  - ps: $env:RUST_VERSION = Get-Content channel-rust-stable | select -first 1 | %{$_.split('-')[1]}
-  - if NOT "%CHANNEL%" == "stable" set RUST_VERSION=%CHANNEL%
-  - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-${env:RUST_VERSION}-${env:TARGET}.exe"
-  - rust-%RUST_VERSION%-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust"
-  - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin
-  - if "%TARGET%" == "i686-pc-windows-gnu" set PATH=%PATH%;C:\msys64\mingw32\bin
-  - if "%TARGET%" == "x86_64-pc-windows-gnu" set PATH=%PATH%;C:\msys64\mingw64\bin
-  - rustc -V
+  - ps: >-
+      If ($Env:TARGET -eq 'x86_64-pc-windows-gnu') {
+        $Env:PATH += ';C:\msys64\mingw64\bin'
+      } ElseIf ($Env:TARGET -eq 'i686-pc-windows-gnu') {
+        $Env:PATH += ';C:\msys64\mingw32\bin'
+      }
+  - curl -sSf -o rustup-init.exe https://win.rustup.rs/
+  - rustup-init.exe -y --default-host %TARGET% --default-toolchain %RUST_VERSION%
+  - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
+  - rustc -Vv
   - cargo -V
 
-# ???
-build: false
-
 # Build and test
 test_script:
   - cargo build --verbose
   - cargo test
+
+cache:
+  - C:\Users\appveyor\.cargo\registry
+  - target
+
+# disable automatic builds
+build: false
diff --git a/src/context.rs b/src/context.rs
index 8dbcfb3..1c47584 100644
--- a/src/context.rs
+++ b/src/context.rs
@@ -85,7 +85,7 @@ impl Context {
 
     /// Only add the given filter to the context if a filter with this name doesn't already exist.
     pub fn maybe_add_filter(&mut self, name: &str, filter: Box<Filter>) {
-        if let None = self.get_filter(name) {
+        if self.get_filter(name).is_none() {
             self.add_filter(name, filter)
         }
     }
@@ -128,7 +128,7 @@ impl Context {
     /// frame already in place, empyting the stack should never happen in a
     /// well-formed program.
     fn pop_scope(&mut self) {
-        if let None = self.stack.pop() {
+        if self.stack.pop().is_none() {
             panic!("Pop leaves empty stack")
         };
     }
@@ -220,11 +220,11 @@ impl Context {
     /// Translates a Token to a Value, looking it up in the context if
     /// necessary
     pub fn evaluate(&self, t: &Token) -> Result<Option<Value>> {
-        match t {
-            &NumberLiteral(f) => Ok(Some(Value::Num(f))),
-            &StringLiteral(ref s) => Ok(Some(Value::Str(s.clone()))),
-            &BooleanLiteral(b) => Ok(Some(Value::Bool(b))),
-            &Identifier(ref id) => Ok(self.get_val(id).cloned()),
+        match *t {
+            NumberLiteral(f) => Ok(Some(Value::Num(f))),
+            StringLiteral(ref s) => Ok(Some(Value::Str(s.clone()))),
+            BooleanLiteral(b) => Ok(Some(Value::Bool(b))),
+            Identifier(ref id) => Ok(self.get_val(id).cloned()),
             _ => {
                 let msg = format!("Cannot evaluate {}", t);
                 Err(Error::Other(msg))
diff --git a/src/filters.rs b/src/filters.rs
index a8ce678..caf5046 100644
--- a/src/filters.rs
+++ b/src/filters.rs
@@ -301,7 +301,7 @@ pub fn join(input: &Value, args: &[Value]) -> FilterResult {
             match args.first() {  // Check the first (and only) argument
                 Some(&Str(ref join_string)) => {
                     // The join string argument is in fact a String
-                    let mut result = strings_to_join.next().unwrap_or(String::new());
+                    let mut result = strings_to_join.next().unwrap_or_else(String::new);
                     for string in strings_to_join {
                         result.push_str(join_string);
                         result.push_str(&string);
@@ -339,7 +339,7 @@ pub fn slice(input: &Value, args: &[Value]) -> FilterResult {
             }
             // Check for overflows over string length and fallback to allowed values
             if start < 0 {
-                start = ilen + start;
+                start += ilen;
             }
             // start is guaranteed to be positive at this point
             if start + offset > ilen {
@@ -353,8 +353,8 @@ pub fn slice(input: &Value, args: &[Value]) -> FilterResult {
 
 pub fn sort(input: &Value, args: &[Value]) -> FilterResult {
     try!(check_args_len(args, 0));
-    match input {
-        &Value::Array(ref array) => {
+    match *input {
+        Value::Array(ref array) => {
             let mut sorted = array.clone();
             sorted.sort_by(|a, b| a.partial_cmp(b).unwrap_or(Ordering::Equal));
             Ok(Value::Array(sorted))
@@ -365,8 +365,8 @@ pub fn sort(input: &Value, args: &[Value]) -> FilterResult {
 
 pub fn date(input: &Value, args: &[Value]) -> FilterResult {
     try!(check_args_len(args, 1));
-    let date = match input {
-        &Value::Str(ref s) => {
+    let date = match *input {
+        Value::Str(ref s) => {
             try!(DateTime::parse_from_str(&s, "%d %B %Y %H:%M:%S %z")
                 .map_err(|e| FilterError::InvalidType(format!("Invalid date format: {}", e))))
         }
diff --git a/src/lib.rs b/src/lib.rs
index a867764..16bdc4b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -22,44 +22,11 @@
 #![crate_name = "liquid"]
 #![doc(html_root_url = "https://cobalt-org.github.io/liquid-rust/")]
 
-// This library uses Clippy!
-#![cfg_attr(feature="clippy", feature(plugin))]
-#![cfg_attr(feature="clippy", plugin(clippy))]
-
 // Deny warnings, except in dev mode
 #![deny(warnings)]
 // #![deny(missing_docs)]
 #![cfg_attr(feature="dev", warn(warnings))]
 
-// Ignore clippy, except in dev mode
-#![cfg_attr(feature="clippy", allow(clippy))]
-#![cfg_attr(feature="dev", warn(clippy))]
-
-// Stuff we want clippy to fail on
-#![cfg_attr(feature="clippy", deny(
-        explicit_iter_loop,
-        clone_on_copy,
-        len_zero,
-        map_clone,
-        map_entry,
-        match_bool,
-        match_same_arms,
-        new_ret_no_self,
-        new_without_default,
-        needless_borrow,
-        needless_lifetimes,
-        needless_range_loop,
-        needless_return,
-        no_effect,
-        ok_expect,
-        out_of_bounds_indexing,
-        ptr_arg,
-        redundant_closure,
-        single_char_pattern,
-        unused_collect,
-        useless_vec,
-        ))]
-
 #[macro_use]
 extern crate lazy_static;
 extern crate regex;
diff --git a/src/output.rs b/src/output.rs
index 8a3aa10..12f5a46 100644
--- a/src/output.rs
+++ b/src/output.rs
@@ -51,7 +51,7 @@ impl Output {
         let mut entry = match self.entry {
             VarOrVal::Val(ref x) => x.clone(),
             VarOrVal::Var(ref x) => {
-                context.get_val(&*x.name()).cloned().unwrap_or(Value::Str("".to_owned()))
+                context.get_val(&*x.name()).cloned().unwrap_or_else(|| Value::Str("".to_owned()))
             }
         };
 
@@ -62,14 +62,14 @@ impl Output {
 
             let mut arguments = Vec::new();
             for arg in &filter.arguments {
-                match arg {
-                    &VarOrVal::Var(ref x) => {
+                match *arg {
+                    VarOrVal::Var(ref x) => {
                         let val = try!(context.get_val(&*x.name())
                             .cloned()
                             .ok_or(Error::Render(format!("undefined variable {}", x.name()))));
                         arguments.push(val);
                     }
-                    &VarOrVal::Val(ref x) => arguments.push(x.clone()),
+                    VarOrVal::Val(ref x) => arguments.push(x.clone()),
                 }
             }
             entry = try!(f(&entry, &*arguments));
diff --git a/src/parser.rs b/src/parser.rs
index abecb08..91f8081 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -42,7 +42,7 @@ pub fn parse(elements: &[Element], options: &LiquidOptions) -> Result<Vec<Box<Re
 fn parse_expression(tokens: &[Token], options: &LiquidOptions) -> Result<Box<Renderable>> {
     match tokens[0] {
         Identifier(ref x) if options.tags.contains_key(x) => {
-            options.tags.get(x).unwrap()(x, &tokens[1..], options)
+            options.tags[x](x, &tokens[1..], options)
         }
         _ => {
             let output = try!(parse_output(tokens));
@@ -128,7 +128,7 @@ fn parse_tag(iter: &mut Iter<Element>,
     match *tag {
         // is a tag
         Identifier(ref x) if options.tags.contains_key(x) => {
-            options.tags.get(x).unwrap()(x, &tokens[1..], options)
+            options.tags[x](x, &tokens[1..], options)
         }
 
         // is a block
@@ -147,7 +147,7 @@ fn parse_tag(iter: &mut Iter<Element>,
             let mut children = vec![];
             let mut nesting_depth = 0;
             for t in iter {
-                if let &Tag(ref tokens, _) = t {
+                if let Tag(ref tokens, _) = *t {
                     match tokens[0] {
                         ref n if n == tag => {
                             nesting_depth += 1;
@@ -161,7 +161,7 @@ fn parse_tag(iter: &mut Iter<Element>,
                 };
                 children.push(t.clone())
             }
-            options.blocks.get(x).unwrap()(x, &tokens[1..], children, options)
+            options.blocks[x](x, &tokens[1..], children, options)
         }
 
         ref x => Err(Error::Parser(format!("parse_tag: {:?} not implemented", x))),
@@ -268,14 +268,13 @@ mod test {
             let result = parse_output(&tokens);
             assert_eq!(result.unwrap(),
                        Output::new(VarOrVal::Var(Variable::new("abc")),
-                                   vec![
-                    FilterPrototype::new("def", vec![
+                                   vec![FilterPrototype::new("def",
+                                                             vec![
                                          VarOrVal::Val(Value::str("1")),
                                          VarOrVal::Val(Value::Num(2.0)),
                                          VarOrVal::Val(Value::str("3")),
                     ]),
-                    FilterPrototype::new("blabla", vec![]),
-                ]));
+                                        FilterPrototype::new("blabla", vec![])]));
         }
 
         #[test]
diff --git a/src/tags/case_block.rs b/src/tags/case_block.rs
index af378bf..2ecb948 100644
--- a/src/tags/case_block.rs
+++ b/src/tags/case_block.rs
@@ -63,7 +63,7 @@ enum Conditional {
 }
 
 fn parse_condition(element: &Element) -> Result<Conditional> {
-    if let &Tag(ref tokens, _) = element {
+    if let Tag(ref tokens, _) = *element {
         match tokens[0] {
             Identifier(ref name) if name == "else" => return Ok(Conditional::Else),
 
diff --git a/src/tags/for_block.rs b/src/tags/for_block.rs
index d69f51f..3f44e7a 100644
--- a/src/tags/for_block.rs
+++ b/src/tags/for_block.rs
@@ -171,8 +171,8 @@ pub fn for_block(_tag_name: &str,
     let mut reversed = false;
 
     while let Some(token) = args.next() {
-        match token {
-            &Identifier(ref attr) => {
+        match *token {
+            Identifier(ref attr) => {
                 match attr.as_ref() {
                     "limit" => limit = try!(int_attr(&mut args)),
                     "offset" => offset = try!(int_attr(&mut args)).unwrap_or(0),


Test patch:
diff --git a/tests/custom_blocks.rs b/tests/custom_blocks.rs
index 7ea3ff0..edd5329 100644
--- a/tests/custom_blocks.rs
+++ b/tests/custom_blocks.rs
@@ -28,13 +28,13 @@ fn run() {
                     -> Result<Box<Renderable>, Error> {
 
         let numbers = arguments.iter()
-                               .filter_map(|x| {
-                                   match x {
-                                       &Token::NumberLiteral(ref num) => Some(*num),
-                                       _ => None,
-                                   }
-                               })
-                               .collect();
+            .filter_map(|x| {
+                match x {
+                    &Token::NumberLiteral(ref num) => Some(*num),
+                    _ => None,
+                }
+            })
+            .collect();
         Ok(Box::new(Multiply { numbers: numbers }))
     }
 
@@ -47,7 +47,7 @@ fn run() {
 
     let template = parse("wat\n{{hello}}\n{{multiply 5 3}}{%raw%}{{multiply 5 3}}{%endraw%} test",
                          options)
-                       .unwrap();
+        .unwrap();
 
     let mut data = Context::new();
     data.set_val("hello", Value::Str("world".to_string()));
diff --git a/tests/filters.rs b/tests/filters.rs
index 5f76d1c..8290a1e 100644
--- a/tests/filters.rs
+++ b/tests/filters.rs
@@ -11,7 +11,7 @@ use std::default::Default;
 pub fn upcase() {
     let text = "{{ text | upcase}}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
     data.set_val("text", Value::Str("hello".to_string()));
@@ -24,7 +24,7 @@ pub fn upcase() {
 pub fn downcase() {
     let text = "{{ text | downcase}}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
     data.set_val("text", Value::Str("HELLO tHeRe".to_string()));
@@ -37,7 +37,7 @@ pub fn downcase() {
 pub fn capitalize() {
     let text = "{{ text | capitalize}}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
     data.set_val("text", Value::Str("hello world".to_string()));
@@ -50,7 +50,7 @@ pub fn capitalize() {
 pub fn pluralize() {
     let text = "{{ count | pluralize: 'one', 'many'}}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
     data.set_val("count", Value::Num(1f32));
@@ -76,7 +76,7 @@ pub fn pluralize() {
 pub fn minus() {
     let text = "{{ num | minus : 2 }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
     data.set_val("num", Value::Num(4f32));
@@ -89,7 +89,7 @@ pub fn minus() {
 pub fn plus() {
     let text = "{{ num | plus : 2 }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
     data.set_val("num", Value::Num(4f32));
@@ -102,7 +102,7 @@ pub fn plus() {
 pub fn minus_error() {
     let text = "{{ num | minus }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
     data.set_val("num", Value::Num(4f32));
@@ -115,7 +115,7 @@ pub fn minus_error() {
 pub fn first() {
     let text = "{{ nums | first }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     // array of numbers
     let mut data = Context::new();
@@ -143,7 +143,7 @@ pub fn first() {
 pub fn last() {
     let text = "{{ list | last }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     // array of numbers
     let mut data = Context::new();
@@ -173,7 +173,7 @@ pub fn last() {
 pub fn replace_first() {
     let text = "{{ text | replace_first: 'bar', 'foo' }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
     data.set_val("text", Value::Str("bar2bar".to_string()));
@@ -186,7 +186,7 @@ pub fn replace_first() {
 pub fn replace() {
     let text = "{{ text | replace: 'bar', 'foo' }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
     data.set_val("text", Value::Str("bar2bar".to_string()));
@@ -199,7 +199,7 @@ pub fn replace() {
 pub fn prepend() {
     let text = "{{ text | prepend: 'fifo' }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
     data.set_val("text", Value::Str("bar2bar".to_string()));
@@ -209,7 +209,7 @@ pub fn prepend() {
 
     let text = "{{ text | prepend: myvar }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
     data.set_val("text", Value::Str("bar2bar".to_string()));
@@ -223,7 +223,7 @@ pub fn prepend() {
 pub fn append() {
     let text = "{{ text | append: 'lifo' }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
     data.set_val("text", Value::Str("roobarb".to_string()));
@@ -240,7 +240,7 @@ pub fn split_with_comma() {
     let text = "{% assign beatles = \"John, Paul, George, Ringo\" | split: \", \" %}{% for member \
                 in beatles %}{{ member }}\n{% endfor %}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
 
@@ -250,12 +250,12 @@ pub fn split_with_comma() {
 }
 
 #[test]
-// This test verifies that issue https://github.com/cobalt-org/liquid-rust/issues/40 is fixed (that split works)
+// This test verifies that issue #40 is fixed (that split works)
 pub fn split_no_comma() {
     let text = "{% assign letters = \"a~b~c\" | split:\"~\" %}{% for letter in letters %}LETTER: \
                 {{ letter }}\n{% endfor %}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
 
@@ -269,7 +269,7 @@ pub fn split_no_comma() {
 pub fn split_then_join() {
     let text = "{{ 'a~b~c' | split:'~' | join:', ' }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
 
@@ -282,7 +282,7 @@ pub fn split_then_join() {
 pub fn slice_one() {
     let text = "{{ '0123456' | slice: 2 }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
 
@@ -295,7 +295,7 @@ pub fn slice_one() {
 pub fn slice_negative() {
     let text = "{{ '6543210' | slice: -4, 3 }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
 
@@ -308,7 +308,7 @@ pub fn slice_negative() {
 pub fn slice_overflow() {
     let text = "{{ 'xx0123456' | slice: 2, 10.1 }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
 
@@ -321,7 +321,7 @@ pub fn slice_overflow() {
 pub fn slice_empty() {
     let text = "{{ '' | slice: 2 }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
 
@@ -334,7 +334,7 @@ pub fn slice_empty() {
 pub fn split_sort_join() {
     let text = "{{ 'zebra, octopus, giraffe, Sally Snake' | split:', ' | sort | join: ', '}}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
 
@@ -347,7 +347,7 @@ pub fn split_sort_join() {
 pub fn modulo() {
     let text = "{{ num | modulo: 2 }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
     let mut data = Context::new();
 
     let samples = [(4_f32, "0"), (3_f32, "1"), (5.1, "1.0999999")];
@@ -361,12 +361,14 @@ pub fn modulo() {
 pub fn escape() {
     let input = "{{ var | escape }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&input, options).unwrap();
+    let template = parse(input, options).unwrap();
     let mut data = Context::new();
 
-    let samples = [("abc", "abc"), ("", ""),
+    let samples = [("abc", "abc"),
+                   ("", ""),
                    ("<>&'\"", "&lt;&gt;&amp;&#39;&quot;"),
-                   ("1 < 2", "1 &lt; 2"), ("1 &lt; 2", "1 &amp;lt; 2"),
+                   ("1 < 2", "1 &lt; 2"),
+                   ("1 &lt; 2", "1 &amp;lt; 2"),
                    ("&etc.", "&amp;etc.")];
     for t in &samples {
         data.set_val("var", Value::Str(t.0.to_string()));
@@ -378,10 +380,11 @@ pub fn escape() {
 pub fn escape_once() {
     let input = "{{ var | escape_once }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&input, options).unwrap();
+    let template = parse(input, options).unwrap();
     let mut data = Context::new();
 
-    let samples = [("text", "text"), ("1 < 2 & 3", "1 &lt; 2 &amp; 3"),
+    let samples = [("text", "text"),
+                   ("1 < 2 & 3", "1 &lt; 2 &amp; 3"),
                    ("1 &lt; 2 &amp; 3", "1 &lt; 2 &amp; 3"),
                    ("&xyz;", "&amp;xyz;"),
                    ("<>&'\"", "&lt;&gt;&amp;&#39;&quot;"),
@@ -396,7 +399,7 @@ pub fn escape_once() {
 pub fn remove_first() {
     let text = "{{ text | remove_first: 'bar' }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
     data.set_val("text", Value::Str("bar2bar".to_string()));
@@ -406,7 +409,7 @@ pub fn remove_first() {
 
     let text = "{{ text | remove_first: myvar }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
     data.set_val("text", Value::Str("bar2bar".to_string()));
@@ -420,7 +423,7 @@ pub fn remove_first() {
 pub fn remove() {
     let text = "{{ text | remove: 'bar' }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
     data.set_val("text", Value::Str("bar2bar".to_string()));
@@ -433,10 +436,11 @@ pub fn remove() {
 pub fn strip_html() {
     let text = "{{ text | strip_html }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
-    data.set_val("text", Value::Str("<!-- <b> Comment -->Lorem <a>ipsum </b>dolor".to_string()));
+    data.set_val("text",
+                 Value::Str("<!-- <b> Comment -->Lorem <a>ipsum </b>dolor".to_string()));
 
     let output = template.render(&mut data);
     assert_eq!(output.unwrap(), Some("Lorem ipsum dolor".to_string()));
@@ -446,7 +450,7 @@ pub fn strip_html() {
 pub fn truncatewords() {
     let text = "{{ text | truncatewords: 1, '...' }}";
     let options: LiquidOptions = Default::default();
-    let template = parse(&text, options).unwrap();
+    let template = parse(text, options).unwrap();
 
     let mut data = Context::new();
     data.set_val("text", Value::Str("first seconds third".to_string()));
diff --git a/tests/parse_file.rs b/tests/parse_file.rs
index c803d45..c329d6b 100644
--- a/tests/parse_file.rs
+++ b/tests/parse_file.rs
@@ -6,7 +6,7 @@ use std::io::Read;
 use liquid::*;
 
 // README: The compare_by_file and following tests are almost line for line carbon-copies of the
-// tests in `fixutres.rs`. This might be overkill but keep that in mind when making changes to
+// tests in `fixtures.rs`. This might be overkill but keep that in mind when making changes to
 // fixtures that might necessitate changes to the parse_file method tested here.
 
 fn compare_by_file(name: &str, context: &mut Context) {