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

Run clippy on all the code #34

Merged
merged 28 commits into from
Jan 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1ae985f
clippy: remove static lifetime from constant
damienmg Dec 31, 2018
ad44b0a
Set the next version to 0.3
damienmg Dec 31, 2018
7939ddf
clippy: replaced &Vec<..> by &[...] in function signatures
damienmg Dec 31, 2018
5495db8
clippy: removed useless & in pattern matching
damienmg Dec 31, 2018
c660ac3
clippy: using is_empty() instead of testing for null length
damienmg Jan 9, 2019
0ff441b
clippy: reduce if-else statement depth
damienmg Jan 9, 2019
6b657d3
clippy: removed useless returns
damienmg Jan 9, 2019
04bcc7d
clippy: renamed into_iter -> iter
damienmg Jan 9, 2019
f70a998
clippy: use _ as separator in numbers
damienmg Jan 9, 2019
41cff5f
clippy: use nth(i) instead of skip(i).next()
damienmg Jan 9, 2019
2817f4d
clippy: remove map(|x| x.clone())
damienmg Jan 9, 2019
e7692e3
clippy: reduce cyclomatic complexity of the expression evaluation fun…
damienmg Jan 9, 2019
f184a70
clippy: fix map accessors using []
damienmg Jan 9, 2019
a6a7d75
clippy: removed useless clone of item with Copy traits
damienmg Jan 9, 2019
f9ca75d
clippy: avoid match when let if is enough
damienmg Jan 9, 2019
da46aec
clippy: remove unused mut keywords
damienmg Jan 9, 2019
81e23bf
clippy: used iter instead of into_iter for a non-moved object
damienmg Jan 9, 2019
fa893dd
clippy: using char for single character string in find
damienmg Jan 9, 2019
dda0207
clippy: use u64::from instead of as u64
damienmg Jan 9, 2019
a2dfb0f
clippy: extract function signature to simplify the type writing
damienmg Jan 9, 2019
de4eacb
clippy: unwrap_or_else to wrap function calls
damienmg Jan 9, 2019
5911ccb
clippy: use write_all instead of write
damienmg Jan 9, 2019
01cdae1
clippy: ignore clippy warnings that we cannot do anything on
damienmg Dec 31, 2018
b846049
clippy: remove write! call when other call were better suited
damienmg Jan 10, 2019
223c160
clippy: cleanup structure construction
damienmg Jan 10, 2019
bfa2ec1
Make the grammar tests module a separate module from the grammar module
damienmg Jan 10, 2019
656fa15
Add clippy to Travis CI
damienmg Jan 10, 2019
26ddbc4
clippy: fix single character string pattern
damienmg Jan 11, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ case "$1" in
doc)
cargo doc --all
;;
esac
clippy)
cargo clippy --all-targets --all-features -- -D warnings
;;
esac
19 changes: 12 additions & 7 deletions .ci/setup.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#!/bin/bash

if [ "$1" == "format" ]; then
echo "Installing rustfmt..."
rustup toolchain install nightly
rustup component add --toolchain nightly rustfmt-preview
which rustfmt || cargo install --force rustfmt-nightly
cargo +nightly fmt -- --version
fi
case "$1" in
format)
echo "Installing rustfmt..."
rustup component add --toolchain nightly rustfmt-preview
which rustfmt || cargo install --force rustfmt-nightly
cargo +nightly fmt -- --version
;;
clippy)
echo "Installing clippy..."
rustup component add clippy --toolchain=nightly || cargo install --git https://github.com/rust-lang/rust-clippy/ --force clippy
;;
esac
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ matrix:
- name: "Rust: format"
env: ACTION=format
rust: nightly
- name: "Rust: clippy"
env: ACTION=clippy
rust: nightly
- name: "Rust: doc"
env: ACTION=doc
rust: stable
Expand Down
4 changes: 2 additions & 2 deletions starlark-repl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "starlark-repl"
version = "0.2.0"
version = "0.3.0-pre"
authors = ["Damien Martin-Guillerez <[email protected]>"]

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

[lib]

Expand Down
2 changes: 1 addition & 1 deletion starlark-repl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub fn repl(global_environment: &Environment, dialect: Dialect) {
reader.set_prompt(">>> ").unwrap();

while let Ok(ReadResult::Input(input)) = reader.read_line() {
if input.len() != 0 {
if !input.is_empty() {
reader.set_prompt("... ").unwrap();
n += 1;
let input = input + "\n";
Expand Down
2 changes: 1 addition & 1 deletion starlark/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "starlark"
version = "0.2.0"
version = "0.3.0-pre"
authors = ["Damien Martin-Guillerez <[email protected]>"]
build = "build.rs"

Expand Down
18 changes: 8 additions & 10 deletions starlark/src/environment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ use values::*;

// TODO: move that code in some common error code list?
// CM prefix = Critical Module
const FROZEN_ENV_ERROR_CODE: &'static str = "CM00";
const NOT_FOUND_ERROR_CODE: &'static str = "CM01";
const CANNOT_IMPORT_ERROR_CODE: &'static str = "CE02";
const FROZEN_ENV_ERROR_CODE: &str = "CM00";
const NOT_FOUND_ERROR_CODE: &str = "CM01";
const CANNOT_IMPORT_ERROR_CODE: &str = "CE02";

#[derive(Debug)]
#[doc(hidden)]
Expand Down Expand Up @@ -207,7 +207,7 @@ impl EnvironmentContent {
/// Get the value of the variable `name`
pub fn get(&self, name: &str) -> Result<Value, EnvironmentError> {
if self.variables.contains_key(name) {
Ok(self.variables.get(name).unwrap().clone())
Ok(self.variables[name].clone())
} else {
match self.parent {
Some(ref p) => p.get(name),
Expand All @@ -233,7 +233,7 @@ impl EnvironmentContent {
pub fn get_type_value(&self, obj: &Value, id: &str) -> Option<Value> {
match self.type_objs.get(obj.get_type()) {
Some(ref d) => match d.get(id) {
Some(&ref v) => Some(v.clone()),
Some(v) => Some(v.clone()),
None => match self.parent {
Some(ref p) => p.get_type_value(obj, id),
None => None,
Expand All @@ -254,12 +254,10 @@ impl EnvironmentContent {
r.push(k.clone());
}
r
} else if let Some(ref p) = self.parent {
p.list_type_value(obj)
} else {
if let Some(ref p) = self.parent {
p.list_type_value(obj)
} else {
Vec::new()
}
Vec::new()
}
}

Expand Down
Loading