Skip to content

Commit

Permalink
Clippy fixes (#729)
Browse files Browse the repository at this point in the history
* plot: clippy: Fix `needless_borrow` lints.

* ci: Enable clippy for all targets in the workspace.

* Update clippy section in `CONTRIBUTING.md`.

* Remove instances of `allow(clippy:all)`.

These are no longer needed.
  • Loading branch information
waywardmonkeys committed Oct 15, 2023
1 parent f0bb72c commit 5774cab
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:

- name: Check for clippy hints
if: ${{ matrix.rust == 'stable' }}
run: cargo clippy -- -D warnings
run: cargo clippy --workspace --all-targets -- -D warnings

# This fails on 1.64, but works on 1.66 and later.
# https://github.com/rust-lang/rust/issues/103306
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ cargo test --all
cargo bench
```

It's a good idea to run clippy and fix any warnings as well:
It's a good idea to run `clippy` and fix any warnings as well:

```
rustup component add clippy-preview
cargo clippy --all
rustup component add clippy
cargo clippy --workspace --all-targets
```

Finally, run Rustfmt to maintain a common code style:
Expand Down
3 changes: 0 additions & 3 deletions plot/src/axis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,6 @@ where
}

impl<'a> Script for (Axis, &'a Properties) {
// Allow clippy::format_push_string even with older versions of rust (<1.62) which
// don't have it defined.
#[allow(clippy::all)]
fn script(&self) -> String {
let &(axis, properties) = self;
let axis_ = axis.display();
Expand Down
3 changes: 0 additions & 3 deletions plot/src/candlestick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ impl Default for Properties {
}

impl Script for Properties {
// Allow clippy::format_push_string even with older versions of rust (<1.62) which
// don't have it defined.
#[allow(clippy::all)]
fn script(&self) -> String {
let mut script = String::from("with candlesticks ");

Expand Down
3 changes: 0 additions & 3 deletions plot/src/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ impl CurveDefault<Style> for Properties {
}

impl Script for Properties {
// Allow clippy::format_push_string even with older versions of rust (<1.62) which
// don't have it defined.
#[allow(clippy::all)]
fn script(&self) -> String {
let mut script = if let Some(axes) = self.axes {
format!("axes {} ", axes.display())
Expand Down
3 changes: 0 additions & 3 deletions plot/src/errorbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ impl ErrorBarDefault<Style> for Properties {
}

impl Script for Properties {
// Allow clippy::format_push_string even with older versions of rust (<1.62) which
// don't have it defined.
#[allow(clippy::all)]
fn script(&self) -> String {
let mut script = format!("with {} ", self.style.display());

Expand Down
3 changes: 0 additions & 3 deletions plot/src/filledcurve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ impl Default for Properties {
}

impl Script for Properties {
// Allow clippy::format_push_string even with older versions of rust (<1.62) which
// don't have it defined.
#[allow(clippy::all)]
fn script(&self) -> String {
let mut script = if let Some(axes) = self.axes {
format!("axes {} ", axes.display())
Expand Down
3 changes: 0 additions & 3 deletions plot/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ impl Properties {
}

impl Script for Properties {
// Allow clippy::format_push_string even with older versions of rust (<1.62) which
// don't have it defined.
#[allow(clippy::all)]
fn script(&self) -> String {
let mut script = if self.hidden {
return String::from("set key off\n");
Expand Down
7 changes: 2 additions & 5 deletions plot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,6 @@ impl Figure {
}
}

// Allow clippy::format_push_string even with older versions of rust (<1.62) which
// don't have it defined.
#[allow(clippy::all)]
fn script(&self) -> Vec<u8> {
let mut s = String::new();

Expand Down Expand Up @@ -1062,7 +1059,7 @@ mod test {
#[test]
fn test_parse_version_on_valid_string() {
let string = "gnuplot 5.0 patchlevel 7";
let version = super::parse_version(&string).unwrap();
let version = super::parse_version(string).unwrap();
assert_eq!(5, version.major);
assert_eq!(0, version.minor);
assert_eq!("7", &version.patch);
Expand All @@ -1071,7 +1068,7 @@ mod test {
#[test]
fn test_parse_gentoo_version() {
let string = "gnuplot 5.2 patchlevel 5a (Gentoo revision r0)";
let version = super::parse_version(&string).unwrap();
let version = super::parse_version(string).unwrap();
assert_eq!(5, version.major);
assert_eq!(2, version.minor);
assert_eq!("5a", &version.patch);
Expand Down

0 comments on commit 5774cab

Please sign in to comment.