Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure clippy to error on warnings #692

Conversation

charlesbluca
Copy link
Collaborator

Adds -D warnings to the clippy entrypoint in our pre-commit config so that warnings will now cause our linting to fail. Will also attempt to fix the existing warnings in this PR.

@@ -24,7 +24,7 @@ repos:
- id: cargo-check
args: ['--manifest-path', './dask_planner/Cargo.toml', '--verbose', '--']
- id: clippy
args: ['--manifest-path', './dask_planner/Cargo.toml', '--verbose', '--']
args: ['--manifest-path', './dask_planner/Cargo.toml', '--verbose', '--', '-D', 'warnings']
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to note that we can also configure clippy to automatically fix some of the more easily corrected warnings with

Suggested change
args: ['--manifest-path', './dask_planner/Cargo.toml', '--verbose', '--', '-D', 'warnings']
args: ['--manifest-path', './dask_planner/Cargo.toml', '--fix', '--allow-dirty', '--verbose', '--', '-D', 'warnings']

Was just hesitant to do this by default as the error message when leaving out --allow-dirty seemed to imply that this could result in destructive changes; @andygrove @jdye64 do you have any preferences here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer that we fix any warnings ourselves, even if we are often just copying & pasting Clippy's suggestions. I think this is an excellent way to learn more about writing idiomatic Rust code.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with Andy's comments here

@jdye64
Copy link
Collaborator

jdye64 commented Aug 16, 2022

For clarity is the plan to manually fix all the clippy warnings in this PR or a subsequent one?

@charlesbluca
Copy link
Collaborator Author

@jdye64 plan is to manually fix all the clippy warnings in this PR, I've managed to narrow it down to only two:

error: deref on an immutable reference
   --> src/sql/types.rs:272:36
    |
272 |     pub fn from_string(input_type: &str) -> Self {
    |                                    ^ help: if you would like to reborrow, try removing `&*`: `&`
    |
    = note: `-D clippy::borrow-deref-ref` implied by `-D warnings`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrow_deref_ref

error: deref on an immutable reference
   --> src/sql.rs:229:34
    |
229 |     pub fn parse_sql(&self, sql: &str) -> PyResult<Vec<statement::PyStatement>> {
    |                                  ^ help: if you would like to reborrow, try removing `&*`: `&`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrow_deref_ref

error: could not compile `dask_planner` due to 2 previous errors

@codecov-commenter
Copy link

codecov-commenter commented Aug 16, 2022

Codecov Report

❗ No coverage uploaded for pull request base (datafusion-sql-planner@9d4b9d1). Click here to learn what that means.
The diff coverage is n/a.

@@                    Coverage Diff                    @@
##             datafusion-sql-planner     #692   +/-   ##
=========================================================
  Coverage                          ?   66.97%           
=========================================================
  Files                             ?       73           
  Lines                             ?     3637           
  Branches                          ?      753           
=========================================================
  Hits                              ?     2436           
  Misses                            ?     1055           
  Partials                          ?      146           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Collaborator

@jdye64 jdye64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jdye64 jdye64 merged commit 9b83d77 into dask-contrib:datafusion-sql-planner Aug 16, 2022
@charlesbluca charlesbluca deleted the clippy-enforce-warnings branch August 31, 2022 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants