Skip to content
This repository was archived by the owner on Oct 14, 2021. It is now read-only.

Commit 15c5a75

Browse files
authored
Merge pull request #34 from google/clippy
Run clippy on all the code
2 parents 7adb491 + 26ddbc4 commit 15c5a75

26 files changed

+668
-625
lines changed

.ci/build.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ case "$1" in
1111
doc)
1212
cargo doc --all
1313
;;
14-
esac
14+
clippy)
15+
cargo clippy --all-targets --all-features -- -D warnings
16+
;;
17+
esac

.ci/setup.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
#!/bin/bash
22

3-
if [ "$1" == "format" ]; then
4-
echo "Installing rustfmt..."
5-
rustup toolchain install nightly
6-
rustup component add --toolchain nightly rustfmt-preview
7-
which rustfmt || cargo install --force rustfmt-nightly
8-
cargo +nightly fmt -- --version
9-
fi
3+
case "$1" in
4+
format)
5+
echo "Installing rustfmt..."
6+
rustup component add --toolchain nightly rustfmt-preview
7+
which rustfmt || cargo install --force rustfmt-nightly
8+
cargo +nightly fmt -- --version
9+
;;
10+
clippy)
11+
echo "Installing clippy..."
12+
rustup component add clippy --toolchain=nightly || cargo install --git https://github.com/rust-lang/rust-clippy/ --force clippy
13+
;;
14+
esac

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ matrix:
1111
- name: "Rust: format"
1212
env: ACTION=format
1313
rust: nightly
14+
- name: "Rust: clippy"
15+
env: ACTION=clippy
16+
rust: nightly
1417
- name: "Rust: doc"
1518
env: ACTION=doc
1619
rust: stable

starlark-repl/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "starlark-repl"
3-
version = "0.2.0"
3+
version = "0.3.0-pre"
44
authors = ["Damien Martin-Guillerez <[email protected]>"]
55

66
description = "A REPL for the implementation in Rust of the Starlark language."
@@ -21,7 +21,7 @@ codemap = "0.1.1"
2121
codemap-diagnostic = "0.1"
2222
getopts = "0.2"
2323
linefeed = "0.5.3"
24-
starlark = { version = "0.2", path = "../starlark" }
24+
starlark = { path = "../starlark" }
2525

2626
[lib]
2727

starlark-repl/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub fn repl(global_environment: &Environment, dialect: Dialect) {
109109
reader.set_prompt(">>> ").unwrap();
110110

111111
while let Ok(ReadResult::Input(input)) = reader.read_line() {
112-
if input.len() != 0 {
112+
if !input.is_empty() {
113113
reader.set_prompt("... ").unwrap();
114114
n += 1;
115115
let input = input + "\n";

starlark/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "starlark"
3-
version = "0.2.0"
3+
version = "0.3.0-pre"
44
authors = ["Damien Martin-Guillerez <[email protected]>"]
55
build = "build.rs"
66

starlark/src/environment/mod.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ use values::*;
2424

2525
// TODO: move that code in some common error code list?
2626
// CM prefix = Critical Module
27-
const FROZEN_ENV_ERROR_CODE: &'static str = "CM00";
28-
const NOT_FOUND_ERROR_CODE: &'static str = "CM01";
29-
const CANNOT_IMPORT_ERROR_CODE: &'static str = "CE02";
27+
const FROZEN_ENV_ERROR_CODE: &str = "CM00";
28+
const NOT_FOUND_ERROR_CODE: &str = "CM01";
29+
const CANNOT_IMPORT_ERROR_CODE: &str = "CE02";
3030

3131
#[derive(Debug)]
3232
#[doc(hidden)]
@@ -207,7 +207,7 @@ impl EnvironmentContent {
207207
/// Get the value of the variable `name`
208208
pub fn get(&self, name: &str) -> Result<Value, EnvironmentError> {
209209
if self.variables.contains_key(name) {
210-
Ok(self.variables.get(name).unwrap().clone())
210+
Ok(self.variables[name].clone())
211211
} else {
212212
match self.parent {
213213
Some(ref p) => p.get(name),
@@ -233,7 +233,7 @@ impl EnvironmentContent {
233233
pub fn get_type_value(&self, obj: &Value, id: &str) -> Option<Value> {
234234
match self.type_objs.get(obj.get_type()) {
235235
Some(ref d) => match d.get(id) {
236-
Some(&ref v) => Some(v.clone()),
236+
Some(v) => Some(v.clone()),
237237
None => match self.parent {
238238
Some(ref p) => p.get_type_value(obj, id),
239239
None => None,
@@ -254,12 +254,10 @@ impl EnvironmentContent {
254254
r.push(k.clone());
255255
}
256256
r
257+
} else if let Some(ref p) = self.parent {
258+
p.list_type_value(obj)
257259
} else {
258-
if let Some(ref p) = self.parent {
259-
p.list_type_value(obj)
260-
} else {
261-
Vec::new()
262-
}
260+
Vec::new()
263261
}
264262
}
265263

0 commit comments

Comments
 (0)